configure_cobbler.yml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # Copyright 2021 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: cobbler_container_status and not cobbler_config_status
  20. - name: Wait for cobbler pod to come to ready state
  21. command: kubectl wait --for=condition=ready -n {{ cobbler_namespace }} pod -l app=cobbler
  22. changed_when: false
  23. tags: install
  24. - name: Get cobbler pod name
  25. command: 'kubectl get pod -n {{ cobbler_namespace }} -l app=cobbler -o jsonpath="{.items[0].metadata.name}"'
  26. changed_when: false
  27. register: cobbler_pod_name
  28. tags: install
  29. - name: Wait for 30 seconds to get cobbler pod ready
  30. wait_for:
  31. timeout: 30
  32. - name: Copy kickstart file inside cobbler container
  33. command: kubectl cp {{ role_path }}/files/{{ cobbler_kickstart_file }} {{ cobbler_pod_name.stdout }}:/root/{{ cobbler_kickstart_file }} -n {{ cobbler_namespace }}
  34. changed_when: true
  35. when: not cobbler_config_status
  36. - name: Configuring cobbler inside container (It may take 5-10 mins)
  37. command: "kubectl exec --stdin --tty -n {{ cobbler_namespace }} {{ cobbler_pod_name.stdout }} -- ansible-playbook /root/cobbler_configurations.yml -e name_iso={{ provision_os }}"
  38. changed_when: true
  39. tags: install
  40. when:
  41. - not cobbler_config_status
  42. - provision_os != os_supported_leap
  43. - name: Configuring cobbler inside container (It may take 5-10 mins)
  44. command: "kubectl exec --stdin --tty -n {{ cobbler_namespace }} {{ cobbler_pod_name.stdout }} -- ansible-playbook /root/cobbler_configurations_leap.yml -e name_iso={{ provision_os }} -e host_network_nic={{ host_network_nic }}"
  45. changed_when: true
  46. tags: install
  47. when:
  48. - not cobbler_config_status
  49. - provision_os == os_supported_leap
  50. - name: Schedule task
  51. cron:
  52. name: "start cobbler on reboot"
  53. special_time: reboot
  54. job: "ansible-playbook {{ role_path }}/files/start_cobbler.yml"
  55. tags: install
  56. when: not cobbler_config_status
  57. - name: Execute cobbler sync in cobbler container
  58. command: 'kubectl exec --stdin --tty -n {{ cobbler_namespace }} {{ cobbler_pod_name.stdout }} -- cobbler sync'
  59. changed_when: true
  60. when: cobbler_config_status
  61. - name: Remove the files
  62. file:
  63. path: "{{ item }}"
  64. state: absent
  65. with_items:
  66. - "{{ role_path }}/files/.users.digest"
  67. - "{{ role_path }}/files/dhcp.template"
  68. - "{{ role_path }}/files/settings"
  69. - "{{ role_path }}/files/{{ cobbler_kickstart_file }}"
  70. - "{{ role_path }}/files/temp_host_mapping_file.csv.bak"