Hi

I'm seeing some weird behaviour trying to use selectattr() on a list
of dicts, when the attribute name I am using is the literal string
'update'.
Anything else works fine.

Example playbook:


---

- name: Test playbook
  hosts: localhost
  connection: local

  vars:
    repos:
      - src: git+ssh://[email protected]/repo1
        version: v1.0.1

      - src: git+ssh://[email protected]/repo2
        version: v1.1.2

      - src: git+ssh://[email protected]/repo3
        version: v1.9.2

      - src: git+ssh://[email protected]/repo4
        version: v5.7
        update: something

      - src: git+ssh://[email protected]/repo5
        version: v1.4
        update2: something


  tasks:
    - set_fact:
        myrepos1: "{{ repos | selectattr('update2', 'defined') | list }}"
        myrepos2: "{{ repos | selectattr('update', 'defined') | list }}"

    - debug: var=myrepos1
    - debug: var=myrepos2


The output of the debug tasks is:

TASK [debug] 
******************************************************************************************************************************
ok: [localhost] => {
    "myrepos1": [
        {
            "src": "git+ssh://[email protected]/repo5",
            "update2": "something",
            "version": "v1.4"
        }
    ]
}

TASK [debug] 
******************************************************************************************************************************
ok: [localhost] => {
    "myrepos2": [
        {
            "src": "git+ssh://[email protected]/repo1",
            "version": "v1.0.1"
        },
        {
            "src": "git+ssh://[email protected]/repo2",
            "version": "v1.1.2"
        },
        {
            "src": "git+ssh://[email protected]/repo3",
            "version": "v1.9.2"
        },
        {
            "src": "git+ssh://[email protected]/repo4",
            "update": "something",
            "version": "v5.7"
        },
        {
            "src": "git+ssh://[email protected]/repo5",
            "update2": "something",
            "version": "v1.4"
        }
    ]
}



Any clues as to what is going on here...?



-- 
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

-- 
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/CAL8fbwMW2a4LQy1uWEbMQSi19kRUb2BseXOnY10Z%3D1KDkXnazA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to