ansible

黄色:成功执行并伴随着状态的改变

绿色:成功执行并且没有发生状态的改变

红色:执行失败

灰紫:表示对命令执行发出警告信息,(可能存在问题,给你建议一下)

yum install -y ansible

ansible主机往其他方向需要ssh信任

ssh-keygen -t rsa

ssh-copy-id .ssh/id_rsa.pub 172.16.0.222

ssh-copy-id .ssh/id_rsa.pub 172.16.0.223

vim /etc/ansible/hosts 添加

[web]
172.16.0.222

[mariadb]
172.16.0.223

[test:children]
web
mariadb

 

ansible test -m ping

------------------------------------------------------

172.16.0.223 | SUCCESS => {
"changed": false,
"ping": "pong"
}
172.16.0.222 | SUCCESS => {
"changed": false,
"ping": "pong"
}

------------------------------------------------------

 

[root@ansible ~]# ansible web -m yum -a 'name=screen state=install'
172.16.0.222 | FAILED! => {
"changed": false,
"msg": "value of state must be one of: absent,present,installed,removed,latest, got: install"
}
[root@ansible ~]# ansible web -m yum -a 'name=screen state=removed'
172.16.0.222 | SUCCESS => {
  "changed": false,
  "msg": "",
  "rc": 0,
  "results": [
    "screen is not installed"
  ]
}

-----------------------------------------------------------------------------------

 

posted @ 2020-03-24 10:47  Le1543  阅读(168)  评论(0编辑  收藏  举报