redhatgov.workshops
redhatgov.workshops copied to clipboard
hostvars[inventory_hostname]['ec2_tag_Index'] not working
The expression hostvars[inventory_hostname]['ec2_tag_Index']
used in many places is not working... It appears this fact is not being returned in hostvars fact....
TASK [wetty : Copy cert.pem to Wetty dir] ***************************************************************************************************************************************
fatal: [redhatgovbr.0.redhatbr.io]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'ec2_tag_Index'\n\nThe error appears to have been in '/home/rsoares/workshops/RedHatGov/redhatgov.workshops/roles/wetty/tasks/main.yml': line 57, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n#-------------------------------------------------------\n- name: Copy cert.pem to Wetty dir\n ^ here\n\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'dict object' has no attribute 'ec2_tag_Index'"}
to retry, use: --limit @/home/rsoares/.ansible-retry/2_configure.retry
Just for reference, I am running into this as well:
TASK [wetty : Copy cert.pem to Wetty dir] ****************************************************************************************** fatal: [EduCauseTrey.tower.0.redhatgov.io]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'ec2_tag_Index'\n\nThe error appears to have been in '/home/tprinz/Documents/Projects/EduCause-2018-Ansible-Workshop/redhatgov.workshops/roles/wetty/tasks/main.yml': line 39, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n#-------------------------------------------------------\n- name: Copy cert.pem to Wetty dir\n ^ here\n"} fatal: [EduCauseTrey.tower.1.redhatgov.io]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'ec2_tag_Index'\n\nThe error appears to have been in '/home/tprinz/Documents/Projects/EduCause-2018-Ansible-Workshop/redhatgov.workshops/roles/wetty/tasks/main.yml': line 39, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n#-------------------------------------------------------\n- name: Copy cert.pem to Wetty dir\n ^ here\n"}
Interesting. What versions of boto and botocore are you using? What Ansible version, as well.
Thanks!
- Alex
On Wed, Oct 24, 2018 at 9:36 AM t-prinz [email protected] wrote:
Just for reference, I am running into this as well:
TASK [wetty : Copy cert.pem to Wetty dir]
fatal: [EduCauseTrey.tower.0.redhatgov.io]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'ec2_tag_Index'\n\nThe error appears to have been in '/home/tprinz/Documents/Projects/EduCause-2018-Ansible-Workshop/redhatgov.workshops/roles/wetty/tasks/main.yml': line 39, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n#-------------------------------------------------------\n- name: Copy cert.pem to Wetty dir\n ^ here\n"} fatal: [EduCauseTrey.tower.1.redhatgov.io]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'ec2_tag_Index'\n\nThe error appears to have been in '/home/tprinz/Documents/Projects/EduCause-2018-Ansible-Workshop/redhatgov.workshops/roles/wetty/tasks/main.yml': line 39, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n#-------------------------------------------------------\n- name: Copy cert.pem to Wetty dir\n ^ here\n"}
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/RedHatGov/redhatgov.workshops/issues/42#issuecomment-432658495, or mute the thread https://github.com/notifications/unsubscribe-auth/AVdXcqd_EuoxntZKvCnNO-IirLrJ5r6Sks5uoGzBgaJpZM4VVlbG .
--
J. Alexander Jacocks | Senior Solutions Architect (e) [email protected] | Public Sector Business Development (c) (240) 447-5974 | Tyson's Corner, VA (g) CC28 8136 C253 907A B9BB 9EEA D3C8 1A3A 790A 0AB9
I'm using on my Mac:
Python 2.7.15
Ansible 2.6.2
Terraform v0.11.10
pip list | grep boto
boto 2.49.0
boto3 1.7.72
botocore 1.10.72
But, in order to get instances tag from ec2 I had to use this: https://github.com/rafaeltuelho/redhatgov.workshops/blob/redhatbr/roles/wetty/tasks/main.yml#L3-L10
and then I can use this: {{ hostvars[inventory_hostname].ec2_tags.tags.Index }}
, like in https://github.com/rafaeltuelho/redhatgov.workshops/blob/redhatbr/roles/wetty/tasks/main.yml#L52
Rafael,
You might want to consider using something like this:
-
name: lookup running RHEL instances ec2_instance_facts: region: "{{ region }}" filters: tag:rhel: "at-{{ workshop_prefix }}" register: ec2_rhel
-
debug: var: ec2_rhel
-
name: Append RHEL instances to list` set_fact: rhel_instance_ids: "{{ rhel_instance_ids }} + [ '{{ item.instance_id }}' ]" with_items: "{{ ec2_rhel.instances }}"
That pulls instance tags (you can see me filtering for tags, in the first task. See the "ansible_tower_aws" workshop for more information.
Does that make sense?
Thanks!
- Alex
On Thu, Dec 6, 2018 at 9:12 AM Rafael T. C. Soares (A.K.A Tuelho) < [email protected]> wrote:
I'm using on my Mac:
Python 2.7.15 Ansible 2.6.2 Terraform v0.11.10
pip list | grep boto boto 2.49.0 boto3 1.7.72 botocore 1.10.72
But, in order to get instances tags from ec2 I had to use this: https://github.com/rafaeltuelho/redhatgov.workshops/blob/redhatbr/roles/LetsEncrypt/tasks/main.yml#L3-L12
and then I can use this: {{ hostvars[inventory_hostname].ec2_tags.tags.Index }}, like in https://github.com/rafaeltuelho/redhatgov.workshops/blob/redhatbr/roles/LetsEncrypt/tasks/main.yml#L46
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/RedHatGov/redhatgov.workshops/issues/42#issuecomment-444883448, or mute the thread https://github.com/notifications/unsubscribe-auth/AVdXch4CX0QBWDYNXB_lPAVQ6Sh6filnks5u2SXSgaJpZM4VVlbG .
--
J. Alexander Jacocks | Senior Solutions Architect (e) [email protected] | Public Sector Business Development (c) (240) 447-5974 | Tyson's Corner, VA (g) CC28 8136 C253 907A B9BB 9EEA D3C8 1A3A 790A 0AB9
Thanks, @ajacocks ! I'll take a look at this approach. thanks.