Tags in loop

4 views
Skip to first unread message

Rafael Tomelin

unread,
Jan 29, 2019, 7:25:58 AM1/29/19
to ansible...@googlegroups.com
Hi dear,

I need create tag in my role, this example:

vars/main.yml
name_variable:
tags:
key1: value1
key2: value2

in tasks
taks/main.yml

- name: name my task
user: name
tags:
tags from vars


how can create this tags?


--
Atenciosamente,

Rafael Tomelin
Tel.: 51-84104084
Skype: rafael.tomelin

LPI ID: LPI000191271

Karl Auer

unread,
Jan 29, 2019, 4:37:01 PM1/29/19
to ansible-project
What kind of tag? Do you mean an ansible tag, or a tag for e.g. Amazon resources?

If you mean Ansible tags, I do not know.

If you mean AWS tags, most resource modules provide a "tags" attribute, if the resource supports tags. Some resources (generally those with IDs) can be tagged using the ec2_tag module.

Regards, 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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAGEUqbBU%2BN0Byj2aLUDLRwCPgLcYN8X%2BA9yMTns4F5QL0okezQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


--
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com


GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

Rafael Tomelin

unread,
Jan 29, 2019, 6:27:36 PM1/29/19
to ansible...@googlegroups.com
Hi,

This tag in ansible. I need set key and value (- key: value), but in variable.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08S%3DyOXkTpApiE1om%3D8DcpnT%2Bp8673ZyQshSqeoTAd%2B8iQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--

Karl Auer

unread,
Jan 29, 2019, 6:44:49 PM1/29/19
to ansible-project
Great! Then I just told you how to do it.

vars:
   mytags:
      fred: frederick
      rod: roderick

- module_whatever:
     [...]
     tags: "{{ mytags }}"
     [...]

Or if you have the IDs of the resources you want to tag, use the ec2_tag module.

Regards, K.



For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages