我正在尝试通过本地Ansible Tower剧本启动EC2实例。
我可以从云中的AWX实例运行完全相同的剧本,而不会出现问题。尽你所能,输出实际上并没有帮助。我可以针对其他EC2实例运行剧本,因此连接似乎不是问题。
我的想法不多了。
剧本和输出如下。
PLAYBOOK:
---
- hosts: localhost
connection: local
gather_facts: False
tasks:
- name: Launch the new EC2 Instance
ec2:
group: "{{ ec2_security_group }}"
instance_type: "{{ ec2_instance_type }}"
image: "{{ ec2_ami }}"
wait: true
region: "{{ ec2_region }}"
keypair: "{{ ec2_keypair }}"
count: 1
vpc_subnet_id: "{{ ec2_vpc_subnet_id }}"
register: ec2
- name: Add new instance to host group
add_host:
hostname: "{{ item.private_ip }}"
groupname: launched
loop: "{{ ec2.instances }}"
- set_stats:
data:
instanceid: "{{ ec2.instance_ids }}"
- name: Wait for SSH to initialise
wait_for:
host: "{{ item.private_ip }}"
port: 22
state: started
loop: "{{ ec2.instances }}"
- name: Pause for instance to initialise
pause:
minutes: 1
- name: output results
debug:
msg:
- "{{ ec2.instance_ids }}"
Playbook调试信息:
Identity added: /tmp/awx_1465_pRdfhE/credential_22 (/tmp/awx_1465_pRdfhE/credential_22)
ansible-playbook 2.7.9
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/var/lib/awx/venv/awx/lib/python2.7/site-packages/awx/plugins/library']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 2.7.5 (default, Sep 12 2018, 05:31:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
Using /etc/ansible/ansible.cfg as config file
/tmp/awx_1465_pRdfhE/tmpV2NHtz did not meet host_list requirements, check plugin documentation if this is unexpected
Parsed /tmp/awx_1465_pRdfhE/tmpV2NHtz inventory source with script plugin
PLAYBOOK: rhel_ec2_provision_1a.yml ********************************************
2 plays in linux/build/aws/1a/rhel_ec2_provision_1a.yml
PLAY [localhost] ***************************************************************
META: ran handlers
TASK [Launch the new EC2 Instance] *********************************************
task path: /var/lib/awx/projects/_6__demo_project43142_pm/linux/build/aws/1a/rhel_ec2_provision_1a.yml:7
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: awx
<127.0.0.1> EXEC /bin/sh -c 'echo ~awx && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /var/lib/awx/.ansible/tmp/ansible-tmp-1562741869.82-200390624175568 `" && echo ansible-tmp-1562741869.82-200390624175568="` echo /var/lib/awx/.ansible/tmp/ansible-tmp-1562741869.82-200390624175568 `" ) && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/amazon/ec2.py
<127.0.0.1> PUT /var/lib/awx/.ansible/tmp/ansible-local-3DXeWyv/tmpdTV8K9 TO /var/lib/awx/.ansible/tmp/ansible-tmp-1562741869.82-200390624175568/AnsiballZ_ec2.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /var/lib/awx/.ansible/tmp/ansible-tmp-1562741869.82-200390624175568/ /var/lib/awx/.ansible/tmp/ansible-tmp-1562741869.82-200390624175568/AnsiballZ_ec2.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2 /var/lib/awx/.ansible/tmp/ansible-tmp-1562741869.82-200390624175568/AnsiballZ_ec2.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /var/lib/awx/.ansible/tmp/ansible-tmp-1562741869.82-200390624175568/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/var/lib/awx/.ansible/tmp/ansible-tmp-1562741869.82-200390624175568/AnsiballZ_ec2.py", line 113, in <module>
_ansiballz_main()
File "/var/lib/awx/.ansible/tmp/ansible-tmp-1562741869.82-200390624175568/AnsiballZ_ec2.py", line 105, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/var/lib/awx/.ansible/tmp/ansible-tmp-1562741869.82-200390624175568/AnsiballZ_ec2.py", line 48, in invoke_module
imp.load_module('__main__', mod, module, MOD_DESC)
File "/tmp/ansible_ec2_payload_1tiKTi/__main__.py", line 1702, in <module>
File "/tmp/ansible_ec2_payload_1tiKTi/__main__.py", line 1686, in main
File "/tmp/ansible_ec2_payload_1tiKTi/__main__.py", line 989, in create_instances
File "/var/lib/awx/venv/ansible/lib/python2.7/site-packages/boto/vpc/__init__.py", line 1152, in get_all_subnets
return self.get_list('DescribeSubnets', params, [('item', Subnet)])
File "/var/lib/awx/venv/ansible/lib/python2.7/site-packages/boto/connection.py", line 1170, in get_list
response = self.make_request(action, params, path, verb)
File "/var/lib/awx/venv/ansible/lib/python2.7/site-packages/boto/connection.py", line 1116, in make_request
return self._mexe(http_request)
File "/var/lib/awx/venv/ansible/lib/python2.7/site-packages/boto/connection.py", line 1030, in _mexe
raise ex
socket.error: [Errno 104] Connection reset by peer
fatal: [localhost]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\\n File \\"/var/lib/awx/.ansible/tmp/ansible-tmp-1562741869.82-200390624175568/AnsiballZ_ec2.py\\", line 113, in <module>\\n _ansiballz_main()\\n File \\"/var/lib/awx/.ansible/tmp/ansible-tmp-1562741869.82-200390624175568/AnsiballZ_ec2.py\\", line 105, in _ansiballz_main\\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\\n File \\"/var/lib/awx/.ansible/tmp/ansible-tmp-1562741869.82-200390624175568/AnsiballZ_ec2.py\\", line 48, in invoke_module\\n imp.load_module('__main__', mod, module, MOD_DESC)\\n File \\"/tmp/ansible_ec2_payload_1tiKTi/__main__.py\\", line 1702, in <module>\\n File \\"/tmp/ansible_ec2_payload_1tiKTi/__main__.py\\", line 1686, in main\\n File \\"/tmp/ansible_ec2_payload_1tiKTi/__main__.py\\", line 989, in create_instances\\n File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/boto/vpc/__init__.py\\", line 1152, in get_all_subnets\\n return self.get_list('DescribeSubnets', params, [('item', Subnet)])\\n File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/boto/connection.py\\", line 1170, in get_list\\n response = self.make_request(action, params, path, verb)\\n File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/boto/connection.py\\", line 1116, in make_request\\n return self._mexe(http_request)\\n File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/boto/connection.py\\", line 1030, in _mexe\\n raise ex\\nsocket.error: [Errno 104] Connection reset by peer\\n",
"module_stdout": "",
"msg": "MODULE FAILURE\\nSee stdout/stderr for the exact error",
"rc": 1
}
PLAY RECAP