I managed to generate the compressed list in a single task ...

+++

---
- name: read yaml vars into dictionary
  hosts: localhost
  become: no
  gather_facts: no
  vars:
    server_groups: "{{ lookup('file','./' + customer_name + '.yml') | from_yaml 
}}"
    server_order: []
  tasks:
    - set_fact:
        server_order: "{{ server_order + this_server }}"
      with_together:
        - "{{ server_groups.keys() | list }}"
        - "{{ server_groups | dict2items | map(attribute='value') }}"
      vars:
        this_server: [ { name: "{{ item.0 }}", halt: "{{ item.1.down_group }}", 
boot: "{{ item.1.up_group }}", excl: "{{ item.1.exclude }}" } ]

    - name: Shutting down servers
      debug: msg="Shutting down server {{ item.name }}."
      loop: "{{ server_order | json_query('[?excl==`false`]') | 
sort(attribute='halt') }}"

    - name: Starting up servers
      debug: msg="Starting up server {{ item.name }}."
      loop: "{{ server_order | json_query('[?excl==`false`]') | 
sort(attribute='boot') }}"

+++

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/237D07ED-81AF-4AD4-A3E7-90D7958BF0B9%40nist.gov.

Reply via email to