amazon web services - Ansible can't resolve EC2 tag if specified in static inventory -
i using ansible deploy amazon ec2, , have ec2.py , ec2.ini set such can retrieve list of servers amazon. have server @ aws tagged rvmdocker:production
, , ansible --list
returns tag ec2_tag_rvmdocker_production.
can run:
ansible -m ping tag_rvmdocker_production`
and works. if have tag in static inventory file, , run:
ansible -m ping -i production
it returns:
tag_rvmdocker_production | unreachable! => { "changed": false, "msg": "error! ssh encountered unknown error during connection. werecommend re-run command using -vvvv, enable ssh debugging output diagnose issue", "unreachable": true }
here production inventory file:
[dockerservers] tag_rvmdocker_production
it looks ansible can't resolve tag_rvmdocker_production
when it's in static inventory file.
update
i followed ydaetskcor's advice , getting new error message:
$ ansible-playbook -i production app.yml error! error! production:2: section [dockerservers:children] includes undefined group: tag_rvmdocker_production
but know tag exists, , seems ansible , ec2.py know it:
$ ansible tag_rvmdocker_production --list hosts (1): 12.34.56.78
here production inventory:
[dockerservers:children] tag_rvmdocker_production
and app.yml playbook file:
--- - name: deploy rvm app production hosts: dockerservers remote_user: ec2-user become: true roles: - ec2 - myapp
in end, i'd love able run same playbook against development (a vm on mac), staging, or production, start environment. thought have static inventory files pointed tags or groups on ec2. approaching right way?
i had similar issue this, , resolved follows.
first, created folder contain inventory files, , put in there symlink /etc/ec2.ini
, copy (or symlink) ec2.py
script (with executable status), , hosts
file follows.
$ ls amg-dev/* amg-dev/ec2.ini -> /etc/ec2.ini amg-dev/ec2.py amg-dev/hosts
my ec2 instances tagged type = amg_dev_web
the hosts file contains following information - blank first entry important here.
[tag_type_amg_dev_web] [webservers:children] tag_type_amg_dev_web [all:children] webservers
then when run ansible-playbook
specify name of folder only inventory makes ansible read hosts
file, , execute ec2.py
script interrogate aws.
ansible-playbook -i amg-dev/ playbook.yml
inside playbook, refer these webservers
follows
- name: web | install , configure relevant packages hosts: webservers roles: - common - web
which seems work expected.
Comments
Post a Comment