cobbler_configurations.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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: 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: dnf install -y cobbler-3.2.2-1.el8.noarch.rpm cobbler-web-3.2.2-1.el8.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 load_wsgi
  39. blockinfile:
  40. state: present
  41. insertbefore: '# LoadModule foo_module modules/mod_foo.so'
  42. dest: /etc/httpd/conf/httpd.conf
  43. block: |
  44. LoadModule wsgi_module modules/mod_wsgi_python3.so
  45. LoadModule proxy_module modules/mod_proxy.so
  46. - name: Cobbler web
  47. blockinfile:
  48. state: present
  49. insertafter: '^<VirtualHost '
  50. path: /etc/httpd/conf.d/cobbler_web.conf
  51. block: |
  52. ServerName localhost
  53. SSLEngine on
  54. SSLCipherSuite PROFILE=SYSTEM
  55. SSLCertificateFile /etc/pki/tls/certs/localhost.crt
  56. SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
  57. - name: Add settings to http
  58. shell: echo "LoadModule wsgi_module modules/mod_wsgi_python3.so" >/etc/httpd/conf.d/wsgi.conf
  59. changed_when: false
  60. - name: Enable cobbler
  61. command: systemctl enable {{ item }}
  62. with_items:
  63. - cobblerd
  64. - tftp
  65. changed_when: false
  66. - name: Restart httpd
  67. service:
  68. name: "{{ item }}"
  69. state: restarted
  70. loop:
  71. - httpd
  72. - cobblerd
  73. - name: Start services
  74. service:
  75. name: "{{ item }}"
  76. state: started
  77. loop:
  78. - cobblerd
  79. - tftp
  80. - name: Adding curl
  81. shell: export PATH="/usr/bin/curl:$PATH"
  82. - name: Run import command
  83. command: cobbler import --arch=x86_64 --path=/mnt --name="{{ name_iso }}"
  84. changed_when: false
  85. - name: Kickstart profile - centos
  86. copy:
  87. src: "/root/centos7.ks"
  88. dest: "/var/lib/cobbler/templates/sample.ks"
  89. mode: 0775
  90. tags: install
  91. when: name_iso == "centos"
  92. - name: Kickstart profile - rocky
  93. copy:
  94. src: "/root/rocky8.ks"
  95. dest: "/var/lib/cobbler/templates/sample.ks"
  96. mode: 0775
  97. tags: install
  98. when: name_iso == "rocky"
  99. - name: Pxe menu
  100. copy:
  101. src: "/root/omnia/control_plane/roles/provision_cobbler/files/menu.yml"
  102. dest: "/etc/cobbler/boot_loader_conf/pxedefault.template"
  103. mode: 0775
  104. tags: install
  105. - name: Assign default grub option
  106. replace:
  107. path: "/var/lib/cobbler/grub_config/grub/grub.cfg"
  108. regexp: "^set default=\'local\'"
  109. replace: "set default=\'1\'"
  110. tags: install
  111. - name: Assign default grub timeout
  112. replace:
  113. path: "/var/lib/cobbler/grub_config/grub/grub.cfg"
  114. regexp: '^set timeout=80'
  115. replace: 'set timeout=10'
  116. tags: install
  117. - name: Syncing of cobbler
  118. command: cobbler sync
  119. changed_when: false
  120. - name: Restart cobblerd, http, xinetd and dhcpd
  121. service:
  122. name: "{{ item }}"
  123. state: restarted
  124. loop:
  125. - cobblerd
  126. - httpd
  127. - xinetd
  128. - dhcpd
  129. - name: Fetch ansible-playbook path
  130. command: whereis ansible-playbook
  131. changed_when: false
  132. register: ansible_playbook_path
  133. - name: Add tftp cron job
  134. cron:
  135. name: Start tftp service
  136. minute: "*"
  137. job: "{{ ansible_playbook_path.stdout.split(' ')[1] }} /root/tftp.yml"
  138. - name: Add inventory cron job
  139. cron:
  140. name: Create inventory
  141. minute: "*/5"
  142. job: "{{ ansible_playbook_path.stdout.split(' ')[1] }} /root/inventory_creation.yml"