|
@@ -0,0 +1,152 @@
|
|
|
+# Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved.
|
|
|
+#
|
|
|
+# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
+# you may not use this file except in compliance with the License.
|
|
|
+# You may obtain a copy of the License at
|
|
|
+#
|
|
|
+# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
+#
|
|
|
+# Unless required by applicable law or agreed to in writing, software
|
|
|
+# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
+# See the License for the specific language governing permissions and
|
|
|
+# limitations under the License.
|
|
|
+---
|
|
|
+
|
|
|
+- name: Initial cobbler setup
|
|
|
+ hosts: localhost
|
|
|
+ connection: local
|
|
|
+ gather_facts: false
|
|
|
+ tasks:
|
|
|
+ - name: Inside cobbler container
|
|
|
+ debug:
|
|
|
+ msg: "Hiii! I am cobbler"
|
|
|
+
|
|
|
+ - name: Make
|
|
|
+ command: make rpms
|
|
|
+ args:
|
|
|
+ chdir: /cobbler
|
|
|
+ changed_when: false
|
|
|
+
|
|
|
+ - name: Install cobbler and cobbler-web
|
|
|
+ command: zypper in -y --allow-unsigned-rpm cobbler-3.2.2-1.noarch.rpm cobbler-web-3.2.2-1.noarch.rpm
|
|
|
+ args:
|
|
|
+ chdir: /cobbler/rpm-build
|
|
|
+ changed_when: false
|
|
|
+
|
|
|
+ - name: Run script
|
|
|
+ shell: sh ./mkgrub.sh
|
|
|
+ args:
|
|
|
+ chdir: /usr/share/cobbler/bin
|
|
|
+ changed_when: false
|
|
|
+
|
|
|
+ - name: Add settings to http
|
|
|
+ shell: echo "LoadModule wsgi_module modules/mod_wsgi_python3.so" >/etc/apache2/conf.d/wsgi.conf
|
|
|
+ changed_when: false
|
|
|
+
|
|
|
+ - name: Add interface to the /etc/sysconfig/dhcpd
|
|
|
+ replace:
|
|
|
+ path: "/etc/sysconfig/dhcpd"
|
|
|
+ regexp: "^DHCPD_INTERFACE=\"\""
|
|
|
+ replace: "DHCPD_INTERFACE={{ host_network_nic }}"
|
|
|
+
|
|
|
+ - name: Enable cobbler
|
|
|
+ command: systemctl enable {{ item }}
|
|
|
+ with_items:
|
|
|
+ - cobblerd
|
|
|
+ - tftp
|
|
|
+ changed_when: false
|
|
|
+
|
|
|
+ - name: Restart httpd
|
|
|
+ service:
|
|
|
+ name: "{{ item }}"
|
|
|
+ state: restarted
|
|
|
+ loop:
|
|
|
+ - apache2
|
|
|
+ - cobblerd
|
|
|
+
|
|
|
+ - name: Start services
|
|
|
+ service:
|
|
|
+ name: "{{ item }}"
|
|
|
+ state: started
|
|
|
+ loop:
|
|
|
+ - cobblerd
|
|
|
+ - tftp
|
|
|
+
|
|
|
+ - name: Adding curl
|
|
|
+ shell: export PATH="/usr/bin/curl:$PATH"
|
|
|
+
|
|
|
+ - name: Run import command
|
|
|
+ command: cobbler import --arch=x86_64 --path=/mnt --name="{{ name_iso }}"
|
|
|
+ changed_when: false
|
|
|
+
|
|
|
+ - name: Kickstart profile - leap
|
|
|
+ copy:
|
|
|
+ src: "/root/leap15.xml"
|
|
|
+ dest: "/var/lib/cobbler/templates/sample_autoyast.xml"
|
|
|
+ mode: 0775
|
|
|
+ tags: install
|
|
|
+
|
|
|
+ - name: Pxe menu
|
|
|
+ copy:
|
|
|
+ src: "/root/omnia/control_plane/roles/provision_cobbler/files/menu.yml"
|
|
|
+ dest: "/etc/cobbler/boot_loader_conf/pxedefault.template"
|
|
|
+ mode: 0775
|
|
|
+ tags: install
|
|
|
+
|
|
|
+ - name: Assign default grub option
|
|
|
+ replace:
|
|
|
+ path: "/var/lib/cobbler/grub_config/grub/grub.cfg"
|
|
|
+ regexp: "^set default='local'"
|
|
|
+ replace: "set default='1'"
|
|
|
+ tags: install
|
|
|
+
|
|
|
+ - name: Assign default grub timeout
|
|
|
+ replace:
|
|
|
+ path: "/var/lib/cobbler/grub_config/grub/grub.cfg"
|
|
|
+ regexp: '^set timeout=80'
|
|
|
+ replace: 'set timeout=10'
|
|
|
+ tags: install
|
|
|
+
|
|
|
+ - name: Syncing of cobbler
|
|
|
+ command: cobbler sync
|
|
|
+ changed_when: false
|
|
|
+
|
|
|
+ - name: Restart cobblerd, http, xinetd and dhcpd
|
|
|
+ service:
|
|
|
+ name: "{{ item }}"
|
|
|
+ state: restarted
|
|
|
+ loop:
|
|
|
+ - cobblerd
|
|
|
+ - apache2
|
|
|
+ - xinetd
|
|
|
+ - dhcpd
|
|
|
+
|
|
|
+ - name: Fetch ansible-playbook path
|
|
|
+ command: whereis ansible-playbook
|
|
|
+ changed_when: false
|
|
|
+ register: ansible_playbook_path
|
|
|
+
|
|
|
+# - name: Set dhcpd_lease_file variable for inventory creation
|
|
|
+# cron:
|
|
|
+# env: yes
|
|
|
+# name: dhcpd_lease_file
|
|
|
+# value: "/var/lib/dhcp/db/dhcpd.leases"
|
|
|
+
|
|
|
+# - name: Set provision_os variable for inventory creation
|
|
|
+# cron:
|
|
|
+# env: yes
|
|
|
+# name: provision_os
|
|
|
+# value: "{{ name_iso }}"
|
|
|
+
|
|
|
+ - name: Add tftp cron job
|
|
|
+ cron:
|
|
|
+ name: Start tftp service
|
|
|
+ minute: "*"
|
|
|
+ job: "{{ ansible_playbook_path.stdout.split(' ')[1] }} /root/tftp.yml -e provision_os={{ name_iso }}"
|
|
|
+
|
|
|
+ - name: Add inventory cron job
|
|
|
+ cron:
|
|
|
+ name: Create inventory
|
|
|
+ minute: "*/5"
|
|
|
+ job: "{{ ansible_playbook_path.stdout.split(' ')[1] }} /root/inventory_creation.yml -e dhcpd_lease_file=\"/var/lib/dhcp/db/dhcpd.leases\""
|