diff --git a/README.md b/README.md index 3e281183f03ab335210e9ac4099b112a13697e48..825955c4095de715506521d186010265c32f5e23 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,10 @@ To deploy this role to a managed host, the following software must be installed ## Quick start ``` - ansible-playbook site.yml -b -K + ansible-playbook site.yml -i ~/inventory_tmp.yml --become ``` -## General usage +## General Ansible usage Most options already have sensible defaults in `ansible.cfg`. However, you can override these defaults using CLI options/flags if you want to. diff --git a/site.yml b/site.yml index 13c0351b23936a69ce49615b9c509cd6a11eb839..28622caa6cd28063fe2be265de40570a1271c76a 100644 --- a/site.yml +++ b/site.yml @@ -1,8 +1,6 @@ --- - hosts: localhost connection: local - vars: - - ISO: "RHEL79" vars_prompt: - name: install_hostname prompt: "What's the hostname of the system that you're trying to install? Use ONLY the hostname, NOT the FQDN!" diff --git a/tasks/main.yml b/tasks/main.yml index d077a9522375b81ed87dee218d612cbe94b272df..35aa554b2039c5fab686e809b9f8929855d1b03f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,17 +1,23 @@ --- ### PREPARATION +# Create a separate build directory so the role directory is not overly polluted - name: create build directory file: path: "{{ playbook_dir }}/build/" state: directory +# Mount the RHEL ISO image to a temporary mountpoint. That mountpoint is +# automatically removed on unmount. +# To not pollute the system's fstab file, we use a separate on below /tmp/. - name: mount boot ISO mount: fstype: "iso9660" opts: "loop" path: "{{ playbook_dir }}/iso/" - src: "{{ playbook_dir }}/rhel-server-7.9-x86_64-dvd.iso" + src: "{{ playbook_dir }}/rhel-server-{{ rhel_version_long }}-x86_64-dvd.iso" fstab: "/tmp/fstab" state: mounted +# Copy contents of ISO image to the build directory, because they will need to +# be included in the new image. - name: copy ISO contents shell: cmd: 'cp -avRf "{{ playbook_dir }}/iso" "{{ playbook_dir }}/build"' @@ -31,11 +37,17 @@ ### CREATE CONFIGS +# Write Kickstart files for all servers listed in the network.yml vars file. +# The Kickstart file contains configurations for the RHEL Anaconda installer +# that determine what the future system will look like in terms of packages, +# partitioning, network configuration etc. - name: write Kickstart files template: src: "kickstart.cfg.j2" dest: "build/iso/{{ item.hostname }}.cfg" loop: "{{ hosts }}" +# Write isolinux config file that contains references to the installation media +# and the Kickstart file. - name: template isolinux config template: src: "isolinux.cfg.j2" @@ -45,6 +57,8 @@ ### CREATE ISO INSTALLATION IMAGE +# Create the custom ISO installation DVD image. When it's finished, it can be +# found below "./build/". - name: create ISO image command: cmd: 'xorrisofs -output {{ playbook_dir }}/build/{{ ISO }}.iso -eltorito-boot isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -volid "{{ ISO }}" -rational-rock {{ playbook_dir }}/build/iso/' @@ -58,7 +72,7 @@ mount: path: "{{ playbook_dir }}/iso" state: unmounted -- name: clean up +- name: clean up temporary files and directories file: path: "{{ item }}" state: absent diff --git a/templates/isolinux.cfg.j2 b/templates/isolinux.cfg.j2 index fdbd2902fcb5c0909f6a2816a70cbe4f07f27abd..e8160d39a28d8af6055971b07654cfdd9470e024 100644 --- a/templates/isolinux.cfg.j2 +++ b/templates/isolinux.cfg.j2 @@ -60,7 +60,7 @@ menu separator # insert an empty line ##### Begin INSERTED FOR ANSIBLE ROLE ##### label netinstall - menu label Install Red Hat Enterprise Linux 7.9 ^Netinstall Server + menu label Install Red Hat Enterprise Linux {{ rhel_version_long }} ^Netinstall Server menu default kernel vmlinuz append initrd=initrd.img inst.ks=cdrom:/{{ item.hostname }}.cfg inst.stage2=hd:LABEL=RHEL79 quiet diff --git a/vars/main.yml b/vars/main.yml index 37268a3460e498724df380291c3c9e3aef66d256..11e68d8aa81095f8698dbd29c900397e6dbfe439 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,2 +1,6 @@ --- # vars file for ansible_lza_create_rhel_iso + +rhel_version_long: "7.9" +rhel_version_short: "79" +ISO: "RHEL{{ rhel_version_short }}"