multi_cluster_provisioning.yml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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: Initial cobbler setup
  16. hosts: localhost
  17. connection: local
  18. gather_facts: false
  19. tasks:
  20. - name: Initialize variables
  21. set_fact:
  22. multi_profile: false
  23. grub_option: 1
  24. - name: Run import command
  25. command: cobbler import --arch=x86_64 --path=/mnt/{{ provision_os }} --name="{{ provision_os }}"
  26. changed_when: false
  27. - name: Kickstart profile - centos
  28. copy:
  29. src: "/root/omnia/control_plane/roles/provision_cobbler/files/centos7.ks"
  30. dest: "/var/lib/cobbler/templates/sample.ks"
  31. mode: "{{ file_perm }}"
  32. tags: install
  33. when: provision_os == "centos"
  34. - name: Kickstart profile - rocky
  35. copy:
  36. src: "/root/omnia/control_plane/roles/provision_cobbler/files/rocky8.ks"
  37. dest: "/var/lib/cobbler/templates/sample.ks"
  38. mode: "{{ file_perm }}"
  39. tags: install
  40. when: provision_os == "rocky"
  41. - name: Kickstart profile - leap
  42. copy:
  43. src: "/root/omnia/control_plane/roles/provision_cobbler/files/leap15.xml"
  44. dest: "/var/lib/cobbler/templates/sample_autoyast.xml"
  45. mode: "{{ file_perm }}"
  46. tags: install
  47. when: provision_os == "leap"
  48. - name: Get the cobbler profile list
  49. command: cobbler profile list
  50. changed_when: false
  51. register: cobbler_profile_list
  52. failed_when: false
  53. - name: Check if cobbler_profile_list has more that one profile
  54. set_fact:
  55. multi_profile: true
  56. when:
  57. - cobbler_profile_list.stdout_lines| length > 1
  58. - name: Check if the provision os is in cobbler_profile_list
  59. set_fact:
  60. grub_option: "{{ index + 1 }}"
  61. when:
  62. - provision_os in item
  63. - multi_profile
  64. loop: "{{ cobbler_profile_list.stdout_lines | flatten(levels=1) }}"
  65. loop_control:
  66. index_var: index
  67. - name: Assign default grub option
  68. replace:
  69. path: "/var/lib/cobbler/grub_config/grub/grub.cfg"
  70. regexp: "^set default=.*"
  71. replace: "set default='{{ grub_option }}'"
  72. tags: install
  73. - name: Syncing of cobbler
  74. command: cobbler sync
  75. changed_when: false