Hi everyone,

how to add the value of a variable to a list?

###########################
[...]
  vars:
    ansible_user: whatever
    somelist:
      - root
      - "{{ ansible_user }}"
  tasks:
    - name: "Print complete list"
      debug: msg="{{ somelist }}"

    - name: "Print variable ansible_user"
      debug: msg="Variable ansible_user is set to {{ ansible_user }}"

    - name: "Print single items in list somelist"
      debug: msg="Item is {{ item }}"
      with_items:
        - "{{ somelist }}"
###########################

I get an empty item or None (depending on what I try) in the third
task, even though the ansible_user variable evaluates correctly in the
second and shows up in the first task:

> TASK [Print complete list] 
> *****************************************************
> ok: [localhost] => {
>     "msg": [
>         "root", 
>         "whatever"
>     ]
> }
> 
> TASK [Print variable ansible_user] 
> *********************************************
> ok: [localhost] => {
>     "msg": "Variable ansible_user is set to whatever"
> }
> 
> TASK [Print single items in list somelist] 
> *************************************
> ok: [localhost] => (item=root) => {
>     "item": "root", 
>     "msg": "Item is root"
> }
> ok: [localhost] => (item=None) => {
>     "item": null, 
>     "msg": "Item is "
> }

How to correctly add a string (that's what it should be), stored in a
value, to a list?

Thanks in advance.

Johannes

-- 
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/570E51DF.1040400%40ojkastl.de.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to