check_prerequisites.yml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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: Check availability of iso file
  16. stat:
  17. path: "{{ role_path }}/files/{{ iso_name }}"
  18. register: iso_status
  19. tags: install
  20. - name: Iso file not present
  21. fail:
  22. msg: "{{ iso_fail }}"
  23. when: iso_status.stat.exists == false
  24. register: iso_file_check
  25. tags: install
  26. - name: Initialize variables
  27. set_fact:
  28. cobbler_container_status: false
  29. cobbler_image_status: false
  30. cobbler_config_status: false
  31. tags: install
  32. - name: Inspect the cobbler image
  33. docker_image_info:
  34. name: cobbler
  35. register: cobbler_image_result
  36. tags: install
  37. - name: Check cobbler status on the machine
  38. docker_container_info:
  39. name: cobbler
  40. register: cobbler_result
  41. tags: install
  42. - name: Update cobbler image status
  43. set_fact:
  44. cobbler_image_status: true
  45. when: cobbler_image_result.images| length==1
  46. tags: install
  47. - name: Update cobbler container status
  48. set_fact:
  49. cobbler_container_status: true
  50. when: cobbler_result.exists
  51. tags: install
  52. - name: Fetch cobbler profile list
  53. command: docker exec cobbler cobbler profile list
  54. changed_when: false
  55. register: cobbler_profile_list
  56. when: cobbler_container_status == true
  57. - name: Check crontab list
  58. command: docker exec cobbler crontab -l
  59. changed_when: false
  60. register: crontab_list
  61. ignore_errors: true
  62. when: cobbler_container_status == true
  63. - name: Update cobbler container status
  64. set_fact:
  65. cobbler_config_status: true
  66. when:
  67. - cobbler_container_status == true
  68. - "'CentOS' in cobbler_profile_list.stdout"
  69. - "'* * * * * ansible-playbook /root/tftp.yml' in crontab_list.stdout"
  70. - "'5 * * * * ansible-playbook /root/inventory_creation.yml' in crontab_list.stdout"