|
| 1 | +--- |
| 2 | +# Single storage test setup entrypoint (typically the play's first task). |
| 3 | +# |
| 4 | +# Optional variables: |
| 5 | +# __storage_include_prep — default true: run role with no storage_* config and set |
| 6 | +# storage_skip_checks. Set false for a follow-up include that only needs |
| 7 | +# package_facts / blivet facts (e.g. tests_resize.yml after initial setup). |
| 8 | +# __storage_storage_skip_checks — if set, used as storage_skip_checks instead of |
| 9 | +# the default [blivet_available, packages_installed conditional]. |
| 10 | +# __storage_get_package_facts — default false: ansible.builtin.package_facts, then |
| 11 | +# blivet_pkg_version, and is_fedora / is_rhel* / is_rhel78. |
| 12 | +# __storage_get_unused_disks — default true: whether to include get_unused_disk.yml. |
| 13 | +# The playbook supplies this when needed; setup does not derive it. |
| 14 | +# __storage_min_size, __storage_max_return, __storage_max_size, |
| 15 | +# __storage_disks_needed, __storage_match_sector_size — passed to get_unused_disk. |
| 16 | +# |
| 17 | +- name: Run the role |
| 18 | + when: __storage_include_prep | default(true) |
| 19 | + block: |
| 20 | + - name: Run the role |
| 21 | + ansible.builtin.include_tasks: run_role_with_clear_facts.yml |
| 22 | + |
| 23 | + - name: Mark tasks to be skipped |
| 24 | + ansible.builtin.set_fact: |
| 25 | + storage_skip_checks: >- |
| 26 | + {{ |
| 27 | + __storage_storage_skip_checks |
| 28 | + if __storage_storage_skip_checks is defined |
| 29 | + else ( |
| 30 | + ['blivet_available', |
| 31 | + (lookup('env', 'SYSTEM_ROLES_REMOVE_CLOUD_INIT') in ['', 'false']) |
| 32 | + | ternary('packages_installed', '')] |
| 33 | + ) |
| 34 | + }} |
| 35 | +
|
| 36 | +- name: Gather package facts and set vars based on package facts |
| 37 | + when: __storage_get_package_facts | default(false) |
| 38 | + block: |
| 39 | + - name: Gather package facts |
| 40 | + ansible.builtin.package_facts: |
| 41 | + no_log: "{{ ansible_verbosity < 3 }}" |
| 42 | + |
| 43 | + - name: Set blivet package version |
| 44 | + ansible.builtin.set_fact: |
| 45 | + blivet_pkg_version: "{{ |
| 46 | + ansible_facts.packages[blivet_pkg_name[0]][0]['version'] + |
| 47 | + '-' + ansible_facts.packages[blivet_pkg_name[0]][0]['release'] }}" |
| 48 | + vars: |
| 49 | + blivet_pkg_name: "{{ ansible_facts.packages | |
| 50 | + select('search', 'blivet') | select('search', 'python') | list }}" |
| 51 | + |
| 52 | +- name: Set distribution version flags |
| 53 | + ansible.builtin.set_fact: |
| 54 | + is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" |
| 55 | + is_rhel7: "{{ ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == '7' }}" |
| 56 | + is_rhel8: "{{ ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == '8' }}" |
| 57 | + is_rhel9: "{{ ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == '9' }}" |
| 58 | + is_rhel10: "{{ ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == '10' }}" |
| 59 | + is_rhel78: "{{ ansible_facts['os_family'] == 'RedHat' and |
| 60 | + ansible_facts['distribution_major_version'] in ['7', '8'] }}" |
| 61 | + |
| 62 | +- name: Get unused disks for test |
| 63 | + when: __storage_get_unused_disks | default(true) |
| 64 | + ansible.builtin.include_tasks: get_unused_disk.yml |
| 65 | + |
| 66 | +- name: Get info about storage devices |
| 67 | + ansible.builtin.shell: |
| 68 | + executable: /bin/bash |
| 69 | + cmd: | |
| 70 | + set -euxo pipefail |
| 71 | + exec 1>&2 |
| 72 | + lsblk -p --pairs --bytes -o NAME,TYPE,SIZE,FSTYPE,LOG-SEC,MOUNTPOINTS,PARTLABEL |
| 73 | + if type -p mdadm >/dev/null; then |
| 74 | + mdadm --misc --examine --scan |
| 75 | + fi |
| 76 | + if type -p dmsetup >/dev/null; then |
| 77 | + dmsetup ls --tree --separator / |
| 78 | + fi |
| 79 | + if type -p lvm >/dev/null; then |
| 80 | + lvm vgdisplay |
| 81 | + fi |
| 82 | + udevadm settle -t 0 |
| 83 | + changed_when: false |
0 commit comments