cobbler_configurations.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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: Syncing of cobbler
  95. command: cobbler sync
  96. changed_when: false
  97. - name: Restart cobbler
  98. service:
  99. name: cobblerd
  100. state: restarted
  101. - name: Restart httpdd
  102. service:
  103. name: httpd
  104. state: restarted
  105. - name: Restart xinetd
  106. service:
  107. name: xinetd
  108. state: restarted
  109. - name: Restart dhcpd
  110. service:
  111. name: dhcpd
  112. state: restarted
  113. - name: Fetch ansible-playbook path
  114. command: whereis ansible-playbook
  115. changed_when: false
  116. register: ansible_playbook_path
  117. - name: Add tftp cron job
  118. cron:
  119. name: Start tftp service
  120. minute: "*"
  121. job: "{{ ansible_playbook_path.stdout.split(' ')[1] }} /root/tftp.yml"
  122. - name: Add inventory cron job
  123. cron:
  124. name: Create inventory
  125. minute: "*/5"
  126. job: "{{ ansible_playbook_path.stdout.split(' ')[1] }} /root/inventory_creation.yml"