I’ve tried pre-defining an empty group and not defining, neither seems to work, the group seems to remain empty when I try to use it, I’m sure I’m missing something vital out.
This is an extract:
- hosts: all-t4
need serial 1 to be able t use add_host more than once
serial: 1
remote_user: XXXX
tasks:
- name: gather ldom info
shell: /usr/sbin/ldm ls -p |awk -F’=’ ‘/active/ {print $2}’ | awk -F’|’ ‘{print $1}’ |grep -v primary | sed -e ‘s/iodomain/{{ inventory_hostname }}-io/’
register: output - name: add ldom to in-mem inventory
add_host:
name: “{{ item }}”
groups: ldoms
with_items: “{{ output.stdout_lines }}” - debug:
msg: “{{ group_names }}”
with_items: “{{ output.stdout_lines }}” - hosts: all
tasks: - debug: var=“{{ group_names }}”