我创建了两个ubuntu Docker容器,一个带有控制节点,另一个带有从属容器。我跑了
ansible all -m service -a "name=ssh state=stopped"
它显示
172.18.0.3 | CHANGED => {
"changed": true,
"name": "ssh",
"status": {
"enabled": {
"changed": false,
"rc": null,
"stderr": null,
"stdout": null
},
"stopped": {
"changed": true,
"rc": 0,
"stderr": "",
"stdout": " * Stopping OpenBSD Secure Shell server sshd\n ...done.\n"
}
}
}
然后我尝试手动ssh失败,因为openssh服务器已停止,这很好。然后我运行了另一个命令来启动它。
# ansible all -m service -a "name=ssh state=started"
172.18.0.3 | CHANGED => {
"changed": true,
"name": "ssh",
"status": {
"enabled": {
"changed": false,
"rc": null,
"stderr": null,
"stdout": null
},
"started": {
"changed": true,
"rc": 0,
"stderr": "",
"stdout": " * Starting OpenBSD Secure Shell server sshd\n ...done.\n"
}
}
}
我很惊讶,当我已经停止节点的ssh服务时,ansible如何连接到该节点?是否有其他方法可将ansible连接到除ssh以外的节点?