Ansible 有很多专业的配置,但是如下简单几步就可以让你先玩起来了 ~_~

安装:

# yum install ansible

 

服务器免密认证:

如果对方直接有 authorized_keys 文件,则直接添加 key 内容 。
# ssh root@192.168.1.101 'cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub

如果对方机器没有,就要先建立 .ssh 目录及 authorized_keys 文件,然后再添加 key 内容 。
# ssh root@192.168.1.101 'mkdir -p .ssh && cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub

 

增加群组:

# vim /etc/ansible/hosts
[test]
172.168.1.101
172.168.1.102
172.168.1.103
172.168.1.104
172.168.1.105
172.168.1.106

 

PING:

# ansible "test" -m ping

执行命令:

# ansible "test" -m shell -a "ls -l /usr/local/src/"

启动服务:(started/stopped/restarted)

# ansible "172.16.1.101" -m service -a "name=zabbix-agent state=started"

拷贝文件:

# ansible "test" -m copy -a "src=/usr/local/src/ansible_test.txt dest=/usr/local/src/ansible_test.txt"

查看机器信息:

# ansible "test" -m setup

 

[ TO BE CONTINUE ]

相关文章:

  • 2021-04-02
  • 2021-07-02
  • 2022-12-23
  • 2022-12-23
  • 2021-09-27
  • 2021-07-19
  • 2021-12-02
  • 2021-06-17
猜你喜欢
  • 2022-01-28
  • 2021-11-21
  • 2021-07-14
  • 2021-05-23
  • 2021-07-25
  • 2022-12-23
  • 2021-04-20
相关资源
相似解决方案