cobbler_configurations.yml 4.3 KB

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