diff --git a/bigboot_setup_environment.yml b/bigboot_setup_environment.yml index e25562a..466f037 100644 --- a/bigboot_setup_environment.yml +++ b/bigboot_setup_environment.yml @@ -21,6 +21,11 @@ - name: Set logical volume information ansible.builtin.import_tasks: tasks/capture_lv_device_details.yml + - name: Run pre-checks to verify environment + ansible.builtin.import_tasks: tasks/pre-checks.yml + when: + - bigboot_execute_bigboot | bool + - name: Set environment for subsequent workflow nodes ansible.builtin.set_stats: aggregate: true diff --git a/tasks/disable_systemd_services.yml b/tasks/disable_systemd_services.yml index 14f9301..4c21418 100644 --- a/tasks/disable_systemd_services.yml +++ b/tasks/disable_systemd_services.yml @@ -1,18 +1,18 @@ --- -- name: Save service state +- name: "Save service state: {{ item }}" ansible.builtin.set_fact: bigboot_service_to_disable: service: "{{ ansible_facts['services'][item]['name'] }}" state: "{{ (ansible_facts['services'][item]['state'] == 'running') | ternary('started', 'stopped') }}" status: "{{ (ansible_facts['services'][item]['status'] == 'enabled') | ternary('true', 'false') }}" -- name: Disable and stop service +- name: "Disable and stop service: {{ item }}" ansible.builtin.service: name: "{{ item }}" state: stopped enabled: false -- name: Log disabled service state +- name: "Log disabled service state: {{ item }}" ansible.builtin.lineinfile: path: "{{ bigboot_disabled_services_log }}" line: "{{ item }},{{ bigboot_service_to_disable['state'] }},{{ bigboot_service_to_disable['status'] }}" diff --git a/tasks/pre-checks.yml b/tasks/pre-checks.yml new file mode 100644 index 0000000..759bc56 --- /dev/null +++ b/tasks/pre-checks.yml @@ -0,0 +1,29 @@ +--- +- name: Get /boot mount information + ansible.builtin.set_fact: + bigboot_boot_mount: "{{ ansible_facts.mounts \ + | selectattr('mount', 'equalto', '/boot') | first }}" + +- name: Set next partition after /boot + ansible.builtin.set_fact: + bigboot_next_device: "{{ bigboot_boot_mount['device'][:-1] }}{{ bigboot_boot_mount['device'][-1:] | int + 1 }}" + +- name: Capture partition information from fdisk + ansible.builtin.shell: + cmd: | + set -o pipefail + fdisk -l {{ bigboot_boot_mount['device'][:-1] }} | grep '{{ bigboot_next_device }}' + executable: /bin/bash + changed_when: false + failed_when: bigboot_fdisk_partition['rc'] not in [0, 141] + register: bigboot_fdisk_partition + +- name: Debug bigboot_fdisk_partition + ansible.builtin.debug: + var: bigboot_fdisk_partition + +- name: Assert that the partition following /boot is of type LVM + ansible.builtin.assert: + that: "'Linux LVM' in bigboot_fdisk_partition['stdout']" + success_msg: The partition following /boot is an LVM partition + fail_msg: The partition following /boot is NOT an LVM partition. Execution halted.