configure_cobbler.yml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 pod -l app=cobbler
  22. changed_when: false
  23. tags: install
  24. - name: Get cobbler pod name
  25. command: 'kubectl get pod -n cobbler -l app=cobbler -o jsonpath="{.items[0].metadata.name}"'
  26. changed_when: false
  27. register: cobbler_pod_name
  28. tags: install
  29. - name: Configuring cobbler inside container (It may take 5-10 mins)
  30. command: "kubectl exec --stdin --tty -n cobbler {{ cobbler_pod_name.stdout }} -- ansible-playbook /root/cobbler_configurations.yml"
  31. changed_when: true
  32. tags: install
  33. when: not cobbler_config_status
  34. - name: Schedule task
  35. cron:
  36. name: "start cobbler on reboot"
  37. special_time: reboot
  38. job: "ansible-playbook {{ role_path }}/files/start_cobbler.yml"
  39. tags: install
  40. when: not cobbler_config_status
  41. - name: Execute cobbler sync in cobbler container
  42. command: 'kubectl exec --stdin --tty -n cobbler {{ cobbler_pod_name.stdout }} -- cobbler sync'
  43. changed_when: true
  44. when: cobbler_config_status
  45. - name: Remove the files
  46. file:
  47. path: "{{ item }}"
  48. state: absent
  49. with_items:
  50. - "{{ role_path }}/files/.users.digest"
  51. - "{{ role_path }}/files/dhcp.template"
  52. - "{{ role_path }}/files/settings"
  53. - "{{ role_path }}/files/centos7.ks"
  54. - "{{ role_path }}/files/temp_host_mapping_file.csv.bak"