kickstart.yml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. changed_when: true
  56. - name: Run import command
  57. command: cobbler import --arch=x86_64 --path=/mnt --name="{{ name_iso }}"
  58. changed_when: false
  59. - name: Distro list
  60. 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
  61. changed_when: false
  62. - name: Kickstart profile
  63. command: cobbler profile edit --name="{{ distro_name }}" --kickstart=/var/lib/cobbler/kickstarts/centos7.ks
  64. changed_when: false
  65. - name: Syncing of cobbler
  66. command: cobbler sync
  67. changed_when: false
  68. - name: Restart cobbler
  69. service:
  70. name: cobblerd
  71. state: restarted
  72. - name: Restart xinetd
  73. service:
  74. name: xinetd
  75. state: restarted
  76. - name: Restart dhcpd
  77. service:
  78. name: dhcpd
  79. state: restarted
  80. - name: Add tftp cron job
  81. cron:
  82. name: Start tftp service
  83. minute: "*"
  84. job: "ansible-playbook /root/tftp.yml"
  85. - name: Add inventory cron job
  86. cron:
  87. name: Create inventory
  88. minute: "*/5"
  89. job: "ansible-playbook /root/inventory_creation.yml"