This may be a bug at some level.  But looks like, from my testing, that this is 
fixed by using something like:

    - name: splittest
      set_fact:
        ldap_domain_split: "{{ ldap_base_dn.split('.') }}”

when you do a single line set_fact:

    - name: splittest
      set_fact: ldap_domain_split="{{ldap_base_dn.split(".")}}”

…something doesn’t convey.
-- 
Matt Martz
[email protected]

On December 16, 2013 at 2:52:22 PM, Ross Becker ([email protected]) wrote:

So, I've found another hiccup with lists.  I'm trying to set a value through a 
python "split" call, and then access the individual pieces.  I've verified that 
set_fact does in fact, set a list, because I can use the result for with_items, 
and it correctly picks up the individual values, but syntax which works for 
accessing array elements for a list set as a var, does not work for accessing 
the array elements when set via set_fact and python split.  Here's a small 
playbook which demonstrates the issue:


- hosts: configurator
  user: root
  gather_facts: False

  vars:
    some_list: [ "foo", "bar", "baz" ]
    ldap_base_dn: "jrbhome.net"

  tasks:
    - name: splittest
      set_fact: ldap_domain_split="{{ldap_base_dn.split(".")}}"

    - name: retrievetest
      debug: msg="Item access {{ some_list[0] }}"

    - name: retrievetest
      debug: msg="Domain part 1 {{ ldap_domain_split[0] }}"

    - name: retrieveloop
      debug: msg="Domain part  {{item}}"
      with_items: ldap_domain_split




The first debug statement works perfectly, shows 'foo' for the value.  The 
with_items loop works correctly, but the value which comes back from 
"retrievetest" is '['.  I think it's setting the fact to a string, and 
accessing characters of the string, rather than correctly picking up that this 
is an array.... but it's very odd that with_items works in that case.


--
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].
For more options, visit https://groups.google.com/groups/opt_out.

-- 
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].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to