compute/ansible.md
... ...
@@ -0,0 +1,14 @@
1
+# Ansible
2
+
3
+Making the easy things easy, and the difficult things damn near impossible.
4
+
5
+### Inventory list merging
6
+Say you need a set of lists from inventory merged into one list. Name the inventory lists X\_my\_list where X is something meaningful, then:
7
+```
8
+- name: "Collect lists"
9
+ vars:
10
+ my_list: []
11
+ ansible.builtin.set_fact:
12
+ my_list: "{{ log_ship_sources | union(lookup('vars', item)) }}"
13
+ loop: "{{ hostvars[inventory_hostname] | select('match','^.*_my_list$') | list }}"
14
+```