# instance\_tags format

**URL:** <https://forum.ansible.com/t/instance-tags-format/12339>\
**Category:** Ansible Project\
**Created:** [February 11, 2013, 4:22pm UTC](https://forum.ansible.com/t/instance-tags-format/12339 "2013-02-11T16:22:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Filip\_Slunecko](https://avatars.discourse-cdn.com/v4/letter/f/58956e/32.png) [@Filip\_Slunecko](https://forum.ansible.com/u/Filip_Slunecko)\
**Post date:** [February 11, 2013, 4:22pm UTC](https://forum.ansible.com/t/instance-tags-format/12339/1 "2013-02-11T16:22:59Z")

</div>

Hi,

I am trying to use instance\_tags from ec2 module and I am not able to figure out the right syntaxe.

I tried:

ec2\_instance\_tags: ‘{“Name”: “test”}’  
ec2\_instance\_tags:  
Name: test

and still no luck to find right format for:

a hash/dictionary of tags, in quoted json format, to add to the new instance

Thanks

Filip

---

<div class="post-metadata">

**Author:** ![Lester\_Wade](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@Lester\_Wade](https://forum.ansible.com/u/Lester_Wade)\
**Post date:** [February 11, 2013, 5:35pm UTC](https://forum.ansible.com/t/instance-tags-format/12339/2 "2013-02-11T17:35:48Z")

</div>

Hi Filip,

Like this:

instance\_tags=‘{“my”:“stuff”}’

It looks like your space is the issue ": " - we should fix that.

---

<div class="post-metadata">

**Author:** ![Filip\_Slunecko](https://avatars.discourse-cdn.com/v4/letter/f/58956e/32.png) [@Filip\_Slunecko](https://forum.ansible.com/u/Filip_Slunecko)\
**Post date:** [February 11, 2013, 6:08pm UTC](https://forum.ansible.com/t/instance-tags-format/12339/3 "2013-02-11T18:08:28Z")

</div>

Thanks!

Problem was with the space.

This one doesn’t work (space between ‘: "’):  
instance\_tags=‘{“my”: “stuff”}’

This one work  
instance\_tags=‘{“my”:“stuff”}’

I think it’s kind of confusing. For json dump in console: space is ok

n [3]: json.dumps({“Name”: “test”})  
Out[3]: ‘{“Name”: “test”}’

Filip

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 11, 2013, 6:14pm UTC](https://forum.ansible.com/t/instance-tags-format/12339/4 "2013-02-11T18:14:42Z")

</div>

We were thinking \*possibly\* the module could 'fix' spaces for you, but  
maybe there is a better easier syntax we could use instead.

instance\_tags='key=value,key=value,key=value'

would technically work with shlex, wouldn't it?

Do tags ever need to have nested datastructures?

---

<div class="post-metadata">

**Author:** ![Lester\_Wade](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@Lester\_Wade](https://forum.ansible.com/u/Lester_Wade)\
**Post date:** [February 11, 2013, 6:17pm UTC](https://forum.ansible.com/t/instance-tags-format/12339/5 "2013-02-11T18:17:17Z")

</div>

That would be much more user friendly. Correct, tags are never nested, it’s always key=value.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 11, 2013, 6:23pm UTC](https://forum.ansible.com/t/instance-tags-format/12339/6 "2013-02-11T18:23:39Z")

</div>

> That would be much more user friendly. Correct, tags are never nested, it's  
> always key=value.

I tend to feel few people are passing instance tags now, so I'm ok  
with changing it work that way if you are?

We could possibly also look for a "{" and if so do it it the old way,  
but that's up to you.

---

<div class="post-metadata">

**Author:** ![Lester\_Wade](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@Lester\_Wade](https://forum.ansible.com/u/Lester_Wade)\
**Post date:** [February 12, 2013, 8:55am UTC](https://forum.ansible.com/t/instance-tags-format/12339/7 "2013-02-12T08:55:40Z")

</div>

Yup, I think changing it to this format is fine.
