provision_report.yml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. # This file used to generate a report of reachable and unreachable host of hpc cluster
  16. # This file can be executed only if provisioned_hosts.yml is created inside the path omnia/appliance/roles/inventory/files/provisioned_hosts.yml
  17. # Command to execute: ansible-playbook provision_report.yml -i ../roles/inventory/files/provisioned_hosts.yml
  18. - name: Fetch provision_password
  19. hosts: localhost
  20. connection: local
  21. gather_facts: no
  22. roles:
  23. - fetch_password
  24. - name: Find reachable hosts using ping
  25. hosts: all
  26. gather_facts: false
  27. ignore_unreachable: true
  28. ignore_errors: true
  29. tasks:
  30. - name: Check for reachable nodes
  31. command: ping -c1 {{ inventory_hostname }}
  32. delegate_to: localhost
  33. register: ping_result
  34. ignore_errors: yes
  35. changed_when: false
  36. - name: Refresh ssh keys
  37. command: ssh-keygen -R {{ inventory_hostname }}
  38. delegate_to: localhost
  39. changed_when: false
  40. - name: Group reachable hosts
  41. group_by:
  42. key: "reachable"
  43. when: "'100% packet loss' not in ping_result.stdout"
  44. - name: Find reachable hosts using ssh
  45. hosts: reachable
  46. gather_facts: False
  47. ignore_unreachable: true
  48. remote_user: "root"
  49. vars:
  50. ansible_password: "{{ hostvars['127.0.0.1']['cobbler_password'] }}"
  51. ansible_become_pass: "{{ hostvars['127.0.0.1']['cobbler_password'] }}"
  52. ansible_ssh_common_args: '-o StrictHostKeyChecking=no'
  53. tasks:
  54. - name: Check ssh status
  55. command: hostname
  56. register: ssh_status
  57. ignore_errors: yes
  58. - name: Group unreachable ssh hosts
  59. group_by:
  60. key: "unreachable_ssh"
  61. when: ssh_status.unreachable is defined and ssh_status.unreachable == true
  62. - name: Group reachable ssh hosts
  63. group_by:
  64. key: "reachable_ssh"
  65. when: (ssh_status.unreachable is defined and ssh_status.unreachable == false) or (ssh_status.rc is defined and ssh_status.rc == 0)
  66. - name: Display hosts list
  67. hosts: localhost
  68. connection: local
  69. gather_facts: false
  70. roles:
  71. - hpc_cluster_report