main.yml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. # Copyright 2022 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. - name: Perform validations
  16. include_tasks: validations.yml
  17. - name: Fetch omnia_config.yml inputs
  18. include_tasks: fetch_omnia_inputs.yml
  19. - name: Fetch control_plane credentials
  20. include_tasks: fetch_control_plane_credentials.yml
  21. - name: Initialize variables
  22. set_fact:
  23. control_plane_status: false
  24. powervault_status: false
  25. nfs_node_status: false
  26. ansible_collection_used: false
  27. - name: Check AWX instance
  28. command: awx --version
  29. changed_when: false
  30. failed_when: false
  31. register: awx_version_check
  32. - name: Check AWX hostname
  33. command: hostname
  34. changed_when: false
  35. register: awx_hostname
  36. - name: Set control_plane_status
  37. set_fact:
  38. control_plane_status: true
  39. when:
  40. - not awx_version_check.failed
  41. - awx_search_key in awx_hostname.stdout
  42. - name: Install Packages
  43. include_tasks: install_packages.yml
  44. when: not control_plane_status
  45. - name: Set NFS node status
  46. set_fact:
  47. nfs_node_status: true
  48. when:
  49. - control_plane_status
  50. - groups['nfs_node'] | length == 1
  51. - name: Fetch powervault status
  52. include_tasks: fetch_powervault_status.yml
  53. when: nfs_node_status
  54. - name: omnia.yml runing on host
  55. block:
  56. - name: Passwordless SSH status
  57. debug:
  58. msg: "omnia.yml running on host"
  59. - name: Check whether ansible config file exists
  60. stat:
  61. path: "{{ ansible_conf_file_path }}/ansible.cfg"
  62. register: ansible_conf_exists
  63. - name: Create the directory if it does not exist
  64. file:
  65. path: "{{ ansible_conf_file_path }}"
  66. state: directory
  67. mode: "{{ file_perm }}"
  68. when: not ansible_conf_exists.stat.exists
  69. - name: Create ansible config file if it does not exist
  70. copy:
  71. dest: "{{ ansible_conf_file_path }}/ansible.cfg"
  72. mode: "{{ file_perm }}"
  73. content: |
  74. [defaults]
  75. log_path = /var/log/omnia.log
  76. when: not ansible_conf_exists.stat.exists
  77. - name: Set omnia.log file
  78. replace:
  79. path: "{{ ansible_conf_file_path }}/ansible.cfg"
  80. regexp: '#log_path = /var/log/ansible.log'
  81. replace: 'log_path = /var/log/omnia.log'
  82. when: ansible_conf_exists.stat.exists
  83. when: not control_plane_status