问题描述
我正在尝试配置在Ansible上运行Windows的EC2计算机。我正在使用AWX来做到这一点。连接到EC2机器后,我将其添加到主机列表中,然后尝试对其进行配置,但是, 尝试从新的ec2系统中搜集事实时,出现以下错误:
Error 'ShellModule' object has no attribute 'ECHO'
当我将collect_facts设置为false时,一切正常,但是我需要collect_facts,因此需要启用此功能。
代码如下:
- name: Connecting to existing EC2 instance to retrieve Metadata @R_985_4045@ion
ec2_instance_facts:
region: "{{ region }}"
filters:
tag:Name: "{{ hostname }}"
register: ec2
# Add machine to hosts in order to connect to it and apply changes
- name: add {{hostname}}.{{domain}} to setup_ec2 group
add_host:
name: "{{ hostname }}"
ansible_host: "{{ hostname }}"
ansible_password: "{{ service_pw }}"
ansible_user: "{{ service_user }}"
groups: setup_ec2
ansible_connection: winrm
ansible_winrm_transport: kerberos
ansible_winrm_server_cert_validation: ignore
ansible_ssh_port: 5986
- name: Change to read permissions for ansible pem file
file:
path: ./keys.pem
owner: root
group: root
mode: '0400'
- name: ADD HOST FOR ANSIBLE --> EDIT /etc/hosts on Docker
add_host:
hostname: ansible
groupname: ansible
ansible_ssh_host: "{{ ansible_ip }}"
ansible_user: ansible
ansible_private_key_file: ./keys.pem
# Adding ec2 instance to ansible AWX in order to connect to it
- hosts: ansible
gather_facts: true
tasks:
- set_fact:
ec2: "{{ hostvars['localhost']['ec2'] }}"
- set_fact:
hostname: "{{ hostvars['localhost']['hostname'] }}"
- name: copy /tmp/hosts to /etc/hosts
command: docker exec -u 0 awx_task bash -c "echo '{{ ec2.instances[0].private_ip_address }} {{ hostname }}{{ domain }}' >> /etc/hosts"
become: true
# Connecting to ec2 host and applying changes e.g. roles
- hosts: setup_ec2
gather_facts: true << here comes this error
如何解决此错误?我尝试了很多事情,四处张望,但似乎无法解决。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)