daily pastebin goal
36%
SHARE
TWEET

Untitled

a guest Jul 11th, 2018 237 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Given playbook.yml
  2.  
  3. - name: PLAY 1 | Group VMWare Guests by guestfamily
  4.   hosts: all
  5.   gather_facts: false
  6.   tags: [ group_hosts ]
  7.   tasks:
  8.   - group_by:
  9.       key: >-
  10.         {%- if hostvars[inventory_hostname].guest.guestfamily == 'linuxGuest' -%}
  11.         Linux
  12.         {%- elif hostvars[inventory_hostname].guest.guestfamily == 'windowsGuest' -%}
  13.         Windows
  14.         {%- else -%}
  15.         Unknown
  16.         {%- endif %}
  17.  
  18. - name: PLAY 2 | Connect to Linux hosts
  19.   hosts: Linux
  20.   tags: [ linux_hosts ]
  21.   gather_facts: false
  22.   vars:
  23.     - ansible_user: "ansible"
  24.     - ansible_password: "password"
  25.   tasks:
  26.     - ping:
  27. - name: PLAY 3 | Connect to Windows Hosts
  28.   hosts: Windows
  29.   tags: [ windows_hosts ]
  30.   gather_facts: false
  31.   vars:
  32.     - ansible_user: "Administrator"
  33.     - ansible_password: "password"
  34.     - ansible_connection: "winrm"
  35.     - ansible_winrm_transport: "basic"
  36.     - ansible_winrm_server_cert_validation: "ignore"
  37.   tasks:
  38.     - win_ping:
  39. # Given playbook invocation 1
  40.  
  41. ansible-playbook -i vmware_inventory.py playbook.yml
  42.  
  43. # Resulting PLAY RECAP 1
  44.  
  45. - Linux and Windows hosts reachability, "ok", "changed", and "failed"
  46.   are as expected
  47. - Unkown group's hosts appear in play recap with "ok"=1
  48.   even though they were involved in play 2 or 3
  49.  
  50. # Given playbook invocation 2
  51.  
  52. ansible-playbook -i vmware_inventory.py playbook.yml --tags "group_hosts,linux_hosts"
  53.  
  54. # Resulting PLAY RECAP 2
  55.  
  56. - Linux hosts reachability, "ok", "changed", and "failed" are as expected
  57. - Unknown and Windows hosts show up in play recap with "ok=1"
  58.   even though no "real plays" were ran against them
  59.  
  60. QUESTION 1: Is there a way to suppress a specific play's hosts from showing up
  61. in the Play recap?  In the above playbook, I'd like to suppress PLAY 1 from
  62. showing up in PLAY RECAP because it is only grouping hosts for the subsequent
  63. plays to work against.
  64.  
  65. QUESTION 2: Is there a better way to accomplish what I'm trying to do given I'll
  66. be running "playbook.yml" against both VMWare and Azure dynamic inventory scripts?
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top