configure_cobbler.yml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 dhcpd.leases from cobbler
  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: not cobbler_config_status
  41. - name: Schedule task
  42. cron:
  43. name: "start cobbler on reboot"
  44. special_time: reboot
  45. job: "ansible-playbook {{ role_path }}/files/start_cobbler.yml"
  46. tags: install
  47. when: not cobbler_config_status
  48. - name: Execute cobbler sync in cobbler container
  49. command: 'kubectl exec --stdin --tty -n {{ cobbler_namespace }} {{ cobbler_pod_name.stdout }} -- cobbler sync'
  50. changed_when: true
  51. when: cobbler_config_status
  52. - name: Remove the files
  53. file:
  54. path: "{{ item }}"
  55. state: absent
  56. with_items:
  57. - "{{ role_path }}/files/.users.digest"
  58. - "{{ role_path }}/files/dhcp.template"
  59. - "{{ role_path }}/files/settings"
  60. - "{{ role_path }}/files/{{ cobbler_kickstart_file }}"
  61. - "{{ role_path }}/files/temp_host_mapping_file.csv.bak"