Hi,
Sorry for a bit of a noobish question, but I am provisioning some instances
in ec2, and I can successfully create and tag the instances in my
*provision* playbook.
However, later I try and add a tag to exiting hosts based on a tag_Name,
but I cannot seem to get the resource-id's I need for ec2_tag.
Example
---
- name: tag something
vars:
tag_name: ami_test
hosts: "tag_Name_{{tag_name}}"
user: admin
tasks:
- name: Add tag to instances
local_action: ec2_tag resource="{{item.id}}" region="{{aws_region}}"
state=present
with_items: ec2.instances
args:
tags:
Name: "{{tag_name}}"
So when I run this with:
bash-3.2$ ansible-playbook tag.yml -e tag_name=dev_test
PLAY [tag something] ******************************************************
GATHERING FACTS
***************************************************************
ok: [52.28.9.65]
TASK: [Add tag to instances]
**************************************************
fatal: [52.28.9.65 -> 127.0.0.1] => One or more undefined variables:
'unicode object' has no attribute 'id'
FATAL: all hosts have already failed -- aborting
PLAY RECAP
********************************************************************
to retry, use: --limit @/Users/keghol/tag.retry
52.28.9.65 : ok=1 changed=0 unreachable=1 failed=0
I think the problem is that I don't understand how register works, or how
to get my instance-id's. And I am pretty sure with_items: ec2.instasnces
will freak out next.
Thanks in advance.
/K
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/c26188a8-6dc8-42a8-9756-bdbd16743f0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.