Hi Michaël, I've fixed this in the v2 code base, which also suffered from the same problem. We will look at potentially fixing this in any future 1.9.x releases as well.
Thanks! James Cammarata Director, Ansible Core Engineering github: jimi-c On Mon, Mar 30, 2015 at 3:35 AM, Michaël Bitard <[email protected]> wrote: > Hi, > > I tried to construct an array with set_fact and I found this: > http://stackoverflow.com/questions/23507589/is-it-possible-to-set-a-fact-of-an-array-in-ansible > > So I tested: > > tasks: > - set_fact: foo="[ 'one', 'two', 'three' ]" > - debug: var=foo > - set_fact: foo="{{foo}} + [ 'four' ]" > - debug: var=foo > > > and it worked very well. > > But when I try to add a 'with_items': > > tasks: > - set_fact: foo="[ 'one' ]" > - debug: var=foo > - set_fact: foo="{{foo}} + [ '{{item}}' ]" > with_items: [ "two", "three" ] > - debug: var=foo > > It doesn't work, I get: > > "foo": [ > "one", > "three" > ] > > instead of: > "foo": [ > "one", > "two", > "three" > ] > > Whereas this works: > > tasks: > - name: set foo fact to an array > set_fact: foo="[ 'one' ]" > - debug: var=foo > - set_fact: foo="{{foo}} + [ 'two' ]" > - set_fact: foo="{{foo}} + [ 'three' ]" > - debug: var=foo > > But is not suitable for my needs (It just proves that a fact can be > overriden multiple times). > > The behaviour of with_items is not what I expected, is something wrong > with my approach? > > I'm using ansible 1.8.2 on ubuntu 14.04 > > Regards, > Michaël > > -- > 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/ca8f953f-6935-48da-9e4f-e02a6a0f95df%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/ca8f953f-6935-48da-9e4f-e02a6a0f95df%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CAMFyvFgcrXq%3D6723VPkJHpSft67AyZdoJTL0ig28oeDbZy%2BTzQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
