kickstart.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. # Copyright 2020 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: Start xinetd
  27. service:
  28. name: "{{ item }}"
  29. state: started
  30. loop:
  31. - cobblerd
  32. - xinetd
  33. - rsyncd
  34. - tftp
  35. - httpd
  36. - name: Remove loaders if it exists
  37. command: rm -rfd /var/lib/cobbler/loaders
  38. changed_when: false
  39. - name: Untar loaders
  40. command: tar -xf /root/omnia/appliance/roles/provision/files/loaders.tar -C /var/lib/cobbler
  41. changed_when: false
  42. - name: Replace in /etc/debian
  43. replace:
  44. path: "/etc/debmirror.conf"
  45. regexp: "^@dists=\"sid\";"
  46. replace: "#@dists=\"sid\";"
  47. - name: Replace in /etc/debian
  48. replace:
  49. path: "/etc/debmirror.conf"
  50. regexp: "^@arches=\"i386\";"
  51. replace: "#@arches=\"i386\";"
  52. - name: Adding curl
  53. shell: export PATH="/usr/bin/curl:$PATH"
  54. - name: Run import command
  55. command: cobbler import --arch=x86_64 --path=/mnt --name="{{ name_iso }}"
  56. changed_when: false
  57. - name: Distro list
  58. command: cobbler distro edit --name="{{ distro_name }}" --kernel=/var/www/cobbler/ks_mirror/CentOS7-x86_64/isolinux/vmlinuz --initrd=/var/www/cobbler/ks_mirror/CentOS7-x86_64/isolinux/initrd.img
  59. changed_when: false
  60. - name: Kickstart profile
  61. command: cobbler profile edit --name="{{ distro_name }}" --kickstart=/var/lib/cobbler/kickstarts/centos7.ks
  62. changed_when: false
  63. - name: Syncing of cobbler
  64. command: cobbler sync
  65. changed_when: false
  66. - name: Disable default apache webpage
  67. blockinfile:
  68. state: present
  69. insertafter: '^#insert the content here for disabling the default apache webpage'
  70. dest: /etc/httpd/conf/httpd.conf
  71. block: |
  72. <Directory />
  73. Order Deny,Allow
  74. Deny from all
  75. Options None
  76. AllowOverride None
  77. </Directory>
  78. - name: Restart cobbler
  79. service:
  80. name: cobblerd
  81. state: restarted
  82. - name: Restart httpdd
  83. service:
  84. name: httpd
  85. state: restarted
  86. - name: Restart xinetd
  87. service:
  88. name: xinetd
  89. state: restarted
  90. - name: Restart dhcpd
  91. service:
  92. name: dhcpd
  93. state: restarted
  94. - name: Add tftp cron job
  95. cron:
  96. name: Start tftp service
  97. minute: "*"
  98. job: "ansible-playbook /root/tftp.yml"
  99. - name: Add inventory cron job
  100. cron:
  101. name: Create inventory
  102. minute: "*/5"
  103. job: "ansible-playbook /root/inventory_creation.yml"