diff --git a/.github/config/ubuntu-requirements.txt b/.github/config/ubuntu-requirements.txt index 1fc4bdab..affdaa7d 100644 --- a/.github/config/ubuntu-requirements.txt +++ b/.github/config/ubuntu-requirements.txt @@ -7,6 +7,7 @@ gcc libffi-dev libnss3-tools pacemaker +pacemaker-dev psmisc puma python3-cryptography diff --git a/.github/workflows/python-unit-test.yml b/.github/workflows/python-unit-test.yml index 1c1b4663..11e70138 100644 --- a/.github/workflows/python-unit-test.yml +++ b/.github/workflows/python-unit-test.yml @@ -18,14 +18,20 @@ jobs: python: strategy: matrix: - os: - - ubuntu-22.04 - - ubuntu-latest - pcs_version: - - v0.11.4 - - v0.11.5 - - v0.11.6 - - main + include: + - os: ubuntu-22.04 + pcs_version: v0.11.4 + - os: ubuntu-22.04 + pcs_version: v0.11.5 + - os: ubuntu-22.04 + pcs_version: v0.11.6 + - os: ubuntu-22.04 + pcs_version: v0.11.7 + - os: ubuntu-22.04 + pcs_version: v0.11.8 + - os: ubuntu-24.04 + pcs_version: main + # pcs_version 0.12.x will go to ubuntu 24.04 only runs-on: ${{ matrix.os }} steps: - name: Update git @@ -47,6 +53,9 @@ jobs: # package per line. if [ -f .github/config/ubuntu-requirements.txt ]; then sudo apt-get install -y $(cat .github/config/ubuntu-requirements.txt) + # remove pcs which is installed as a dependency of pacemaker (since + # ubuntu 23.10) and conflicts with pcs built from source + sudo dpkg --force-depends --purge pcs fi - name: Clone pcs @@ -60,7 +69,7 @@ jobs: run: | set -euxo pipefail pcs_dir="${RUNNER_TEMP}/pcs" - mkdir -p pcs_dir + mkdir -p "$pcs_dir" cd pcs-upstream if [ "x${{ matrix.pcs_version }}" == "xmain" ]; then echo "0.0.1+ci" > .tarball-version diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 92807a4e..1f1fa0b9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -56,11 +56,7 @@ variables: - PYENV_PACKAGES="${PYENV_ROOT}/lib/python${PYTHON_VER}/site-packages" - PCS_DIR=$(rpm -ql pcs | grep 'site-packages/pcs$') - PCS_PYTHON_VER=$(echo "$PCS_DIR" | sed -e 's@.*/python\([0-9\.]\+\)/.*@\1@') - - PCS_EGG=$(rpm -ql pcs | grep 'site-packages/pcs.*\.egg-info$') - - PCS_EGG_NAME=$(basename "$PCS_EGG") - if [ "x$PYTHON_VER" != "x$PCS_PYTHON_VER" ]; then ln -s "${PCS_DIR}" "${PYENV_PACKAGES}/pcs"; fi - - if [ "x$PYTHON_VER" != "x$PCS_PYTHON_VER" ]; then ln -s "${PCS_EGG}" "${PYENV_PACKAGES}/${PCS_EGG_NAME}"; fi - - if [ "x$PYTHON_VER" != "x$PCS_PYTHON_VER" ]; then pushd .; cd "${PYENV_PACKAGES}"; rename --verbose "${PCS_PYTHON_VER}" "${PYTHON_VER}" pcs-*.egg-info; popd; fi - ls -l "$PYENV_PACKAGES" .convert_role_to_collection: &convert_role_to_collection diff --git a/.sanity-ansible-ignore-2.18.txt b/.sanity-ansible-ignore-2.18.txt new file mode 100644 index 00000000..794e99c2 --- /dev/null +++ b/.sanity-ansible-ignore-2.18.txt @@ -0,0 +1,8 @@ +plugins/modules/pcs_api_v2.py validate-modules:missing-gplv3-license +plugins/modules/pcs_qdevice_certs.py validate-modules:missing-gplv3-license +tests/ha_cluster/unit/test_pcs_api_v2.py shebang!skip +tests/ha_cluster/unit/test_pcs_qdevice_certs.py shebang!skip +plugins/modules/pcs_api_v2.py import-3.8!skip +plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.8!skip +plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-3.8!skip +plugins/modules/pcs_qdevice_certs.py import-3.8!skip diff --git a/tests/tasks/fetch_versions.yml b/tests/tasks/fetch_versions.yml index 9cee95e5..ea915b98 100644 --- a/tests/tasks/fetch_versions.yml +++ b/tests/tasks/fetch_versions.yml @@ -25,3 +25,19 @@ ansible_facts.packages['pacemaker'][0]['version'] }}" __test_pcs_version: "{{ ansible_facts.packages['pcs'][0]['version'] }}" + +- name: CIB schema version + when: with_cib_schema_version | d(false) + block: + - name: Discover CIB schema version + command: + cmd: > + xmllint + --xpath 'substring-after(/cib/@validate-with, "pacemaker-")' + /var/lib/pacemaker/cib/cib.xml + register: __test_cib_validate_with_xpath + changed_when: false + + - name: Extract versions of cluster components + set_fact: + __test_cib_validate_with: "{{ __test_cib_validate_with_xpath.stdout }}" diff --git a/tests/tests_cib_constraints_create.yml b/tests/tests_cib_constraints_create.yml index afa4a3b2..470a2bd1 100644 --- a/tests/tests_cib_constraints_create.yml +++ b/tests/tests_cib_constraints_create.yml @@ -405,15 +405,8 @@ - name: Fetch cluster versions of cluster components include_tasks: tasks/fetch_versions.yml - - - name: Discover CIB schema version - command: - cmd: > - xmllint - --xpath 'substring-after(/cib/@validate-with, "pacemaker-")' - /var/lib/pacemaker/cib/cib.xml - register: __test_cib_validate_with - changed_when: false + vars: + with_cib_schema_version: true - name: Discover role names set_fact: @@ -423,7 +416,12 @@ __test_new_roles_cib: "{{ __test_pcs_version is version('0.11', '>=') and - __test_cib_validate_with.stdout is version('3.7', '>=') + __test_cib_validate_with is version('3.7', '>=') + }}" + __test_inner_rules_score: "{{ + __test_cib_validate_with is version('3.9', '<') + or + __test_pcs_version is version('0.12', '<') }}" # yamllint disable rule:line-length @@ -852,7 +850,9 @@ "in_effect": "UNKNOWN", "options": { "boolean-op": "or", - "score": "0" + {% if __test_inner_rules_score %} + "score": "0" + {% endif %} }, "type": "RULE" } @@ -938,7 +938,9 @@ "in_effect": "UNKNOWN", "options": { "boolean-op": "or", - "score": "0" + {% if __test_inner_rules_score %} + "score": "0" + {% endif %} }, "type": "RULE" } @@ -1235,7 +1237,9 @@ "in_effect": "UNKNOWN", "options": { "boolean-op": "or", - "score": "0" + {% if __test_inner_rules_score %} + "score": "0" + {% endif %} }, "type": "RULE" }, @@ -1320,7 +1324,9 @@ "in_effect": "UNKNOWN", "options": { "boolean-op": "or", - "score": "0" + {% if __test_inner_rules_score %} + "score": "0" + {% endif %} }, "type": "RULE" }, diff --git a/tests/tests_cib_rsc_op_defaults.yml b/tests/tests_cib_rsc_op_defaults.yml index 5f8e1f54..8b3a8758 100644 --- a/tests/tests_cib_rsc_op_defaults.yml +++ b/tests/tests_cib_rsc_op_defaults.yml @@ -77,8 +77,19 @@ name: linux-system-roles.ha_cluster public: true + - name: Fetch versions of cluster components + include_tasks: tasks/fetch_versions.yml + vars: + with_cib_schema_version: true + - name: Verify resource defaults vars: + __test_rule_score: "{{ + ( + __test_cib_validate_with is version('3.9', '<') + or __test_pcs_version is version('0.12', '<') + ) + | ternary(' score=INFINITY', '') }}" __test_expected_lines: - "Meta Attrs: rsc_defaults-meta_attributes" - " rsc-key-1=rsc-val-1" @@ -88,16 +99,16 @@ - " rsc-key-3=rsc-val-3" - "Meta Attrs: rsc_defaults-meta_attributes-2" - " rsc-key-4=rsc-val-4" - - " Rule: boolean-op=and score=INFINITY" + - " Rule: boolean-op=and{{ __test_rule_score }}" - " Expression: resource ocf:pacemaker:" - "Meta Attrs: without_attrs_rsc score=20" - - " Rule: boolean-op=or score=INFINITY" + - " Rule: boolean-op=or{{ __test_rule_score }}" - " Expression: resource :pacemaker:" - " Expression: resource :heartbeat:" - "Meta Attrs: all_options_rsc score=INFINITY" - " rsc-key-5=rsc-val-5" - " rsc-key-6=rsc-val-6" - - " Rule: boolean-op=and score=INFINITY" + - " Rule: boolean-op=and{{ __test_rule_score }}" - " Expression: resource ocf:pacemaker:test" block: - name: Fetch resource defaults configuration from the cluster @@ -122,6 +133,12 @@ - name: Verify operation defaults vars: + __test_rule_score: "{{ + ( + __test_cib_validate_with is version('3.9', '<') + or __test_pcs_version is version('0.12', '<') + ) + | ternary(' score=INFINITY', '') }}" __test_expected_lines: - "Meta Attrs: op_defaults-meta_attributes" - " op-key-1=op-val-1" @@ -131,16 +148,16 @@ - " op-key-3=op-val-3" - "Meta Attrs: op_defaults-meta_attributes-2" - " op-key-4=op-val-4" - - " Rule: boolean-op=and score=INFINITY" + - " Rule: boolean-op=and{{ __test_rule_score }}" - " Expression: resource ocf:pacemaker:" - "Meta Attrs: without_attrs_op score=20" - - " Rule: boolean-op=or score=INFINITY" + - " Rule: boolean-op=or{{ __test_rule_score }}" - " Expression: resource :pacemaker:" - " Expression: op monitor" - "Meta Attrs: all_options_op score=INFINITY" - " op-key-5=op-val-5" - " op-key-6=op-val-6" - - " Rule: boolean-op=and score=INFINITY" + - " Rule: boolean-op=and{{ __test_rule_score }}" - " Expression: resource ocf:pacemaker:test" block: - name: Fetch operation defaults configuration from the cluster diff --git a/tests/tests_cib_stonith_levels.yml b/tests/tests_cib_stonith_levels.yml index 7251b2ed..d4ffe9a4 100644 --- a/tests/tests_cib_stonith_levels.yml +++ b/tests/tests_cib_stonith_levels.yml @@ -57,6 +57,8 @@ include_tasks: tasks/fetch_versions.yml - name: Verify stonith levels + when: + - '"pcmk.stonith.levels.config.output-formats" not in __test_pcs_capabilities' vars: __test_regexp_label: "{{ __test_pcs_version is version('0.10.10', '>') @@ -79,7 +81,7 @@ - name: Print real stonith levels configuration debug: - var: __test_pcs_stonith_level_config + var: __test_pcs_stonith_level_config.stdout_lines - name: Print expected stonith levels configuration debug: @@ -91,5 +93,75 @@ - __test_pcs_stonith_level_config.stdout_lines == __test_expected_lines | list + - name: Verify stonith levels + when: + - '"pcmk.stonith.levels.config.output-formats" in __test_pcs_capabilities' + vars: + __test_expected_lines: ' + { + "target_node": [ + { + "id": "fl-{{ __test_first_node }}-1", + "target": "{{ __test_first_node }}", + "index": 1, + "devices": [ + "fence1" + ] + } + ], + "target_regex": [ + { + "id": "fl-node-d-2", + "target_pattern": "node-\\d+", + "index": 2, + "devices": [ + "fence2" + ] + } + ], + "target_attribute": [ + { + "id": "fl-some-name-3", + "target_attribute": "some-name", + "target_value": "", + "index": 3, + "devices": [ + "fence1", + "fence2" + ] + }, + { + "id": "fl-some-name-4", + "target_attribute": "some-name", + "target_value": "some-value", + "index": 4, + "devices": [ + "fence2", + "fence1" + ] + } + ] + }' + block: + - name: Fetch stonith levels configuration from the cluster + command: + cmd: pcs --output-format=json stonith level config + register: __test_pcs_stonith_level_config + changed_when: false + + - name: Print real stonith levels configuration + debug: + var: __test_pcs_stonith_level_config.stdout | from_json + + - name: Print expected stonith levels configuration + debug: + var: __test_expected_lines | from_json + + - name: Check stonith levels configuration + assert: + that: + - __test_pcs_stonith_level_config.stdout | from_json + == __test_expected_lines | from_json + - name: Check firewall and selinux state include_tasks: tasks/check_firewall_selinux.yml