cobbler_configurations_leap.yml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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: Inside cobbler container
  21. debug:
  22. msg: "Hiii! I am cobbler"
  23. - name: Make
  24. command: make rpms
  25. args:
  26. chdir: /cobbler
  27. changed_when: false
  28. - name: Install cobbler and cobbler-web
  29. command: zypper in -y --allow-unsigned-rpm cobbler-3.2.2-1.noarch.rpm cobbler-web-3.2.2-1.noarch.rpm
  30. args:
  31. chdir: /cobbler/rpm-build
  32. changed_when: false
  33. - name: Run script
  34. shell: sh ./mkgrub.sh
  35. args:
  36. chdir: /usr/share/cobbler/bin
  37. changed_when: false
  38. - name: Add settings to http
  39. shell: echo "LoadModule wsgi_module modules/mod_wsgi_python3.so" >/etc/apache2/conf.d/wsgi.conf
  40. changed_when: false
  41. - name: Change http port to 8000
  42. replace:
  43. path: "/etc/apache2/listen.conf"
  44. regexp: '^Listen 80'
  45. replace: 'Listen 8000'
  46. changed_when: false
  47. - name: Change https port to 8008
  48. replace:
  49. path: "/etc/apache2/listen.conf"
  50. regexp: '^\s.*Listen 443'
  51. replace: ' Listen 8008'
  52. changed_when: false
  53. - name: Change http port to 8000
  54. replace:
  55. path: "/etc/apache2/vhosts.d/cobbler.conf"
  56. regexp: '^<VirtualHost.*'
  57. replace: '<VirtualHost *:8000>'
  58. changed_when: false
  59. - name: Add interface to the /etc/sysconfig/dhcpd
  60. replace:
  61. path: "/etc/sysconfig/dhcpd"
  62. regexp: "^DHCPD_INTERFACE=\"\""
  63. replace: "DHCPD_INTERFACE={{ host_network_nic }}"
  64. - name: Enable cobbler
  65. command: systemctl enable {{ item }}
  66. with_items:
  67. - cobblerd
  68. - tftp
  69. - apache2
  70. changed_when: false
  71. - name: Restart httpd
  72. service:
  73. name: "{{ item }}"
  74. state: restarted
  75. loop:
  76. - apache2
  77. - cobblerd
  78. - name: Start services
  79. service:
  80. name: "{{ item }}"
  81. state: started
  82. loop:
  83. - cobblerd
  84. - tftp
  85. - name: Adding curl
  86. shell: export PATH="/usr/bin/curl:$PATH"
  87. - name: Run import command
  88. command: cobbler import --arch=x86_64 --path=/mnt/{{ provision_os }} --name="{{ provision_os }}"
  89. changed_when: false
  90. - name: Kickstart profile - centos
  91. copy:
  92. src: "/root/omnia/control_plane/roles/provision_cobbler/files/centos7.ks"
  93. dest: "/var/lib/cobbler/templates/sample.ks"
  94. mode: "{{ file_perm }}"
  95. tags: install
  96. when: provision_os == "centos"
  97. - name: Kickstart profile - rocky
  98. copy:
  99. src: "/root/omnia/control_plane/roles/provision_cobbler/files/rocky8.ks"
  100. dest: "/var/lib/cobbler/templates/sample.ks"
  101. mode: "{{ file_perm }}"
  102. tags: install
  103. when: provision_os == "rocky"
  104. - name: Kickstart profile - leap
  105. copy:
  106. src: "/root/omnia/control_plane/roles/provision_cobbler/files/leap15.xml"
  107. dest: "/var/lib/cobbler/templates/sample_autoyast.xml"
  108. mode: "{{ file_perm }}"
  109. tags: install
  110. when: provision_os == "leap"
  111. - name: Pxe menu
  112. copy:
  113. src: "/root/omnia/control_plane/roles/provision_cobbler/files/menu.yml"
  114. dest: "/etc/cobbler/boot_loader_conf/pxedefault.template"
  115. mode: "{{ file_perm }}"
  116. tags: install
  117. - name: Assign default grub option
  118. replace:
  119. path: "/var/lib/cobbler/grub_config/grub/grub.cfg"
  120. regexp: "^set default='local'"
  121. replace: "set default='1'"
  122. tags: install
  123. - name: Assign default grub timeout
  124. replace:
  125. path: "/var/lib/cobbler/grub_config/grub/grub.cfg"
  126. regexp: '^set timeout=80'
  127. replace: 'set timeout=10'
  128. tags: install
  129. - name: Syncing of cobbler
  130. command: cobbler sync
  131. changed_when: false
  132. - name: Restart cobblerd, http, xinetd and dhcpd
  133. service:
  134. name: "{{ item }}"
  135. state: restarted
  136. loop:
  137. - cobblerd
  138. - apache2
  139. - xinetd
  140. - dhcpd
  141. - name: Fetch ansible-playbook path
  142. command: whereis ansible-playbook
  143. changed_when: false
  144. register: ansible_playbook_path
  145. - name: Add tftp cron job
  146. cron:
  147. name: Start tftp service
  148. minute: "*"
  149. job: "{{ ansible_playbook_path.stdout.split(' ')[1] }} /root/tftp.yml"
  150. - name: Add inventory cron job
  151. cron:
  152. name: Create inventory
  153. minute: "*/5"
  154. job: "{{ ansible_playbook_path.stdout.split(' ')[1] }} /root/inventory_creation.yml"