cobbler_configurations.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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: 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: Enable cobbler
  40. command: systemctl enable {{ item }}
  41. with_items:
  42. - cobblerd
  43. - tftp
  44. changed_when: false
  45. - name: Restart httpd
  46. service:
  47. name: "{{ item }}"
  48. state: restarted
  49. loop:
  50. - httpd
  51. - cobblerd
  52. - name: Start services
  53. service:
  54. name: "{{ item }}"
  55. state: started
  56. loop:
  57. - cobblerd
  58. - tftp
  59. - name: Adding curl
  60. shell: export PATH="/usr/bin/curl:$PATH"
  61. changed_when: false
  62. - name: Run import command
  63. command: cobbler import --arch=x86_64 --path=/mnt --name="{{ name_iso }}"
  64. changed_when: false
  65. - name: Kickstart profile - centos
  66. copy:
  67. src: "/root/centos7.ks"
  68. dest: "/var/lib/cobbler/templates/sample.ks"
  69. mode: 0775
  70. tags: install
  71. when: name_iso == "centos"
  72. - name: Kickstart profile - rocky
  73. copy:
  74. src: "/root/rocky8.ks"
  75. dest: "/var/lib/cobbler/templates/sample.ks"
  76. mode: 0775
  77. tags: install
  78. when: name_iso == "rocky"
  79. - name: Pxe menu
  80. copy:
  81. src: "/root/omnia/control_plane/roles/provision_cobbler/files/menu.yml"
  82. dest: "/etc/cobbler/boot_loader_conf/pxedefault.template"
  83. mode: 0775
  84. tags: install
  85. - name: Assign default grub option
  86. replace:
  87. path: "/var/lib/cobbler/grub_config/grub/grub.cfg"
  88. regexp: "^set default=\'local\'"
  89. replace: "set default=\'1\'"
  90. tags: install
  91. - name: Assign default grub timeout
  92. replace:
  93. path: "/var/lib/cobbler/grub_config/grub/grub.cfg"
  94. regexp: '^set timeout=80'
  95. replace: 'set timeout=10'
  96. tags: install
  97. - name: Syncing of cobbler
  98. command: cobbler sync
  99. changed_when: false
  100. - name: Restart cobblerd, http, xinetd and dhcpd
  101. service:
  102. name: "{{ item }}"
  103. state: restarted
  104. loop:
  105. - cobblerd
  106. - httpd
  107. - xinetd
  108. - dhcpd
  109. - name: Fetch ansible-playbook path
  110. command: whereis ansible-playbook
  111. changed_when: false
  112. register: ansible_playbook_path
  113. - name: Add tftp cron job
  114. cron:
  115. name: Start tftp service
  116. minute: "*"
  117. job: "{{ ansible_playbook_path.stdout.split(' ')[1] }} /root/tftp.yml"
  118. - name: Add inventory cron job
  119. cron:
  120. name: Create inventory
  121. minute: "*/5"
  122. job: "{{ ansible_playbook_path.stdout.split(' ')[1] }} /root/inventory_creation.yml"