cobbler_configurations_rocky.yml 4.8 KB

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