diff --git a/.ansible-lint b/.ansible-lint index a5e96ab..da66d5f 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -32,3 +32,5 @@ mock_roles: - performancecopilot.metrics.redis - performancecopilot.metrics.repository - performancecopilot.metrics.spark +mock_modules: + - ansible.utils.update_fact diff --git a/.ostree/README.md b/.ostree/README.md new file mode 100644 index 0000000..f5e6931 --- /dev/null +++ b/.ostree/README.md @@ -0,0 +1,3 @@ +*NOTE*: The `*.txt` files are used by `get_ostree_data.sh` to create the lists +of packages, and to find other system roles used by this role. DO NOT use them +directly. diff --git a/.ostree/get_ostree_data.sh b/.ostree/get_ostree_data.sh new file mode 100755 index 0000000..7c32524 --- /dev/null +++ b/.ostree/get_ostree_data.sh @@ -0,0 +1,123 @@ +#!/bin/bash + +set -euo pipefail + +role_collection_dir="${ROLE_COLLECTION_DIR:-fedora/linux_system_roles}" +ostree_dir="${OSTREE_DIR:-"$(dirname "$(realpath "$0")")"}" + +if [ -z "${4:-}" ] || [ "${1:-}" = help ] || [ "${1:-}" = -h ]; then + cat < 0 + +- name: Ensure correct package manager for ostree systems + vars: + ostree_pkg_mgr: ansible.posix.rhel_rpm_ostree + ostree_booted_file: /run/ostree-booted + when: ansible_facts.pkg_mgr | d("") != ostree_pkg_mgr + block: + - name: Check if system is ostree + stat: + path: "{{ ostree_booted_file }}" + register: __ostree_booted_stat + + - name: Set package manager to use for ostree + ansible.utils.update_fact: + updates: + - path: ansible_facts.pkg_mgr + value: "{{ ostree_pkg_mgr }}" + when: __ostree_booted_stat.stat.exists + - name: Add Elasticsearch to metrics domain list set_fact: __metrics_domains: "{{ __metrics_domains + ['elasticsearch'] }}" diff --git a/tests/check_into_elasticsearch.yml b/tests/check_into_elasticsearch.yml index 217ef68..d2b9424 100644 --- a/tests/check_into_elasticsearch.yml +++ b/tests/check_into_elasticsearch.yml @@ -6,5 +6,6 @@ - name: Check the ansible_managed header in pcp2elasticsearch.service vars: - __test_config_path: /usr/lib/systemd/system/pcp2elasticsearch.service + __test_config_path: >- + {{ __elasticsearch_service_path }}/pcp2elasticsearch.service include_tasks: check_header.yml diff --git a/tests/tests_verify_from_elasticsearch.yml b/tests/tests_verify_from_elasticsearch.yml index fe0790e..9504664 100644 --- a/tests/tests_verify_from_elasticsearch.yml +++ b/tests/tests_verify_from_elasticsearch.yml @@ -3,11 +3,6 @@ - name: Test import from Elasticsearch hosts: all - roles: - - role: linux-system-roles.metrics - vars: - metrics_from_elasticsearch: true - pre_tasks: - name: Stop test meta: end_host @@ -19,6 +14,13 @@ import_tasks: get_services_state.yml tasks: + - name: Run the metrics role to configure Elasticsearch + include_role: + name: linux-system-roles.metrics + public: true + vars: + metrics_from_elasticsearch: true + - name: Check if import from Elasticsearch works include_tasks: check_from_elasticsearch.yml diff --git a/tests/tests_verify_mssql.yml b/tests/tests_verify_mssql.yml index 0e624c9..a08e5f8 100644 --- a/tests/tests_verify_mssql.yml +++ b/tests/tests_verify_mssql.yml @@ -19,6 +19,24 @@ - name: Save state of services import_tasks: get_services_state.yml + - name: Ensure correct package manager for ostree systems + vars: + ostree_pkg_mgr: ansible.posix.rhel_rpm_ostree + ostree_booted_file: /run/ostree-booted + when: ansible_facts.pkg_mgr | d("") != ostree_pkg_mgr + block: + - name: Check if system is ostree + stat: + path: "{{ ostree_booted_file }}" + register: __ostree_booted_stat + + - name: Set package manager to use for ostree + ansible.utils.update_fact: + updates: + - path: ansible_facts.pkg_mgr + value: "{{ ostree_pkg_mgr }}" + when: __ostree_booted_stat.stat.exists + - name: Ensure python3-pyodbc is installed package: name: python3-pyodbc diff --git a/tests/tests_verify_postfix.yml b/tests/tests_verify_postfix.yml index d10c829..79e38fd 100644 --- a/tests/tests_verify_postfix.yml +++ b/tests/tests_verify_postfix.yml @@ -18,6 +18,24 @@ - name: Save state of services import_tasks: get_services_state.yml + - name: Ensure correct package manager for ostree systems + vars: + ostree_pkg_mgr: ansible.posix.rhel_rpm_ostree + ostree_booted_file: /run/ostree-booted + when: ansible_facts.pkg_mgr | d("") != ostree_pkg_mgr + block: + - name: Check if system is ostree + stat: + path: "{{ ostree_booted_file }}" + register: __ostree_booted_stat + + - name: Set package manager to use for ostree + ansible.utils.update_fact: + updates: + - path: ansible_facts.pkg_mgr + value: "{{ ostree_pkg_mgr }}" + when: __ostree_booted_stat.stat.exists + - name: Ensure postfix is installed package: name: diff --git a/vars/main.yml b/vars/main.yml index 41becd9..0c73951 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -3,3 +3,15 @@ __metrics_domains: [] __metrics_accounts: {} + +__metrics_required_facts: + - distribution + - distribution_major_version + - distribution_version + - os_family + +# the subsets of ansible_facts that need to be gathered in case any of the +# facts in required_facts is missing; see the documentation of +# the 'gather_subset' parameter of the 'setup' module +__metrics_required_facts_subsets: "{{ ['!all', '!min'] + + __metrics_required_facts }}"