check_prerequisites.yml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. - name: Initialize variables
  16. set_fact:
  17. cobbler_container_status: false
  18. cobbler_image_status: false
  19. cobbler_config_status: false
  20. backup_map_status: false
  21. new_node_status: false
  22. tags: install
  23. - name: Check if any backup file exists
  24. block:
  25. - name: Check status of backup file
  26. stat:
  27. path: "{{ role_path }}/files/backup_mapping_file.csv"
  28. register: backup_map
  29. - name: Set status for backup file
  30. set_fact:
  31. backup_map_status: true
  32. when: backup_map.stat.exists == true
  33. rescue:
  34. - name: Message
  35. debug:
  36. msg: "All nodes are new"
  37. verbosity: 2
  38. - name: Inspect the cobbler image
  39. docker_image_info:
  40. name: cobbler
  41. register: cobbler_image_result
  42. tags: install
  43. vars:
  44. ansible_python_interpreter: "/usr/bin/python3"
  45. - name: Check cobbler status on the machine
  46. docker_container_info:
  47. name: cobbler
  48. register: cobbler_result
  49. tags: install
  50. vars:
  51. ansible_python_interpreter: "/usr/bin/python3"
  52. - name: Update cobbler image status
  53. set_fact:
  54. cobbler_image_status: true
  55. when: cobbler_image_result.images| length==1
  56. tags: install
  57. - name: Update cobbler container status
  58. set_fact:
  59. cobbler_container_status: true
  60. when: cobbler_result.exists
  61. tags: install
  62. - name: Fetch cobbler profile list
  63. command: docker exec cobbler cobbler profile list
  64. changed_when: false
  65. register: cobbler_profile_list
  66. ignore_errors: true
  67. when: cobbler_container_status == true
  68. - name: Check crontab list
  69. command: docker exec cobbler crontab -l
  70. changed_when: false
  71. register: crontab_list
  72. ignore_errors: true
  73. when: cobbler_container_status == true
  74. - name: Update cobbler container status
  75. set_fact:
  76. cobbler_config_status: true
  77. when:
  78. - cobbler_container_status == true
  79. - "'CentOS' in cobbler_profile_list.stdout"
  80. - "'* * * * * ansible-playbook /root/tftp.yml' in crontab_list.stdout"
  81. - "'5 * * * * ansible-playbook /root/inventory_creation.yml' in crontab_list.stdout"