Guest User

Untitled

a guest
Apr 19th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. - name: perform linux SAT
  2. hosts: sat_test_linux_group
  3. gather_facts: False
  4.  
  5. pre_tasks:
  6.  
  7. - name: set ansible_play_hosts start fact
  8. set_fact:
  9. start_ansible_play_hosts: "{{ ansible_play_hosts }}"
  10. delegate_to: localhost
  11. run_once: true
  12.  
  13. tasks:
  14.  
  15. - name: gather facts
  16. setup:
  17.  
  18. - name: set ansible_play_hosts end fact
  19. set_fact:
  20. end_ansible_play_hosts: "{{ ansible_play_hosts }}"
  21.  
  22. post_tasks:
  23.  
  24. - name: set failed hosts fact
  25. set_fact:
  26. failed_hosts: "{{ start_ansible_play_hosts | difference(end_ansible_play_hosts) }}"
  27. delegate_to: localhost
  28. run_once: true
  29.  
  30. - name: debug start_ansible_play_hosts
  31. debug:
  32. var: start_ansible_play_hosts
  33. delegate_to: localhost
  34. run_once: true
  35.  
  36. - name: debug end_ansible_play_hosts
  37. debug:
  38. var: end_ansible_play_hosts
  39. delegate_to: localhost
  40. run_once: true
  41.  
  42. - name: debug failed_hosts
  43. debug:
  44. var: failed_hosts
  45. delegate_to: localhost
  46. run_once: true
  47.  
  48. - name: dummy exit_status
  49. set_fact:
  50. exit_status: { testing: '123' }
  51.  
  52. - name: "check if host is available"
  53. set_fact:
  54. check_fail_hosts: "{{ check_fail_hosts|default([]) + [ { item : 'HOST FATAL ERROR' } ] }}"
  55. check_tasks: "{{ check_tasks|default([]) + [ exit_status | combine( { 'task': 'no task selected' } ) ] }}"
  56. with_items:
  57. - "{{ failed_hosts }}"
  58. run_once: yes
  59.  
  60. - name: debug check_fail_hosts
  61. debug:
  62. var: check_fail_hosts
  63. delegate_to: localhost
  64. run_once: true
  65.  
  66. - name: debug check_tasks
  67. debug:
  68. var: check_tasks
  69. delegate_to: localhost
  70. run_once: true
Add Comment
Please, Sign In to add comment