kickstart.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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: Cobbler get-loaders
  37. command: cobbler get-loaders
  38. changed_when: false
  39. - name: Get fence agents
  40. package:
  41. name: fence-agents
  42. state: present
  43. - name: Replace in /etc/debian
  44. replace:
  45. path: "/etc/debmirror.conf"
  46. regexp: "^@dists=\"sid\";"
  47. replace: "#@dists=\"sid\";"
  48. - name: Replace in /etc/debian
  49. replace:
  50. path: "/etc/debmirror.conf"
  51. regexp: "^@arches=\"i386\";"
  52. replace: "#@arches=\"i386\";"
  53. - name: Adding curl
  54. shell: export PATH="/usr/bin/curl:$PATH"
  55. - name: Run import command
  56. command: cobbler import --arch=x86_64 --path=/mnt --name="{{ name_iso }}"
  57. changed_when: false
  58. - name: Distro list
  59. 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
  60. changed_when: false
  61. - name: Kickstart profile
  62. command: cobbler profile edit --name="{{ distro_name }}" --kickstart=/var/lib/cobbler/kickstarts/centos7.ks
  63. changed_when: false
  64. - name: Syncing of cobbler
  65. command: cobbler sync
  66. changed_when: false
  67. - name: Disable default apache webpage
  68. blockinfile:
  69. state: present
  70. insertafter: '^#insert the content here for disabling the default apache webpage'
  71. dest: /etc/httpd/conf/httpd.conf
  72. block: |
  73. <Directory />
  74. Order Deny,Allow
  75. Deny from all
  76. Options None
  77. AllowOverride None
  78. </Directory>
  79. - name: Restart cobbler
  80. service:
  81. name: cobblerd
  82. state: restarted
  83. - name: Restart httpdd
  84. service:
  85. name: httpd
  86. state: restarted
  87. - name: Restart xinetd
  88. service:
  89. name: xinetd
  90. state: restarted
  91. - name: Restart dhcpd
  92. service:
  93. name: dhcpd
  94. state: restarted
  95. - name: Add tftp cron job
  96. cron:
  97. name: Start tftp service
  98. minute: "*"
  99. job: "ansible-playbook /root/tftp.yml"
  100. - name: Add inventory cron job
  101. cron:
  102. name: Create inventory
  103. minute: "*/5"
  104. job: "ansible-playbook /root/inventory_creation.yml"