cobbler_configurations_leap.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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: zypper in -y --allow-unsigned-rpm cobbler-3.2.2-1.noarch.rpm cobbler-web-3.2.2-1.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 settings to http
  39. shell: echo "LoadModule wsgi_module modules/mod_wsgi_python3.so" >/etc/apache2/conf.d/wsgi.conf
  40. changed_when: false
  41. - name: Add interface to the /etc/sysconfig/dhcpd
  42. replace:
  43. path: "/etc/sysconfig/dhcpd"
  44. regexp: "^DHCPD_INTERFACE=\"\""
  45. replace: "DHCPD_INTERFACE={{ host_network_nic }}"
  46. - name: Enable cobbler
  47. command: systemctl enable {{ item }}
  48. with_items:
  49. - cobblerd
  50. - tftp
  51. changed_when: false
  52. - name: Restart httpd
  53. service:
  54. name: "{{ item }}"
  55. state: restarted
  56. loop:
  57. - apache2
  58. - cobblerd
  59. - name: Start services
  60. service:
  61. name: "{{ item }}"
  62. state: started
  63. loop:
  64. - cobblerd
  65. - tftp
  66. - name: Adding curl
  67. shell: export PATH="/usr/bin/curl:$PATH"
  68. - name: Run import command
  69. command: cobbler import --arch=x86_64 --path=/mnt --name="{{ name_iso }}"
  70. changed_when: false
  71. - name: Kickstart profile - leap
  72. copy:
  73. src: "/root/leap15.xml"
  74. dest: "/var/lib/cobbler/templates/sample_autoyast.xml"
  75. mode: 0775
  76. tags: install
  77. - name: Pxe menu
  78. copy:
  79. src: "/root/omnia/control_plane/roles/provision_cobbler/files/menu.yml"
  80. dest: "/etc/cobbler/boot_loader_conf/pxedefault.template"
  81. mode: 0775
  82. tags: install
  83. - name: Assign default grub option
  84. replace:
  85. path: "/var/lib/cobbler/grub_config/grub/grub.cfg"
  86. regexp: "^set default='local'"
  87. replace: "set default='1'"
  88. tags: install
  89. - name: Assign default grub timeout
  90. replace:
  91. path: "/var/lib/cobbler/grub_config/grub/grub.cfg"
  92. regexp: '^set timeout=80'
  93. replace: 'set timeout=10'
  94. tags: install
  95. - name: Syncing of cobbler
  96. command: cobbler sync
  97. changed_when: false
  98. - name: Restart cobblerd, http, xinetd and dhcpd
  99. service:
  100. name: "{{ item }}"
  101. state: restarted
  102. loop:
  103. - cobblerd
  104. - apache2
  105. - xinetd
  106. - dhcpd
  107. - name: Fetch ansible-playbook path
  108. command: whereis ansible-playbook
  109. changed_when: false
  110. register: ansible_playbook_path
  111. # - name: Set dhcpd_lease_file variable for inventory creation
  112. # cron:
  113. # env: yes
  114. # name: dhcpd_lease_file
  115. # value: "/var/lib/dhcp/db/dhcpd.leases"
  116. # - name: Set provision_os variable for inventory creation
  117. # cron:
  118. # env: yes
  119. # name: provision_os
  120. # value: "{{ name_iso }}"
  121. - name: Add tftp cron job
  122. cron:
  123. name: Start tftp service
  124. minute: "*"
  125. job: "{{ ansible_playbook_path.stdout.split(' ')[1] }} /root/tftp.yml -e provision_os={{ name_iso }}"
  126. - name: Add inventory cron job
  127. cron:
  128. name: Create inventory
  129. minute: "*/5"
  130. job: "{{ ansible_playbook_path.stdout.split(' ')[1] }} /root/inventory_creation.yml -e dhcpd_lease_file=\"/var/lib/dhcp/db/dhcpd.leases\""