configure_cobbler.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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: Deploy cobbler pod
  16. command: "kubectl apply -f {{ role_path }}/files/k8s_cobbler.yml"
  17. changed_when: true
  18. tags: install
  19. when:
  20. - cobbler_container_status
  21. - not cobbler_config_status
  22. - not provision_os_change
  23. - name: Wait for cobbler pod to come to ready state
  24. command: kubectl wait --for=condition=ready -n {{ cobbler_namespace }} pod -l app=cobbler
  25. changed_when: false
  26. tags: install
  27. - name: Get cobbler pod name
  28. command: 'kubectl get pod -n {{ cobbler_namespace }} -l app=cobbler -o jsonpath="{.items[0].metadata.name}"'
  29. changed_when: false
  30. register: cobbler_pod_name
  31. tags: install
  32. - name: Wait for 30 seconds to get cobbler pod ready
  33. wait_for:
  34. timeout: 30
  35. - name: Copy kickstart file inside cobbler container
  36. command: kubectl cp {{ role_path }}/files/{{ cobbler_kickstart_file }} {{ cobbler_pod_name.stdout }}:/root/{{ cobbler_kickstart_file }} -n {{ cobbler_namespace }}
  37. changed_when: true
  38. when: not cobbler_config_status
  39. - name: Configuring cobbler inside container (It may take 5-10 mins)
  40. command: "kubectl exec --stdin --tty -n {{ cobbler_namespace }} {{ cobbler_pod_name.stdout }} -- ansible-playbook /root/cobbler_configurations_rocky.yml -e provision_os={{ provision_os }} -e file_perm={{ file_perm }}"
  41. changed_when: true
  42. tags: install
  43. when:
  44. - not cobbler_config_status
  45. - mgmt_os == os_supported_rocky
  46. - not provision_os_change
  47. - name: Configuring cobbler inside container (It may take 5-10 mins)
  48. command: "kubectl exec --stdin --tty -n {{ cobbler_namespace }} {{ cobbler_pod_name.stdout }} -- ansible-playbook /root/cobbler_configurations_leap.yml -e provision_os={{ provision_os }} -e host_network_nic={{ host_network_nic }} -e file_perm={{ file_perm }}"
  49. changed_when: true
  50. tags: install
  51. when:
  52. - not cobbler_config_status
  53. - os_supported_leap in mgmt_os
  54. - not provision_os_change
  55. - name: Configuring cobbler for multiple profile support
  56. command: "kubectl exec --stdin --tty -n {{ cobbler_namespace }} {{ cobbler_pod_name.stdout }} -- ansible-playbook /root/multi_cluster_provisioning.yml -e provision_os={{ provision_os }} -e provision_os_change={{ provision_os_change }} -e file_perm={{ file_perm }}"
  57. changed_when: true
  58. tags: install
  59. when: provision_os_change
  60. - name: Schedule task
  61. cron:
  62. name: "start cobbler on reboot"
  63. special_time: reboot
  64. job: "ansible-playbook {{ role_path }}/files/start_cobbler.yml"
  65. tags: install
  66. when: not cobbler_config_status
  67. - name: Execute cobbler sync in cobbler container
  68. command: 'kubectl exec --stdin --tty -n {{ cobbler_namespace }} {{ cobbler_pod_name.stdout }} -- cobbler sync'
  69. changed_when: true
  70. when: cobbler_config_status
  71. - name: Store the provisioned os in .provisioned_os.txt file
  72. shell: echo "{{ provision_os }}">> {{ role_path }}/files/.provisioned_os
  73. changed_when: false
  74. - name: Remove the files
  75. file:
  76. path: "{{ item }}"
  77. state: absent
  78. with_items:
  79. - "{{ role_path }}/files/.users.digest"
  80. - "{{ role_path }}/files/dhcp.template"
  81. - "{{ role_path }}/files/settings"
  82. - "{{ role_path }}/files/{{ cobbler_kickstart_file }}"
  83. - "{{ role_path }}/files/temp_host_mapping_file.csv.bak"
  84. - "/mnt/tmp"