![需要解释什么情况下会导致同一尝试在两台主机上运行任务?](https://linux22.com/image/727201/%E9%9C%80%E8%A6%81%E8%A7%A3%E9%87%8A%E4%BB%80%E4%B9%88%E6%83%85%E5%86%B5%E4%B8%8B%E4%BC%9A%E5%AF%BC%E8%87%B4%E5%90%8C%E4%B8%80%E5%B0%9D%E8%AF%95%E5%9C%A8%E4%B8%A4%E5%8F%B0%E4%B8%BB%E6%9C%BA%E4%B8%8A%E8%BF%90%E8%A1%8C%E4%BB%BB%E5%8A%A1%EF%BC%9F.png)
我遇到了一个似乎试图在两台主机上运行的任务,如下所示:
TASK [setup] *******************************************************************
fatal: [====]: UNREACHABLE! => {"changed": false, "msg": "ssl: auth method ssl requires a password", "unreachable": true}
ok: [web-app.source-ami]
当然,我正在尝试调试该错误并找出错误来源====
。
但这也是我第一次遇到一次尝试在多个主机上运行这样的任务。
TASK [setup] *******************************************************************
Using module file /usr/local/lib/python2.7/site-packages/ansible/modules/core/windows/setup.ps1
<====> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO ====
fatal: [====]: UNREACHABLE! => {
"changed": false,
"msg": "ssl: auth method ssl requires a password",
"unreachable": true
}
Using module file /usr/local/lib/python2.7/site-packages/ansible/modules/core/system/setup.py
<web-app.source-ami> ESTABLISH LOCAL CONNECTION FOR USER: ec2-user
<web-app.source-ami> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1536934067.19-26447522223236 `" && echo ansible-tmp-1536934067.19-26447522223236="` echo $HOME/.ansible/tmp/ansible-tmp-1536934067.19-26447522223236 `" ) && sleep 0'
<web-app.source-ami> PUT /tmp/tmpFfmjhW TO /home/ec2-user/.ansible/tmp/ansible-tmp-1536934067.19-26447522223236/setup.py
<web-app.source-ami> EXEC /bin/sh -c 'chmod u+x /home/ec2-user/.ansible/tmp/ansible-tmp-1536934067.19-26447522223236/ /home/ec2-user/.ansible/tmp/ansible-tmp-1536934067.19-26447522223236/setup.py && sleep 0'
<web-app.source-ami> EXEC /bin/sh -c '/usr/bin/python /home/ec2-user/.ansible/tmp/ansible-tmp-1536934067.19-26447522223236/setup.py; rm -rf "/home/ec2-user/.ansible/tmp/ansible-tmp-1536934067.19-26447522223236/" > /dev/null 2>&1 && sleep 0'
ok: [web-app.source-ami]
PLAYBOOK 的启动过程如下:
---
- name: Fetch AMI ID
hosts: base-source-amis:&{{ subset | default('None') }}
connection: local
tags: [ ami-id ]
roles:
- { role: do_something }
命令:
ansible-playbook -i ../../hosts_file \
-e subset=ami-bakes-resources \
playbook
我查看了库存,它看起来很简单,没有在====
任何地方提及。
Hosts_文件:
localhost ansible_connection=local
[base-resources]
web-app.ec2
web-app.source-ami
[base-source-amis]
web-app.source-ami
[ami-bakes-resources:children]
base-resources
主机变量:
# host_vars/web-app.source-ami
---
aws_resource_id: ami-34549s3d
...
目前没有适用于群组的群组变量。
我也搜索过winrm
它用于连接其他地方的 Windows 实例,但这里的任务是connection: local
在 Linux 机器上运行时使用的。
# group_vars/windows-instances/settings.yml
---
ansible_connection: winrm
ansible_ssh_port: 5986
ansible_ssh_user: Administrator
...