diff --git a/.gitignore b/.gitignore index 6d19139..cb8bc18 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ SOURCES/ansible-sshd-e1de59b3c54e9d48a010eeca73755df339c7e628.tar.gz -SOURCES/certificate-1.0.1.tar.gz +SOURCES/auto-maintenance-627b7a83a2c5b2a3c1f775751c689ca40f5fb294.tar.gz +SOURCES/certificate-19115b5f824141330861359a137d08ac32082502.tar.gz SOURCES/crypto_policies-76b2d5b0460dba22c5d290c1af96e4fdb3434cb9.tar.gz SOURCES/kdump-77596fdd976c6160d6152c200a5432c609725a14.tar.gz SOURCES/kernel_settings-1.0.1.tar.gz @@ -7,7 +8,7 @@ SOURCES/logging-fe3f658e72b2883d2a1460d453105c7a53dd70e8.tar.gz SOURCES/metrics-7f94b49688902eb507e0ebeda1fbf08621bc3c6b.tar.gz SOURCES/nbde_client-1.0.1.tar.gz SOURCES/nbde_server-1.0.1.tar.gz -SOURCES/network-bf4501bb8770d3ef761e1684011c905f99a9752f.tar.gz +SOURCES/network-675c7e8073f33ead5143cd5fc11e332f18524317.tar.gz SOURCES/postfix-0.1.tar.gz SOURCES/selinux-1.1.1.tar.gz SOURCES/storage-1.2.2.tar.gz diff --git a/.rhel-system-roles.metadata b/.rhel-system-roles.metadata index 6e424d3..3bc1b4b 100644 --- a/.rhel-system-roles.metadata +++ b/.rhel-system-roles.metadata @@ -1,5 +1,6 @@ 77e952b62e634c69e36115845b4f24ee3bfe76b7 SOURCES/ansible-sshd-e1de59b3c54e9d48a010eeca73755df339c7e628.tar.gz -a24d2a8ae03d3f92f8564494fd8f464dec7e45ed SOURCES/certificate-1.0.1.tar.gz +dbf1f7ca7cb0bb6ba7cb7f6f85489591e481337c SOURCES/auto-maintenance-627b7a83a2c5b2a3c1f775751c689ca40f5fb294.tar.gz +83eab43fb47021fc2fcd062d77ad7555bf78b3ab SOURCES/certificate-19115b5f824141330861359a137d08ac32082502.tar.gz 513057251590e81b629a69a4ed704b0976b1bc44 SOURCES/crypto_policies-76b2d5b0460dba22c5d290c1af96e4fdb3434cb9.tar.gz fa3d5daf6cf1ceeaa87f58c16e11153cf250e2fa SOURCES/kdump-77596fdd976c6160d6152c200a5432c609725a14.tar.gz 61be37db19fe593f418e5b69798152f4c5e84cc7 SOURCES/kernel_settings-1.0.1.tar.gz @@ -7,7 +8,7 @@ fa3d5daf6cf1ceeaa87f58c16e11153cf250e2fa SOURCES/kdump-77596fdd976c6160d6152c200 3c25f49356e9325ba694d14ece036c8ea3aa16f6 SOURCES/metrics-7f94b49688902eb507e0ebeda1fbf08621bc3c6b.tar.gz 2acad85c458a08a36ca2f2e6b6c12b9b63c42dae SOURCES/nbde_client-1.0.1.tar.gz c55d45d134042b00ece17f2a21bb945c571310b3 SOURCES/nbde_server-1.0.1.tar.gz -d1e3e5cd724e7a61a9b3f4eb2bf669d6ed6f9cde SOURCES/network-bf4501bb8770d3ef761e1684011c905f99a9752f.tar.gz +7b3fe217917edd822513e5894f4467885334c8a5 SOURCES/network-675c7e8073f33ead5143cd5fc11e332f18524317.tar.gz 66c82331f4ac9598c506c3999965b4d07dbfe49d SOURCES/postfix-0.1.tar.gz f2ad38bd93487962de511b1f4bc9dc6607a5ab36 SOURCES/selinux-1.1.1.tar.gz b2c6c16da768d379c72f6ed313440bd7fa20c469 SOURCES/storage-1.2.2.tar.gz diff --git a/SOURCES/collection_readme.sh b/SOURCES/collection_readme.sh new file mode 100755 index 0000000..0775282 --- /dev/null +++ b/SOURCES/collection_readme.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -euxo pipefail + +readme_md=${1:-"lsr_role2collection/collection_readme.md"} + +sed -i -e '/## Currently supported distributions/{:1;/## Dependencies/!{N;b 1};s|.*|## Dependencies|}' \ + -e 's/\(Linux System Roles is a collection of roles for managing Linux system components.\)/\1\n\nThis collection is available as a Technology Preview./' \ + -e 's/Linux/RHEL/g' \ + -e 's/Ansible Galaxy/Automation Hub/g' \ + -e 's/fedora\(.\)linux_system_roles/redhat\1rhel_system_roles/g' \ + -e 's/linux-system-roles/rhel-system-roles/g' \ + -e '/## Documentation/{:a;/## Support/!{N;b a};s|.*|## Documentation\nThe official RHEL System Roles documentation can be found in the [Product Documentation section of the Red Hat Customer Portal](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/administration_and_configuration_tasks_using_system_roles_in_rhel/index).\n\n## Support|}' \ + $readme_md diff --git a/SOURCES/md2html.sh b/SOURCES/md2html.sh deleted file mode 100644 index f3da649..0000000 --- a/SOURCES/md2html.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -set -euxo pipefail - -for file in "$@"; do - pandoc -f markdown_github "${file}" -t asciidoc -o "${file%.md}.tmp.adoc" - touch -r "${file}" "${file%.md}.tmp.adoc" - TZ=UTC asciidoc -o "${file%.md}.html" -a footer-style=none -a toc2 -a source-highlighter=highlight "${file%.md}.tmp.adoc" - rm "${file%.md}.tmp.adoc" -done diff --git a/SOURCES/network-epel-minimal.diff b/SOURCES/network-epel-minimal.diff new file mode 100644 index 0000000..05e05fc --- /dev/null +++ b/SOURCES/network-epel-minimal.diff @@ -0,0 +1,389 @@ +diff --git a/tests/playbooks/integration_pytest_python3.yml b/tests/playbooks/integration_pytest_python3.yml +index 3c7d3fb..ad8418c 100644 +--- a/tests/playbooks/integration_pytest_python3.yml ++++ b/tests/playbooks/integration_pytest_python3.yml +@@ -9,6 +9,11 @@ + - rsync + + tasks: ++ - name: Install EPEL for RHEL and CentOS ++ # yamllint disable-line rule:line-length ++ command: "yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm" ++ when: ansible_distribution in ["CentOS", "RedHat"] ++ + - name: Install rpm dependencies + package: + state: present +diff --git a/tests/tasks/el_repo_setup.yml b/tests/tasks/el_repo_setup.yml +deleted file mode 100644 +index 0656e8c..0000000 +--- a/tests/tasks/el_repo_setup.yml ++++ /dev/null +@@ -1,26 +0,0 @@ +-# SPDX-License-Identifier: BSD-3-Clause +-- name: Fix CentOS6 Base repo +- copy: +- dest: /etc/yum.repos.d/CentOS-Base.repo +- content: | +- [base] +- name=CentOS-$releasever - Base +- baseurl=https://vault.centos.org/6.10/os/$basearch/ +- gpgcheck=1 +- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 +- +- [updates] +- name=CentOS-$releasever - Updates +- baseurl=https://vault.centos.org/6.10/updates/$basearch/ +- gpgcheck=1 +- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 +- +- [extras] +- name=CentOS-$releasever - Extras +- baseurl=https://vault.centos.org/6.10/extras/$basearch/ +- gpgcheck=1 +- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 +- when: +- - ansible_distribution == 'CentOS' +- - ansible_distribution_major_version == '6' +-- include_tasks: enable_epel.yml +diff --git a/tests/tasks/setup_802_1x_server.yml b/tests/tasks/setup_802_1x_server.yml +index 49d1ce1..3bf16a9 100644 +--- a/tests/tasks/setup_802_1x_server.yml ++++ b/tests/tasks/setup_802_1x_server.yml +@@ -1,5 +1,7 @@ + # SPDX-License-Identifier: BSD-3-Clause + --- ++- include_tasks: enable_epel.yml ++ + - name: Install hostapd + package: + name: hostapd +diff --git a/tests/tasks/setup_mock_wifi.yml b/tests/tasks/setup_mock_wifi.yml +index 997b704..d7a1e22 100644 +--- a/tests/tasks/setup_mock_wifi.yml ++++ b/tests/tasks/setup_mock_wifi.yml +@@ -1,5 +1,7 @@ + # SPDX-License-Identifier: BSD-3-Clause + --- ++- include_tasks: enable_epel.yml ++ + - name: Install packages required to set up mock wifi network + package: + name: +diff --git a/tests/tests_802_1x_nm.yml b/tests/tests_802_1x_nm.yml +index a27d8ea..288cd5d 100644 +--- a/tests/tests_802_1x_nm.yml ++++ b/tests/tests_802_1x_nm.yml +@@ -5,7 +5,6 @@ + - hosts: all + name: Run playbook 'playbooks/tests_802_1x.yml' with nm as provider + tasks: +- - include_tasks: tasks/el_repo_setup.yml + - name: Set network provider to 'nm' + set_fact: + network_provider: nm +diff --git a/tests/tests_802_1x_updated_nm.yml b/tests/tests_802_1x_updated_nm.yml +index 5a25f5b..bd335e4 100644 +--- a/tests/tests_802_1x_updated_nm.yml ++++ b/tests/tests_802_1x_updated_nm.yml +@@ -5,7 +5,6 @@ + - hosts: all + name: Run playbook 'playbooks/tests_802_1x_updated.yml' with nm as provider + tasks: +- - include_tasks: tasks/el_repo_setup.yml + - name: Set network provider to 'nm' + set_fact: + network_provider: nm +diff --git a/tests/tests_bond_initscripts.yml b/tests/tests_bond_initscripts.yml +index 32fcc32..8fa74c5 100644 +--- a/tests/tests_bond_initscripts.yml ++++ b/tests/tests_bond_initscripts.yml +@@ -4,7 +4,6 @@ + - hosts: all + name: Run playbook 'playbooks/tests_bond.yml' with initscripts as provider + tasks: +- - include_tasks: tasks/el_repo_setup.yml + - name: Set network provider to 'initscripts' + set_fact: + network_provider: initscripts +diff --git a/tests/tests_bond_nm.yml b/tests/tests_bond_nm.yml +index 7075d95..8ac6cbd 100644 +--- a/tests/tests_bond_nm.yml ++++ b/tests/tests_bond_nm.yml +@@ -5,7 +5,6 @@ + - hosts: all + name: Run playbook 'playbooks/tests_bond.yml' with nm as provider + tasks: +- - include_tasks: tasks/el_repo_setup.yml + - name: Set network provider to 'nm' + set_fact: + network_provider: nm +diff --git a/tests/tests_bridge_initscripts.yml b/tests/tests_bridge_initscripts.yml +index 8ce42e6..db5663c 100644 +--- a/tests/tests_bridge_initscripts.yml ++++ b/tests/tests_bridge_initscripts.yml +@@ -4,7 +4,6 @@ + - hosts: all + name: Run playbook 'playbooks/tests_bridge.yml' with initscripts as provider + tasks: +- - include_tasks: tasks/el_repo_setup.yml + - name: Set network provider to 'initscripts' + set_fact: + network_provider: initscripts +diff --git a/tests/tests_bridge_nm.yml b/tests/tests_bridge_nm.yml +index 3d1b53a..c565952 100644 +--- a/tests/tests_bridge_nm.yml ++++ b/tests/tests_bridge_nm.yml +@@ -5,7 +5,6 @@ + - hosts: all + name: Run playbook 'playbooks/tests_bridge.yml' with nm as provider + tasks: +- - include_tasks: tasks/el_repo_setup.yml + - name: Set network provider to 'nm' + set_fact: + network_provider: nm +diff --git a/tests/tests_default.yml b/tests/tests_default.yml +index e196314..f6f7550 100644 +--- a/tests/tests_default.yml ++++ b/tests/tests_default.yml +@@ -5,7 +5,6 @@ + roles: + - linux-system-roles.network + tasks: +- - include_tasks: tasks/el_repo_setup.yml + - name: Test warning and info logs + assert: + that: +diff --git a/tests/tests_default_initscripts.yml b/tests/tests_default_initscripts.yml +index 006889c..cc8b875 100644 +--- a/tests/tests_default_initscripts.yml ++++ b/tests/tests_default_initscripts.yml +@@ -2,7 +2,6 @@ + --- + - hosts: all + tasks: +- - include_tasks: tasks/el_repo_setup.yml + - name: Set network provider to 'initscripts' + set_fact: + network_provider: initscripts +diff --git a/tests/tests_default_nm.yml b/tests/tests_default_nm.yml +index 54bc3e1..8138ca9 100644 +--- a/tests/tests_default_nm.yml ++++ b/tests/tests_default_nm.yml +@@ -2,7 +2,6 @@ + --- + - hosts: all + tasks: +- - include_tasks: tasks/el_repo_setup.yml + - name: Set network provider to 'nm' + set_fact: + network_provider: nm +diff --git a/tests/tests_ethernet_initscripts.yml b/tests/tests_ethernet_initscripts.yml +index 366b052..62e75fe 100644 +--- a/tests/tests_ethernet_initscripts.yml ++++ b/tests/tests_ethernet_initscripts.yml +@@ -4,8 +4,6 @@ + - hosts: all + name: Run playbook 'playbooks/tests_ethernet.yml' with initscripts as provider + tasks: +- - include_tasks: tasks/el_repo_setup.yml +- + - name: Set network provider to 'initscripts' + set_fact: + network_provider: initscripts +diff --git a/tests/tests_ethernet_nm.yml b/tests/tests_ethernet_nm.yml +index 238172d..ecefa14 100644 +--- a/tests/tests_ethernet_nm.yml ++++ b/tests/tests_ethernet_nm.yml +@@ -5,8 +5,6 @@ + - hosts: all + name: Run playbook 'playbooks/tests_ethernet.yml' with nm as provider + tasks: +- - include_tasks: tasks/el_repo_setup.yml +- + - name: Set network provider to 'nm' + set_fact: + network_provider: nm +diff --git a/tests/tests_ethtool_features_initscripts.yml b/tests/tests_ethtool_features_initscripts.yml +index 5bac5d3..6aea73b 100644 +--- a/tests/tests_ethtool_features_initscripts.yml ++++ b/tests/tests_ethtool_features_initscripts.yml +@@ -2,7 +2,6 @@ + # set network provider and gather facts + - hosts: all + tasks: +- - include_tasks: tasks/el_repo_setup.yml + - name: Set network provider to 'initscripts' + set_fact: + network_provider: initscripts +diff --git a/tests/tests_ethtool_features_nm.yml b/tests/tests_ethtool_features_nm.yml +index 2027862..30c6faa 100644 +--- a/tests/tests_ethtool_features_nm.yml ++++ b/tests/tests_ethtool_features_nm.yml +@@ -5,8 +5,6 @@ + - hosts: all + name: Run playbook 'playbooks/tests_ethtool_features.yml' with nm as provider + tasks: +- - include_tasks: tasks/el_repo_setup.yml +- + - name: Set network provider to 'nm' + set_fact: + network_provider: nm +diff --git a/tests/tests_helpers_and_asserts.yml b/tests/tests_helpers_and_asserts.yml +index 64e2875..5514182 100644 +--- a/tests/tests_helpers_and_asserts.yml ++++ b/tests/tests_helpers_and_asserts.yml +@@ -3,8 +3,6 @@ + - name: Check that creating and removing test devices and assertions work + hosts: all + tasks: +- - include_tasks: tasks/el_repo_setup.yml +- + - name: test veth interface management + include_tasks: tasks/create_and_remove_interface.yml + vars: +diff --git a/tests/tests_integration_pytest.yml b/tests/tests_integration_pytest.yml +index 9b80bd4..153214d 100644 +--- a/tests/tests_integration_pytest.yml ++++ b/tests/tests_integration_pytest.yml +@@ -1,8 +1,7 @@ + # SPDX-License-Identifier: BSD-3-Clause + --- +-- hosts: all +- tasks: +- - include_tasks: tasks/el_repo_setup.yml ++- name: Empty play to gather facts ++ hosts: all + + - import_playbook: playbooks/integration_pytest_python3.yml + when: (ansible_distribution in ["CentOS", "RedHat"] and +diff --git a/tests/tests_provider_nm.yml b/tests/tests_provider_nm.yml +index 67fcffe..99306a1 100644 +--- a/tests/tests_provider_nm.yml ++++ b/tests/tests_provider_nm.yml +@@ -5,8 +5,6 @@ + - hosts: all + name: Run playbook 'playbooks/tests_provider.yml' with nm as provider + tasks: +- - include_tasks: tasks/el_repo_setup.yml +- + - name: Set network provider to 'nm' + set_fact: + network_provider: nm +diff --git a/tests/tests_reapply_nm.yml b/tests/tests_reapply_nm.yml +index eb48ddb..69fb208 100644 +--- a/tests/tests_reapply_nm.yml ++++ b/tests/tests_reapply_nm.yml +@@ -5,8 +5,6 @@ + - hosts: all + name: Run playbook 'playbooks/tests_reapply.yml' with nm as provider + tasks: +- - include_tasks: tasks/el_repo_setup.yml +- + - name: Set network provider to 'nm' + set_fact: + network_provider: nm +diff --git a/tests/tests_regression_nm.yml b/tests/tests_regression_nm.yml +index b2c46e9..9eb8084 100644 +--- a/tests/tests_regression_nm.yml ++++ b/tests/tests_regression_nm.yml +@@ -3,8 +3,6 @@ + # set network provider and gather facts + - hosts: all + tasks: +- - include_tasks: tasks/el_repo_setup.yml +- + - name: Set network provider to 'nm' + set_fact: + network_provider: nm +diff --git a/tests/tests_states_initscripts.yml b/tests/tests_states_initscripts.yml +index fa94103..3e55a43 100644 +--- a/tests/tests_states_initscripts.yml ++++ b/tests/tests_states_initscripts.yml +@@ -4,8 +4,6 @@ + - hosts: all + name: Run playbook 'playbooks/tests_states.yml' with initscripts as provider + tasks: +- - include_tasks: tasks/el_repo_setup.yml +- + - name: Set network provider to 'initscripts' + set_fact: + network_provider: initscripts +diff --git a/tests/tests_states_nm.yml b/tests/tests_states_nm.yml +index 34c8a24..3164a3a 100644 +--- a/tests/tests_states_nm.yml ++++ b/tests/tests_states_nm.yml +@@ -5,8 +5,6 @@ + - hosts: all + name: Run playbook 'playbooks/tests_states.yml' with nm as provider + tasks: +- - include_tasks: tasks/el_repo_setup.yml +- + - name: Set network provider to 'nm' + set_fact: + network_provider: nm +diff --git a/tests/tests_team_nm.yml b/tests/tests_team_nm.yml +index 8048029..0516765 100644 +--- a/tests/tests_team_nm.yml ++++ b/tests/tests_team_nm.yml +@@ -5,8 +5,6 @@ + - hosts: all + name: Run playbook 'playbooks/tests_team.yml' with nm as provider + tasks: +- - include_tasks: tasks/el_repo_setup.yml +- + - name: Set network provider to 'nm' + set_fact: + network_provider: nm +diff --git a/tests/tests_unit.yml b/tests/tests_unit.yml +index a410fbd..b8d4096 100644 +--- a/tests/tests_unit.yml ++++ b/tests/tests_unit.yml +@@ -3,7 +3,7 @@ + - hosts: all + name: Setup for test running + tasks: +- - include_tasks: tasks/el_repo_setup.yml ++ - include_tasks: tasks/enable_epel.yml + + - name: Install dependencies + package: +diff --git a/tests/tests_vlan_mtu_initscripts.yml b/tests/tests_vlan_mtu_initscripts.yml +index dcd5d74..37770a9 100644 +--- a/tests/tests_vlan_mtu_initscripts.yml ++++ b/tests/tests_vlan_mtu_initscripts.yml +@@ -4,8 +4,6 @@ + - hosts: all + name: Run playbook 'playbooks/tests_vlan_mtu.yml' with initscripts as provider + tasks: +- - include_tasks: tasks/el_repo_setup.yml +- + - name: Set network provider to 'initscripts' + set_fact: + network_provider: initscripts +diff --git a/tests/tests_vlan_mtu_nm.yml b/tests/tests_vlan_mtu_nm.yml +index c38263c..f201de3 100644 +--- a/tests/tests_vlan_mtu_nm.yml ++++ b/tests/tests_vlan_mtu_nm.yml +@@ -5,8 +5,6 @@ + - hosts: all + name: Run playbook 'playbooks/tests_vlan_mtu.yml' with nm as provider + tasks: +- - include_tasks: tasks/el_repo_setup.yml +- + - name: Set network provider to 'nm' + set_fact: + network_provider: nm +diff --git a/tests/tests_wireless_nm.yml b/tests/tests_wireless_nm.yml +index 03b5ad6..86baf67 100644 +--- a/tests/tests_wireless_nm.yml ++++ b/tests/tests_wireless_nm.yml +@@ -5,8 +5,6 @@ + - hosts: all + name: Run playbook 'playbooks/tests_wireless.yml' with nm as provider + tasks: +- - include_tasks: tasks/el_repo_setup.yml +- + - name: Set network provider to 'nm' + set_fact: + network_provider: nm diff --git a/SOURCES/network-pr298.diff b/SOURCES/network-pr298.diff deleted file mode 100644 index 67f504b..0000000 --- a/SOURCES/network-pr298.diff +++ /dev/null @@ -1,524 +0,0 @@ -From 94ba2d701fa93bff69a7bfb1a033f27e53a17439 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Thu, 12 Nov 2020 21:42:01 +0800 -Subject: [PATCH] nm provider: Refactor the down action of network connection - -When deactivating a profile in libNM, we should: - - * Check `NM.ActionConnection` existence - * Check `NM.ActionConnection.props.state` not DEACTIVATED - * Use signal `state-changed` of `NM.ActionConnection`. - * Only invoke `NM.Client.deactivate_connection_async()` if not - in DEACTIVATING state. - * Ignore `NM.ManagerError.CONNECTIONNOTACTIVE` error. - -This patch also introduced a new class `NetworkManagerProvider` -in `module_utils/network_lsr/nm`: - - * Independent from Ansible but need to use absolute import due to - limitation of ansible 2.8. - * Provide sync function wrapping async calls of libNM. - * Use stable logging method of python. - * Only load this module when provider is nm. - -This patch also changed how logging is handling in -`Cmd_nm.run_action_down()` as initial step on isolate ansible log -mechanism from provider module. - -By moving provider codes to `module_utils` folder, we can eventually -simplify the bloated `library/network_connections.py`. - -Signed-off-by: Gris Ge ---- - library/network_connections.py | 146 ++++++------------ - module_utils/network_lsr/nm/__init__.py | 9 ++ - .../network_lsr/nm/active_connection.py | 125 +++++++++++++++ - module_utils/network_lsr/nm/client.py | 86 +++++++++++ - module_utils/network_lsr/nm/error.py | 5 + - module_utils/network_lsr/nm/provider.py | 29 ++++ - 6 files changed, 300 insertions(+), 100 deletions(-) - create mode 100644 module_utils/network_lsr/nm/__init__.py - create mode 100644 module_utils/network_lsr/nm/active_connection.py - create mode 100644 module_utils/network_lsr/nm/client.py - create mode 100644 module_utils/network_lsr/nm/error.py - create mode 100644 module_utils/network_lsr/nm/provider.py - -diff --git a/library/network_connections.py b/library/network_connections.py -index e8ee347..e693ab7 100644 ---- a/library/network_connections.py -+++ b/library/network_connections.py -@@ -11,6 +11,7 @@ import socket - import subprocess - import time - import traceback -+import logging - - # pylint: disable=import-error, no-name-in-module - from ansible.module_utils.basic import AnsibleModule -@@ -66,6 +67,17 @@ class LogLevel: - INFO = "info" - DEBUG = "debug" - -+ _LOGGING_LEVEL_MAP = { -+ logging.DEBUG: DEBUG, -+ logging.INFO: INFO, -+ logging.WARN: WARN, -+ logging.ERROR: ERROR, -+ } -+ -+ @staticmethod -+ def from_logging_level(logging_level): -+ return LogLevel._LOGGING_LEVEL_MAP.get(logging_level, LogLevel.ERROR) -+ - @staticmethod - def fmt(level): - return "<%-6s" % (str(level) + ">") -@@ -1386,61 +1398,6 @@ class NMUtil: - if failure_reason: - raise MyError("connection not activated: %s" % (failure_reason)) - -- def active_connection_deactivate(self, ac, timeout=10, wait_time=None): -- def deactivate_cb(client, result, cb_args): -- success = False -- try: -- success = client.deactivate_connection_finish(result) -- except Exception as e: -- if Util.error_is_cancelled(e): -- return -- cb_args["error"] = str(e) -- cb_args["success"] = success -- Util.GMainLoop().quit() -- -- cancellable = Util.create_cancellable() -- cb_args = {} -- self.nmclient.deactivate_connection_async( -- ac, cancellable, deactivate_cb, cb_args -- ) -- if not Util.GMainLoop_run(timeout): -- cancellable.cancel() -- raise MyError("failure to deactivate connection: %s" % (timeout)) -- if not cb_args.get("success", False): -- raise MyError( -- "failure to deactivate connection: %s" -- % (cb_args.get("error", "unknown error")) -- ) -- -- self.active_connection_deactivate_wait(ac, wait_time) -- return True -- -- def active_connection_deactivate_wait(self, ac, wait_time): -- -- if not wait_time: -- return -- -- NM = Util.NM() -- -- def check_deactivated(ac): -- return ac.get_state() >= NM.ActiveConnectionState.DEACTIVATED -- -- if not check_deactivated(ac): -- -- def check_deactivated_cb(): -- if check_deactivated(ac): -- Util.GMainLoop().quit() -- -- ac_id = ac.connect( -- "notify::state", lambda source, pspec: check_deactivated_cb() -- ) -- -- try: -- if not Util.GMainLoop_run(wait_time): -- raise MyError("connection not fully deactivated after timeout") -- finally: -- ac.handler_disconnect(ac_id) -- - def reapply(self, device, connection=None): - version_id = 0 - flags = 0 -@@ -1628,6 +1585,21 @@ class RunEnvironmentAnsible(RunEnvironment): - ############################################################################### - - -+class NmLogHandler(logging.Handler): -+ def __init__(self, log_func, idx): -+ self._log = log_func -+ self._idx = idx -+ super(NmLogHandler, self).__init__() -+ -+ def filter(self, record): -+ return True -+ -+ def emit(self, record): -+ self._log( -+ self._idx, LogLevel.from_logging_level(record.levelno), record.getMessage() -+ ) -+ -+ - class Cmd(object): - def __init__( - self, -@@ -1953,6 +1925,14 @@ class Cmd_nm(Cmd): - self._nmutil = None - self.validate_one_type = ArgValidator_ListConnections.VALIDATE_ONE_MODE_NM - self._checkpoint = None -+ # pylint: disable=import-error, no-name-in-module -+ from ansible.module_utils.network_lsr.nm import ( # noqa: E501 -+ NetworkManagerProvider, -+ ) -+ -+ # pylint: enable=import-error, no-name-in-module -+ -+ self._nm_provider = NetworkManagerProvider() - - @property - def nmutil(self): -@@ -2264,51 +2244,17 @@ class Cmd_nm(Cmd): - - def run_action_down(self, idx): - connection = self.connections[idx] -- -- cons = self.nmutil.connection_list(name=connection["name"]) -- changed = False -- if cons: -- seen = set() -- while True: -- ac = Util.first( -- self.nmutil.active_connection_list( -- connections=cons, black_list=seen -- ) -- ) -- if ac is None: -- break -- seen.add(ac) -- self.log_info( -- idx, "down connection %s: %s" % (connection["name"], ac.get_path()) -- ) -- changed = True -- self.connections_data_set_changed(idx) -- if self.check_mode == CheckMode.REAL_RUN: -- try: -- self.nmutil.active_connection_deactivate(ac) -- except MyError as e: -- self.log_error(idx, "down connection failed: %s" % (e)) -- -- wait_time = connection["wait"] -- if wait_time is None: -- wait_time = 10 -- -- try: -- self.nmutil.active_connection_deactivate_wait(ac, wait_time) -- except MyError as e: -- self.log_error( -- idx, "down connection failed while waiting: %s" % (e) -- ) -- -- cons = self.nmutil.connection_list(name=connection["name"]) -- if not changed: -- message = "down connection %s failed: connection not found" % ( -- connection["name"] -- ) -- if connection[PERSISTENT_STATE] == ABSENT_STATE: -- self.log_info(idx, message) -- else: -- self.log_error(idx, message) -+ logger = logging.getLogger() -+ log_handler = NmLogHandler(self.log, idx) -+ logger.addHandler(log_handler) -+ timeout = connection["wait"] -+ if self._nm_provider.deactivate_connection( -+ connection["name"], -+ 10 if timeout is None else timeout, -+ self.check_mode != CheckMode.REAL_RUN, -+ ): -+ self.connections_data_set_changed(idx) -+ logger.removeHandler(log_handler) - - - ############################################################################### -diff --git a/module_utils/network_lsr/nm/__init__.py b/module_utils/network_lsr/nm/__init__.py -new file mode 100644 -index 0000000..ce115f8 ---- /dev/null -+++ b/module_utils/network_lsr/nm/__init__.py -@@ -0,0 +1,9 @@ -+# Relative import is not support by ansible 2.8 yet -+# pylint: disable=import-error, no-name-in-module -+from ansible.module_utils.network_lsr.nm.provider import ( # noqa:E501 -+ NetworkManagerProvider, -+) -+ -+# pylint: enable=import-error, no-name-in-module -+ -+NetworkManagerProvider -diff --git a/module_utils/network_lsr/nm/active_connection.py b/module_utils/network_lsr/nm/active_connection.py -new file mode 100644 -index 0000000..451fa61 ---- /dev/null -+++ b/module_utils/network_lsr/nm/active_connection.py -@@ -0,0 +1,125 @@ -+# SPDX-License-Identifier: BSD-3-Clause -+ -+# Handle NM.ActiveConnection -+ -+import logging -+ -+# Relative import is not support by ansible 2.8 yet -+# pylint: disable=import-error, no-name-in-module -+from ansible.module_utils.network_lsr.nm.client import GLib # noqa:E501 -+from ansible.module_utils.network_lsr.nm.client import NM # noqa:E501 -+from ansible.module_utils.network_lsr.nm.client import get_mainloop # noqa:E501 -+from ansible.module_utils.network_lsr.nm.client import get_client # noqa:E501 -+from ansible.module_utils.network_lsr.nm.error import LsrNetworkNmError # noqa:E501 -+ -+# pylint: enable=import-error, no-name-in-module -+ -+ -+NM_AC_STATE_CHANGED_SIGNAL = "state-changed" -+ -+ -+def deactivate_active_connection(nm_ac, timeout, check_mode): -+ if not nm_ac or nm_ac.props.state == NM.ActiveConnectionState.DEACTIVATED: -+ logging.info("Connection is not active, no need to deactivate") -+ return False -+ if not check_mode: -+ main_loop = get_mainloop(timeout) -+ logging.debug( -+ "Deactivating {id} with timeout {timeout}".format( -+ id=nm_ac.get_id(), timeout=timeout -+ ) -+ ) -+ user_data = main_loop -+ handler_id = nm_ac.connect( -+ NM_AC_STATE_CHANGED_SIGNAL, _nm_ac_state_change_callback, user_data -+ ) -+ logging.debug( -+ "Registered {signal} on NM.ActiveConnection {id}".format( -+ signal=NM_AC_STATE_CHANGED_SIGNAL, id=nm_ac.get_id() -+ ) -+ ) -+ if nm_ac.props.state != NM.ActiveConnectionState.DEACTIVATING: -+ nm_client = get_client() -+ user_data = (main_loop, nm_ac, nm_ac.get_id(), handler_id) -+ nm_client.deactivate_connection_async( -+ nm_ac, -+ main_loop.cancellable, -+ _nm_ac_deactivate_call_back, -+ user_data, -+ ) -+ logging.debug("Deactivating NM.ActiveConnection {0}".format(nm_ac.get_id())) -+ main_loop.run() -+ return True -+ -+ -+def _nm_ac_state_change_callback(nm_ac, state, reason, user_data): -+ main_loop = user_data -+ if main_loop.is_cancelled: -+ return -+ logging.debug( -+ "Got NM.ActiveConnection state change: {id}: {state} {reason}".format( -+ id=nm_ac.get_id(), state=state, reason=reason -+ ) -+ ) -+ if nm_ac.props.state == NM.ActiveConnectionState.DEACTIVATED: -+ logging.debug("NM.ActiveConnection {0} is deactivated".format(nm_ac.get_id())) -+ main_loop.quit() -+ -+ -+def _nm_ac_deactivate_call_back(nm_client, result, user_data): -+ main_loop, nm_ac, nm_ac_id, handler_id = user_data -+ logging.debug("NM.ActiveConnection deactivating callback") -+ if main_loop.is_cancelled: -+ if nm_ac: -+ nm_ac.handler_disconnect(handler_id) -+ return -+ -+ try: -+ success = nm_client.deactivate_connection_finish(result) -+ except GLib.Error as e: -+ if e.matches(NM.ManagerError.quark(), NM.ManagerError.CONNECTIONNOTACTIVE): -+ logging.info( -+ "Connection is not active on {0}, no need to deactivate".format( -+ nm_ac_id -+ ) -+ ) -+ if nm_ac: -+ nm_ac.handler_disconnect(handler_id) -+ main_loop.quit() -+ return -+ else: -+ _deactivate_fail( -+ main_loop, -+ handler_id, -+ nm_ac, -+ "Failed to deactivate connection {id}, error={error}".format( -+ id=nm_ac_id, error=e -+ ), -+ ) -+ return -+ except Exception as e: -+ _deactivate_fail( -+ main_loop, -+ handler_id, -+ nm_ac, -+ "Failed to deactivate connection {id}, error={error}".format( -+ id=nm_ac_id, error=e -+ ), -+ ) -+ return -+ -+ if not success: -+ _deactivate_fail( -+ main_loop, -+ handler_id, -+ nm_ac, -+ "Failed to deactivate connection {0}, error='None " -+ "returned from deactivate_connection_finish()'".format(nm_ac_id), -+ ) -+ -+ -+def _deactivate_fail(main_loop, handler_id, nm_ac, msg): -+ if nm_ac: -+ nm_ac.handler_disconnect(handler_id) -+ logging.error(msg) -+ main_loop.fail(LsrNetworkNmError(msg)) -diff --git a/module_utils/network_lsr/nm/client.py b/module_utils/network_lsr/nm/client.py -new file mode 100644 -index 0000000..a3c4f98 ---- /dev/null -+++ b/module_utils/network_lsr/nm/client.py -@@ -0,0 +1,86 @@ -+# SPDX-License-Identifier: BSD-3-Clause -+ -+import logging -+ -+# Relative import is not support by ansible 2.8 yet -+# pylint: disable=import-error, no-name-in-module -+from ansible.module_utils.network_lsr.nm.error import LsrNetworkNmError # noqa:E501 -+ -+import gi -+ -+gi.require_version("NM", "1.0") -+ -+# It is required to state the NM version before importing it -+# But this break the flake8 rule: https://www.flake8rules.com/rules/E402.html -+# Use NOQA: E402 to suppress it. -+from gi.repository import NM # NOQA: E402 -+from gi.repository import GLib # NOQA: E402 -+from gi.repository import Gio # NOQA: E402 -+ -+# pylint: enable=import-error, no-name-in-module -+ -+NM -+GLib -+Gio -+ -+ -+def get_client(): -+ return NM.Client.new() -+ -+ -+class _NmMainLoop(object): -+ def __init__(self, timeout): -+ self._mainloop = GLib.MainLoop() -+ self._cancellable = Gio.Cancellable.new() -+ self._timeout = timeout -+ self._timeout_id = None -+ -+ def run(self): -+ logging.debug("NM mainloop running") -+ user_data = None -+ self._timeout_id = GLib.timeout_add( -+ int(self._timeout * 1000), -+ self._timeout_call_back, -+ user_data, -+ ) -+ logging.debug("Added timeout checker") -+ self._mainloop.run() -+ -+ def _timeout_call_back(self, _user_data): -+ logging.error("Timeout") -+ self.fail(LsrNetworkNmError("Timeout")) -+ -+ @property -+ def cancellable(self): -+ return self._cancellable -+ -+ @property -+ def is_cancelled(self): -+ if self._cancellable: -+ return self._cancellable.is_cancelled() -+ return True -+ -+ def _clean_up(self): -+ logging.debug("NM mainloop cleaning up") -+ if self._timeout_id: -+ logging.debug("Removing timeout checker") -+ GLib.source_remove(self._timeout_id) -+ self._timeout_id = None -+ if self._cancellable: -+ logging.debug("Canceling all pending tasks") -+ self._cancellable.cancel() -+ self._cancellable = None -+ self._mainloop = None -+ -+ def quit(self): -+ logging.debug("NM mainloop quiting") -+ self._mainloop.quit() -+ self._clean_up() -+ -+ def fail(self, exception): -+ self.quit() -+ raise exception -+ -+ -+def get_mainloop(timeout): -+ return _NmMainLoop(timeout) -diff --git a/module_utils/network_lsr/nm/error.py b/module_utils/network_lsr/nm/error.py -new file mode 100644 -index 0000000..42014ec ---- /dev/null -+++ b/module_utils/network_lsr/nm/error.py -@@ -0,0 +1,5 @@ -+# SPDX-License-Identifier: BSD-3-Clause -+ -+ -+class LsrNetworkNmError(Exception): -+ pass -diff --git a/module_utils/network_lsr/nm/provider.py b/module_utils/network_lsr/nm/provider.py -new file mode 100644 -index 0000000..cb703a4 ---- /dev/null -+++ b/module_utils/network_lsr/nm/provider.py -@@ -0,0 +1,29 @@ -+# SPDX-License-Identifier: BSD-3-Clause -+ -+import logging -+ -+# Relative import is not support by ansible 2.8 yet -+# pylint: disable=import-error, no-name-in-module -+from ansible.module_utils.network_lsr.nm.active_connection import ( # noqa:E501 -+ deactivate_active_connection, -+) -+from ansible.module_utils.network_lsr.nm.client import get_client # noqa:E501 -+ -+# pylint: enable=import-error, no-name-in-module -+ -+ -+class NetworkManagerProvider: -+ def deactivate_connection(self, connection_name, timeout, check_mode): -+ """ -+ Return True if changed. -+ """ -+ nm_client = get_client() -+ changed = False -+ for nm_ac in nm_client.get_active_connections(): -+ nm_profile = nm_ac.get_connection() -+ if nm_profile and nm_profile.get_id() == connection_name: -+ changed |= deactivate_active_connection(nm_ac, timeout, check_mode) -+ if not changed: -+ logging.info("No active connection for {0}".format(connection_name)) -+ -+ return changed --- -2.25.4 - diff --git a/SOURCES/network-tier1-tags.diff b/SOURCES/network-tier1-tags.diff index 803d4f1..76b813f 100644 --- a/SOURCES/network-tier1-tags.diff +++ b/SOURCES/network-tier1-tags.diff @@ -457,7 +457,7 @@ index 0000000..5690aed + register: etc_sysconfig_network_stat + ignore_errors: yes diff --git a/tests/tests_802_1x_nm.yml b/tests/tests_802_1x_nm.yml -index 3bd0719..77cf2d9 100644 +index 288cd5d..840958d 100644 --- a/tests/tests_802_1x_nm.yml +++ b/tests/tests_802_1x_nm.yml @@ -4,6 +4,8 @@ @@ -469,14 +469,14 @@ index 3bd0719..77cf2d9 100644 tasks: - name: Set network provider to 'nm' set_fact: -@@ -21,3 +23,5 @@ +@@ -17,3 +19,5 @@ - import_playbook: playbooks/tests_802_1x.yml when: - ansible_distribution_major_version != '6' + tags: + - tests::expfail diff --git a/tests/tests_802_1x_updated_nm.yml b/tests/tests_802_1x_updated_nm.yml -index 0d4c741..ca666a6 100644 +index bd335e4..4ebcaf9 100644 --- a/tests/tests_802_1x_updated_nm.yml +++ b/tests/tests_802_1x_updated_nm.yml @@ -4,6 +4,8 @@ @@ -488,7 +488,7 @@ index 0d4c741..ca666a6 100644 tasks: - name: Set network provider to 'nm' set_fact: -@@ -21,3 +23,5 @@ +@@ -17,3 +19,5 @@ - import_playbook: playbooks/tests_802_1x_updated.yml when: - ansible_distribution_major_version != '6' diff --git a/SOURCES/storage-partition-name.diff b/SOURCES/storage-partition-name.diff new file mode 100644 index 0000000..9a183e2 --- /dev/null +++ b/SOURCES/storage-partition-name.diff @@ -0,0 +1,30 @@ +diff --git a/library/blivet.py b/library/blivet.py +index 1f0473a..a03d88c 100644 +--- a/library/blivet.py ++++ b/library/blivet.py +@@ -316,7 +316,11 @@ + if self._device: + return + +- device = self._blivet.devicetree.resolve_device(self._get_device_id()) ++ device_id = self._get_device_id() ++ if device_id is None: ++ return ++ ++ device = self._blivet.devicetree.resolve_device(device_id) + if device is None: + return + +@@ -501,7 +501,11 @@ class BlivetPartitionVolume(BlivetVolume): + return self._device.raw_device.type == 'partition' + + def _get_device_id(self): +- return self._blivet_pool._disks[0].name + '1' ++ device_id = None ++ if self._blivet_pool._disks[0].partitioned and len(self._blivet_pool._disks[0].children) == 1: ++ device_id = self._blivet_pool._disks[0].children[0].name ++ ++ return device_id + + def _resize(self): + pass diff --git a/SPECS/rhel-system-roles.spec b/SPECS/rhel-system-roles.spec index c7494b1..f5791f2 100644 --- a/SPECS/rhel-system-roles.spec +++ b/SPECS/rhel-system-roles.spec @@ -1,3 +1,9 @@ +%if 0%{?rhel} && ! 0%{?epel} +%bcond_with ansible +%else +%bcond_without ansible +%endif + %if 0%{?rhel} Name: rhel-system-roles %else @@ -5,16 +11,54 @@ Name: linux-system-roles %endif Url: https://github.com/linux-system-roles/ Summary: Set of interfaces for unified system management -Version: 1.0 -Release: 24%{?dist} +Version: 1.0.0 +Release: 25%{?dist} #Group: Development/Libraries License: GPLv3+ and MIT and BSD %if 0%{?rhel} %global rolealtprefix linux-system-roles. +%global collection_namespace redhat +%global collection_name rhel_system_roles +%else +%global collection_namespace fedora +%global collection_name linux_system_roles %endif %global roleprefix %{name}. +%global collection_version %{version} + +# Helper macros originally from macros.ansible by Igor Raits +# Not available on RHEL, so we must define those macros locally here without using ansible-galaxy + +# Not used (yet). Could be made to point to AH in RHEL - but what about CentOS Stream? +#%%{!?ansible_collection_url:%%define ansible_collection_url() https://galaxy.ansible.com/%%{collection_namespace}/%%{collection_name}} + +%{!?ansible_collection_files:%define ansible_collection_files %{_datadir}/ansible/collections/ansible_collections/%{collection_namespace}/} + +%if %{with ansible} +BuildRequires: ansible >= 2.9.10 +Requires: ansible >= 2.9.10 +%endif + +%if %{undefined ansible_collection_build} +%if %{without ansible} +# Empty command. We don't have ansible-galaxy. +%define ansible_collection_build() : +%else +%define ansible_collection_build() ansible-galaxy collection build +%endif +%endif + +%if %{undefined ansible_collection_install} +%if %{without ansible} +# Simply copy everything instead of galaxy-installing the built artifact. +%define ansible_collection_install() mkdir -p %{buildroot}%{ansible_collection_files}; cp -a . %{buildroot}%{ansible_collection_files}/%{collection_name}/ +%else +%define ansible_collection_install() ansible-galaxy collection install -n -p %{buildroot}%{_datadir}/ansible/collections %{collection_namespace}-%{collection_name}-%{version}.tar.gz +%endif +%endif + # For each role, call either defcommit() or deftag(). The other macros # (%%id and %%shortid) can be then used in the same way in both cases. # This way the rest of the spec file des not need to know whether we are @@ -35,10 +79,6 @@ License: GPLv3+ and MIT and BSD %%global archiveurl%{1} %%{?forgeorg%{1}}%%{!?forgeorg%{1}:%%{url}}%%{repo%{1}}/archive/%%{ref%{1}}/%%{repo%{1}}-%%{ref%{1}}.tar.gz } -%defcommit 0 77596fdd976c6160d6152c200a5432c609725a14 -%global rolename0 kdump -#%%deftag 0 1.0.0 - #%%defcommit 1 43eec5668425d295dce3801216c19b1916df1f9b %global rolename1 postfix %deftag 1 0.1 @@ -51,7 +91,11 @@ License: GPLv3+ and MIT and BSD %global rolename3 timesync #%%deftag 3 1.0.0 -%defcommit 5 bf4501bb8770d3ef761e1684011c905f99a9752f +%defcommit 4 77596fdd976c6160d6152c200a5432c609725a14 +%global rolename4 kdump +#%%deftag 4 1.0.0 + +%defcommit 5 675c7e8073f33ead5143cd5fc11e332f18524317 %global rolename5 network #%%deftag 5 1.0.0 @@ -83,9 +127,9 @@ License: GPLv3+ and MIT and BSD %global rolename12 nbde_client %deftag 12 1.0.1 -#%%defcommit 13 fedef6e7844bb623bb54695a602137e332f5509f +%defcommit 13 19115b5f824141330861359a137d08ac32082502 %global rolename13 certificate -%deftag 13 1.0.1 +#%%deftag 13 1.0.1 %defcommit 14 76b2d5b0460dba22c5d290c1af96e4fdb3434cb9 %global rolename14 crypto_policies @@ -95,10 +139,12 @@ License: GPLv3+ and MIT and BSD %global rolename15 sshd %defcommit 15 e1de59b3c54e9d48a010eeca73755df339c7e628 -Source: %{archiveurl0} +%global mainid 627b7a83a2c5b2a3c1f775751c689ca40f5fb294 +Source: %{url}auto-maintenance/archive/%{mainid}/auto-maintenance-%{mainid}.tar.gz Source1: %{archiveurl1} Source2: %{archiveurl2} Source3: %{archiveurl3} +Source4: %{archiveurl4} Source5: %{archiveurl5} Source6: %{archiveurl6} Source7: %{archiveurl7} @@ -111,25 +157,27 @@ Source13: %{archiveurl13} Source14: %{archiveurl14} Source15: %{archiveurl15} -Source999: md2html.sh +Source998: collection_readme.sh Patch11: rhel-system-roles-postfix-pr5.diff Patch12: postfix-meta-el8.diff -Patch101: rhel-system-roles-kdump-pr22.diff - -Patch102: kdump-tier1-tags.diff -Patch103: kdump-meta-el8.diff -Patch104: kdump-fix-newline.diff Patch21: selinux-tier1-tags.diff Patch31: timesync-tier1-tags.diff +Patch41: rhel-system-roles-kdump-pr22.diff +Patch42: kdump-tier1-tags.diff +Patch43: kdump-meta-el8.diff +Patch44: kdump-fix-newline.diff + +Patch51: network-epel-minimal.diff Patch52: network-permissions.diff Patch53: network-tier1-tags.diff -Patch54: network-pr298.diff Patch55: network-disable-bondtests.diff +Patch62: storage-partition-name.diff + Patch151: sshd-example.diff BuildArch: noarch @@ -137,11 +185,20 @@ BuildArch: noarch BuildRequires: asciidoc BuildRequires: pandoc BuildRequires: highlight +BuildRequires: python3 +BuildRequires: python3-six +BuildRequires: python3dist(ruamel.yaml) Requires: python3-jmespath Obsoletes: rhel-system-roles-techpreview < 1.0-3 +%if %{undefined __ansible_provides} +Provides: ansible-collection(%{collection_namespace}.%{collection_name}) = %{collection_version} +%endif +# be compatible with the usual Fedora Provides: +Provides: ansible-collection-%{collection_namespace}-%{collection_name} = %{version}-%{release} + # We need to put %%description within the if block to avoid empty # lines showing up. %if 0%{?rhel} @@ -157,9 +214,9 @@ of Fedora, Red Hat Enterprise Linux & CentOS. %endif %prep -%setup -qc -a1 -a2 -a3 -a5 -a6 -a7 -a8 -a9 -a10 -a11 -a12 -a13 -a14 -a15 -for rolename_id in %{extractdir0} %{extractdir1} %{extractdir2} \ - %{extractdir3} %{extractdir5} %{extractdir6} \ +%setup -q -a1 -a2 -a3 -a4 -a5 -a6 -a7 -a8 -a9 -a10 -a11 -a12 -a13 -a14 -a15 -n %{getarchivedir 0} +for rolename_id in %{extractdir1} %{extractdir2} %{extractdir3} \ + %{extractdir4} %{extractdir5} %{extractdir6} \ %{extractdir7} %{extractdir8} %{extractdir9} \ %{extractdir10} %{extractdir11} %{extractdir12} \ %{extractdir13} %{extractdir14}; do @@ -172,12 +229,6 @@ done # how to do this inside the loop for all the roles? mv %{extractdir15} %{rolename15} -cd %{rolename0} -%patch101 -p1 -%patch102 -p1 -%patch103 -p1 -%patch104 -p1 -cd .. cd %{rolename1} %patch11 -p1 %patch12 -p1 @@ -188,38 +239,68 @@ cd .. cd %{rolename3} %patch31 -p1 cd .. +cd %{rolename4} +%patch41 -p1 +%patch42 -p1 +%patch43 -p1 +%patch44 -p1 +cd .. cd %{rolename5} +%patch51 -p1 %patch52 -p1 %patch53 -p1 -%patch54 -p1 %patch55 -p1 cd .. cd %{rolename6} -#%%patch61 -p1 +%patch62 -p1 cd .. cd %{rolename15} %patch151 -p1 sed -r -i -e "s/ansible-sshd/linux-system-roles.sshd/" tests/*.yml examples/*.yml README.md cd .. -# for some roles, the prefix change can be scripted - see below -%if "%{roleprefix}" != "linux-system-roles." -for rolename in %{rolename1} %{rolename2} \ - %{rolename3} %{rolename5} %{rolename6} \ +# Replacing "linux-system-roles.rolename" with "rhel-system-roles.rolename" in each role +# Removing symlinkx in tests/roles +for rolename in %{rolename1} %{rolename2} %{rolename3} \ + %{rolename4} %{rolename5} %{rolename6} \ %{rolename7} %{rolename8} %{rolename9} \ %{rolename10} %{rolename11} %{rolename12} \ %{rolename13} %{rolename14} %{rolename15}; do +%if "%{roleprefix}" != "linux-system-roles." find $rolename -type f -exec \ sed "s/linux-system-roles[.]${rolename}\\>/%{roleprefix}${rolename}/g" -i {} \; -done %endif + if [ -d ${rolename}/tests/roles ]; then + find ${rolename}/tests/roles -type l -exec rm {} \; + if [ -d ${rolename}/tests/roles/linux-system-roles.${rolename} ]; then + rm -r ${rolename}/tests/roles/linux-system-roles.${rolename} + fi + fi +done +rm %{rolename5}/tests/modules +rm %{rolename5}/tests/module_utils +rm %{rolename5}/tests/playbooks/roles + +# transform ambiguous #!/usr/bin/env python shebangs to python3 to stop brp-mangle-shebangs complaining +find -type f -executable -name '*.py' -exec \ + sed -i -r -e '1s@^(#! */usr/bin/env python)(\s|$)@#\13\2@' '{}' + + +cat > galaxy.yml < + - Rich Megginson +EOF %build -sh %{SOURCE999} \ -%{rolename0}/README.md \ +sh md2html.sh \ %{rolename1}/README.md \ %{rolename2}/README.md \ %{rolename3}/README.md \ +%{rolename4}/README.md \ %{rolename5}/README.md \ %{rolename6}/README.md \ %{rolename7}/README.md \ @@ -232,13 +313,34 @@ sh %{SOURCE999} \ %{rolename14}/README.md \ %{rolename15}/README.md +mkdir .collections +%if 0%{?rhel} +# Convert the upstream collection readme to the downstream one +%{SOURCE998} lsr_role2collection/collection_readme.md +%endif +for role in %{rolename1} %{rolename2} %{rolename3} \ + %{rolename4} %{rolename5} %{rolename6} \ + %{rolename7} %{rolename8} %{rolename9} \ + %{rolename10} %{rolename11} %{rolename12} \ + %{rolename13} %{rolename14} %{rolename15}; do + python3 lsr_role2collection.py --role "$role" --src-path "$role" \ + --src-owner %{name} --dest-path .collections \ + --readme lsr_role2collection/collection_readme.md \ + --namespace %{collection_namespace} --collection %{collection_name} +done + +cp -p galaxy.yml .collections/ansible_collections/%{collection_namespace}/%{collection_name} + +cd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/ +%ansible_collection_build + %install mkdir -p $RPM_BUILD_ROOT%{_datadir}/ansible/roles -cp -pR %{rolename0} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}%{rolename0} cp -pR %{rolename1} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}%{rolename1} cp -pR %{rolename2} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}%{rolename2} cp -pR %{rolename3} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}%{rolename3} +cp -pR %{rolename4} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}%{rolename4} cp -pR %{rolename5} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}%{rolename5} cp -pR %{rolename6} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}%{rolename6} cp -pR %{rolename7} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}%{rolename7} @@ -252,10 +354,10 @@ cp -pR %{rolename14} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix} cp -pR %{rolename15} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}%{rolename15} %if 0%{?rolealtprefix:1} -ln -s %{roleprefix}%{rolename0} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename0} ln -s %{roleprefix}%{rolename1} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename1} ln -s %{roleprefix}%{rolename2} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename2} ln -s %{roleprefix}%{rolename3} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename3} +ln -s %{roleprefix}%{rolename4} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename4} ln -s %{roleprefix}%{rolename5} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename5} ln -s %{roleprefix}%{rolename6} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename6} ln -s %{roleprefix}%{rolename7} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename7} @@ -347,6 +449,12 @@ mv $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}network/examples/wirele $RPM_BUILD_ROOT%{_pkgdocdir}/network/example-wireless_wpa_psk-playbook.yml mv $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}network/examples/remove+down_profile.yml \ $RPM_BUILD_ROOT%{_pkgdocdir}/network/example-remove+down_profile-playbook.yml +mv $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}network/examples/dummy_simple.yml \ + $RPM_BUILD_ROOT%{_pkgdocdir}/network/example-dummy_simple-playbook.yml +mv $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}network/examples/ethtool_coalesce.yml \ + $RPM_BUILD_ROOT%{_pkgdocdir}/network/example-ethtool_coalesce-playbook.yml +mv $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}network/examples/team_simple.yml \ + $RPM_BUILD_ROOT%{_pkgdocdir}/network/example-team_simple-playbook.yml # referenced in the configuring-openssh-servers-using-the-sshd-system-role documentation module # must be updated if changing the file path @@ -360,11 +468,10 @@ cp -p $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}storage/README.md \ rm $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}*/semaphore rm -r $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}*/molecule -rm $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}*/.travis.yml -rm $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}*/.ansible-lint -rm $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}network/.gitignore -rm $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}network/tests/.gitignore +rm -r $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}*/.[A-Za-z]* +rm $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}*/tests/.git* + rm $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}network/examples/roles rmdir $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}network/examples @@ -415,6 +522,10 @@ cp -p $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}sshd/README.md \ $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}sshd/LICENSE \ $RPM_BUILD_ROOT%{_pkgdocdir}/sshd +cd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/ +%ansible_collection_install + + %files %dir %{_datadir}/ansible %dir %{_datadir}/ansible/roles @@ -506,7 +617,27 @@ cp -p $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}sshd/README.md \ %license %{_datadir}/ansible/roles/%{roleprefix}crypto_policies/LICENSE %license %{_datadir}/ansible/roles/%{roleprefix}sshd/LICENSE +%{ansible_collection_files} + %changelog +* Tue Jan 26 2021 Pavel Cahyna - 1.0.0-25 +- Apply storage PR #153 to fix a problem with partition name on NVMe devices + Resolves: rhbz1865990 +- Remove symlinks to roles under tests +- Cleanup of role directories - remove files starting with . in roles' root + directories and Git files under tests. Resolves rhbz#1650550 +- Add collection support, make Version semver compatible: 1.0 -> 1.0.0 + Resolves rhbz#1893906 +- Autogenerate Automation-Hub README.md if building for RHEL +- Renumber sources, Source is now auto-maintenance since it is the root + of the source tree, kdump becomes Source4 (4 was originally firewall) +- Introduce bcond_with/without ansible, work on Fedora, RHEL and EPEL +- Rebase certificate role to include collection-related workarounds, + no change in behavior intended +- Rebase network role, includes collection-related workarounds +- Revert an invasive network change to enable EPEL (PR #335) and implement + a minimal version + * Fri Jan 15 2021 Pavel Cahyna - 1.0-24 - Apply PR #63 for kdump to fix a problem in test introduced by rebase