check_prerequisites.yml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. - name: Check cobbler status on the machine
  44. docker_container_info:
  45. name: cobbler
  46. register: cobbler_result
  47. tags: install
  48. - name: Update cobbler image status
  49. set_fact:
  50. cobbler_image_status: true
  51. when: cobbler_image_result.images| length==1
  52. tags: install
  53. - name: Update cobbler container status
  54. set_fact:
  55. cobbler_container_status: true
  56. when: cobbler_result.exists
  57. tags: install
  58. - name: Fetch cobbler profile list
  59. command: docker exec cobbler cobbler profile list
  60. changed_when: false
  61. register: cobbler_profile_list
  62. ignore_errors: true
  63. when: cobbler_container_status == true
  64. - name: Check crontab list
  65. command: docker exec cobbler crontab -l
  66. changed_when: false
  67. register: crontab_list
  68. ignore_errors: true
  69. when: cobbler_container_status == true
  70. - name: Update cobbler container status
  71. set_fact:
  72. cobbler_config_status: true
  73. when:
  74. - cobbler_container_status == true
  75. - "'CentOS' in cobbler_profile_list.stdout"
  76. - "'* * * * * ansible-playbook /root/tftp.yml' in crontab_list.stdout"
  77. - "'5 * * * * ansible-playbook /root/inventory_creation.yml' in crontab_list.stdout"