You are a lifesaver. Thank you so much! This gives me a fantastic place to 
start.

From: 'Rowe, Walter P. (Fed)' via Ansible Project 
<[email protected]>
Date: Thursday, August 18, 2022 at 10:51 AM
To: [email protected] <[email protected]>
Subject: {EXTERNAL} Re: [ansible-project] Dynamic/complex inventory - Specific 
reboot order
CAUTION! This email originated from outside of our organization. DO NOT CLICK 
links or open attachments unless you recognize the sender and know the content 
is safe.
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 a topic in the Google 
Groups "Ansible Project" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/ansible-project/YPr7kdsA1es/unsubscribe<https://urldefense.com/v3/__https:/groups.google.com/d/topic/ansible-project/YPr7kdsA1es/unsubscribe__;!!LgPfcEISpGU!vf4K-01IHZk4WwZsP12iTshVBqefPTzK67vcbWu1sEECflycj4sQPxvs2jBW-Km_p6H_AQ$>.
To unsubscribe from this group and all its topics, send an email to 
[email protected]<mailto:[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<https://urldefense.com/v3/__https:/groups.google.com/d/msgid/ansible-project/237D07ED-81AF-4AD4-A3E7-90D7958BF0B9*40nist.gov?utm_medium=email&utm_source=footer__;JQ!!LgPfcEISpGU!vf4K-01IHZk4WwZsP12iTshVBqefPTzK67vcbWu1sEECflycj4sQPxvs2jBW-KnghlynWA$>.

-- 
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/BN7PR02MB52040DD95F7F99A1BDD6FF329E6D9%40BN7PR02MB5204.namprd02.prod.outlook.com.

Reply via email to