From 565408ff8eb1aa46939fa485662baa26f3face77 Mon Sep 17 00:00:00 2001 From: Chris Croome <chris@webarchitects.co.uk> Date: Wed, 29 Nov 2023 13:54:04 +0000 Subject: [PATCH] Fix error caused by new Ansible versions --- .pre-commit-config.yaml | 24 +++++++++++++++++++++--- .pymarkdown.yml | 5 +++++ tasks/master_features.yml | 32 +++++++++++++++++++++++++++----- 3 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 .pymarkdown.yml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f373278..0cf1f0f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,9 +1,27 @@ --- -# https://yamllint.readthedocs.io/en/stable/integration.html -# https://github.com/adrienverge/yamllint/tags repos: + # https://github.com/adrienverge/yamllint/tags - repo: https://github.com/adrienverge/yamllint.git - rev: v1.30.0 + rev: v1.33.0 hooks: - id: yamllint + name: YAML Lint + # https://github.com/ansible/ansible-lint/releases + - repo: https://github.com/ansible/ansible-lint.git + rev: v6.22.0 + hooks: + - id: ansible-lint + name: Ansible Lint + language: python + additional_dependencies: + # https://github.com/kellyjonbrazil/jc/releases + - jc==1.23.6 + # https://github.com/jmespath/jmespath.py/tags + - jmespath==1.0.1 + # https://github.com/jackdewinter/pymarkdown/releases + - repo: https://github.com/jackdewinter/pymarkdown + rev: v0.9.14 + hooks: + - id: pymarkdown + name: Markdown Lint ... diff --git a/.pymarkdown.yml b/.pymarkdown.yml new file mode 100644 index 0000000..03986e9 --- /dev/null +++ b/.pymarkdown.yml @@ -0,0 +1,5 @@ +--- +plugins: + md013: + enabled: false +... diff --git a/tasks/master_features.yml b/tasks/master_features.yml index 7e4491d..8e51029 100644 --- a/tasks/master_features.yml +++ b/tasks/master_features.yml @@ -13,11 +13,33 @@ var: icinga_feature_enabled verbosity: 1 - - name: Check that there are no items in the icinga_feature_disabled and icinga_feature_enabled lists - ansible.builtin.assert: - that: - - icinga_feature_disabled | difference(icinga_feature_enabled) == icinga_feature_disabled - quiet: "{% if ansible_verbosity == 0 %}true{% else %}false{% endif %}" + - name: Run check in a block to catch errors + block: + + - name: Check that there are no items in the icinga_feature_disabled and icinga_feature_enabled lists + ansible.builtin.assert: + that: + - not icinga_feature_disabled | difference(icinga_feature_enabled) == icinga_feature_disabled | bool + quiet: "{% if ansible_verbosity == 0 %}true{% else %}false{% endif %}" + + rescue: + + - name: Debug proposed disabled features + ansible.builtin.debug: + var: icinga_feature_disabled + + - name: Debug proposed enabled features + ansible.builtin.debug: + var: icinga_feature_enabled + + - name: Debug the check that caused the failure + ansible.builtin.debug: + msg: + - "Folowing are the results of: icinga_feature_disabled | difference(icinga_feature_enabled) == icinga_feature_disabled" + - "{{ icinga_feature_disabled | difference(icinga_feature_enabled) == icinga_feature_disabled }}" + + - name: Fail as it appears there are some Icinga features that are set to be both enabled and disabled? + ansible.builtin.fail: - name: Get a list of enabled and disabled features ansible.builtin.command: /usr/sbin/icinga2 feature list -- GitLab