Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Given playbook.yml
- - name: PLAY 1 | Group VMWare Guests by guestfamily
- hosts: all
- gather_facts: false
- tags: [ group_hosts ]
- tasks:
- - group_by:
- key: >-
- {%- if hostvars[inventory_hostname].guest.guestfamily == 'linuxGuest' -%}
- Linux
- {%- elif hostvars[inventory_hostname].guest.guestfamily == 'windowsGuest' -%}
- Windows
- {%- else -%}
- Unknown
- {%- endif %}
- - name: PLAY 2 | Connect to Linux hosts
- hosts: Linux
- tags: [ linux_hosts ]
- gather_facts: false
- vars:
- - ansible_user: "ansible"
- - ansible_password: "password"
- tasks:
- - ping:
- - name: PLAY 3 | Connect to Windows Hosts
- hosts: Windows
- tags: [ windows_hosts ]
- gather_facts: false
- vars:
- - ansible_user: "Administrator"
- - ansible_password: "password"
- - ansible_connection: "winrm"
- - ansible_winrm_transport: "basic"
- - ansible_winrm_server_cert_validation: "ignore"
- tasks:
- - win_ping:
- # Given playbook invocation 1
- ansible-playbook -i vmware_inventory.py playbook.yml
- # Resulting PLAY RECAP 1
- - Linux and Windows hosts reachability, "ok", "changed", and "failed"
- are as expected
- - Unkown group's hosts appear in play recap with "ok"=1
- even though they were involved in play 2 or 3
- # Given playbook invocation 2
- ansible-playbook -i vmware_inventory.py playbook.yml --tags "group_hosts,linux_hosts"
- # Resulting PLAY RECAP 2
- - Linux hosts reachability, "ok", "changed", and "failed" are as expected
- - Unknown and Windows hosts show up in play recap with "ok=1"
- even though no "real plays" were ran against them
- QUESTION 1: Is there a way to suppress a specific play's hosts from showing up
- in the Play recap? In the above playbook, I'd like to suppress PLAY 1 from
- showing up in PLAY RECAP because it is only grouping hosts for the subsequent
- plays to work against.
- QUESTION 2: Is there a better way to accomplish what I'm trying to do given I'll
- be running "playbook.yml" against both VMWare and Azure dynamic inventory scripts?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement