我遇到了一个似乎试图在两台主机上运行的任务,如下所示:
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
...