diff --git a/.gitignore b/.gitignore index 22841e5..6f55258 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,73 @@ SOURCES/vpn-1.5.3.tar.gz /vpn-1.5.3.tar.gz /community-general-6.4.0.tar.gz /rhc-1.1.1.tar.gz +/community-general-6.5.0.tar.gz +/auto-maintenance-40e904d40dcfb8b522c91e525b2a0da24f9ad7ea.tar.gz +/postfix-1.3.4.tar.gz +/selinux-1.5.7.tar.gz +/timesync-1.7.3.tar.gz +/kdump-1.2.7.tar.gz +/storage-1.9.7.tar.gz +/metrics-1.8.2.tar.gz +/tlog-1.2.12.tar.gz +/kernel_settings-1.1.13.tar.gz +/logging-1.11.6.tar.gz +/nbde_server-1.3.4.tar.gz +/certificate-1.1.10.tar.gz +/crypto_policies-1.2.8.tar.gz +/ssh-1.1.13.tar.gz +/ha_cluster-1.9.0.tar.gz +/vpn-1.5.4.tar.gz +/firewall-1.4.3.tar.gz +/podman-1.1.3.tar.gz +/ad_integration-1.0.3.tar.gz +/journald-1.0.1.tar.gz +/postgresql-1.0.0.tar.gz +/nbde_client-1.2.11.tar.gz +/ansible-sshd-v0.18.2.tar.gz +/postfix-1.3.5.tar.gz +/selinux-1.5.8.tar.gz +/timesync-1.7.4.tar.gz +/kdump-1.2.8.tar.gz +/network-1.11.3.tar.gz +/storage-1.9.8.tar.gz +/metrics-1.8.3.tar.gz +/tlog-1.2.13.tar.gz +/kernel_settings-1.1.14.tar.gz +/logging-1.11.7.tar.gz +/nbde_client-1.2.12.tar.gz +/crypto_policies-1.2.9.tar.gz +/ssh-1.1.14.tar.gz +/vpn-1.5.5.tar.gz +/firewall-1.4.4.tar.gz +/podman-1.1.4.tar.gz +/journald-1.0.2.tar.gz +/ansible-posix-1.5.2.tar.gz +/cockpit-1.4.4.tar.gz +/postgresql-1.0.1.tar.gz +/cockpit-1.4.5.tar.gz +/auto-maintenance-81f9d109236b6c46c229b196a4087424542f8b6d.tar.gz +/ad_integration-1.1.0.tar.gz +/postfix-1.3.6.tar.gz +/selinux-1.5.9.tar.gz +/timesync-1.7.5.tar.gz +/kdump-1.2.9.tar.gz +/metrics-1.8.4.tar.gz +/tlog-1.2.14.tar.gz +/kernel_settings-1.1.15.tar.gz +/nbde_server-1.3.5.tar.gz +/nbde_client-1.2.13.tar.gz +/certificate-1.1.11.tar.gz +/ssh-1.1.15.tar.gz +/ha_cluster-1.9.2.tar.gz +/vpn-1.5.6.tar.gz +/podman-1.1.5.tar.gz +/rhc-1.1.2.tar.gz +/journald-1.0.3.tar.gz +/postgresql-1.0.2.tar.gz +/community-general-6.6.0.tar.gz +/network-1.11.4.tar.gz +/ansible-sshd-v0.19.0.tar.gz +/auto-maintenance-3a0a698cb96e0fccf4d00b45e29414c28c1ab0a1.tar.gz +/auto-maintenance-f8932b3155a3cb7579a2b3c453578f7bee6bb837.tar.gz +/postgresql-1.0.3.tar.gz diff --git a/CHANGELOG.md b/CHANGELOG.md index 1974631..3d253f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,21 @@ Changelog ========= +[1.22.0-0.6] - 2023-05-04 +---------------------------- + +### New Features + +- [fingerprint in config files managed by roles](https://bugzilla.redhat.com/show_bug.cgi?id=2186910) +- [ha_cluster - Add possibility to load SBD watchdog kernel modules](https://bugzilla.redhat.com/show_bug.cgi?id=2190478) +- [ha_cluster - support for resource and operation defaults](https://bugzilla.redhat.com/show_bug.cgi?id=2190483) +- [postgresql - [RFE] system role for PostgreSQL management](https://bugzilla.redhat.com/show_bug.cgi?id=2151371) +- [rhc - [RFE] New role for Red Hat subscription management, insights management [rhel-8.9.0]](https://bugzilla.redhat.com/show_bug.cgi?id=2179016) + +### Bug Fixes + +- none + [1.21.1] - 2023-03-16 ---------------------------- diff --git a/ansible-packaging.inc b/ansible-packaging.inc new file mode 100644 index 0000000..7cdb972 --- /dev/null +++ b/ansible-packaging.inc @@ -0,0 +1,21 @@ +# Helper macros originally from macros.ansible by Igor Raits +# This file is for maintaining the compatibility with macros and other +# functionality (generators) provided by ansible-packaging on Fedora. + +Provides: ansible-collection(%{collection_namespace}.%{collection_name}) = %{collection_version} + +# ansible-galaxy is available by ansible-core on RHEL 8.6 and newer at buildtime. +%define ansible_collection_build() ansible-galaxy collection build +%define ansible_collection_install() ansible-galaxy collection install -n -p %{buildroot}%{_datadir}/ansible/collections %{collection_namespace}-%{collection_name}-%{version}.tar.gz + +%define ansible_roles_dir %{_datadir}/ansible/roles +%define ansible_collections_dir %{_datadir}/ansible/collections/ansible_collections + +# TODO: Officially deprecate this macro and add the following line to the macro +# def after the new approach has gotten more testing and adoption: +# %%{warn: %%{ansible_collection_files} is deprecated. Use %%files -f %%{ansible_collection_filelist} instead.} +%define ansible_collection_files %{shrink: +%{ansible_collections_dir}/%{collection_namespace}/ +} + +%define ansible_collection_filelist %{__ansible_builddir}/ansible_collection_files diff --git a/extrasources.inc b/extrasources.inc index d2d3175..dfe42af 100644 --- a/extrasources.inc +++ b/extrasources.inc @@ -1,9 +1,9 @@ -Source801: https://galaxy.ansible.com/download/ansible-posix-1.5.1.tar.gz -Source901: https://galaxy.ansible.com/download/community-general-6.4.0.tar.gz +Source801: https://galaxy.ansible.com/download/ansible-posix-1.5.2.tar.gz +Source901: https://galaxy.ansible.com/download/community-general-6.6.0.tar.gz Source902: https://galaxy.ansible.com/download/containers-podman-1.10.1.tar.gz -Provides: bundled(ansible-collection(ansible.posix)) = 1.5.1 -Provides: bundled(ansible-collection(community.general)) = 6.4.0 +Provides: bundled(ansible-collection(ansible.posix)) = 1.5.2 +Provides: bundled(ansible-collection(community.general)) = 6.6.0 Provides: bundled(ansible-collection(containers.podman)) = 1.10.1 Source996: CHANGELOG.rst diff --git a/redhat_subscription.py b/redhat_subscription.py deleted file mode 100644 index 2995e5a..0000000 --- a/redhat_subscription.py +++ /dev/null @@ -1,1187 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# Copyright (c) James Laska (jlaska@redhat.com) -# -# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) -# SPDX-License-Identifier: GPL-3.0-or-later - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - - -DOCUMENTATION = ''' ---- -module: redhat_subscription -short_description: Manage registration and subscriptions to RHSM using C(subscription-manager) -description: - - Manage registration and subscription to the Red Hat Subscription Management entitlement platform using the C(subscription-manager) command, - registering using D-Bus if possible. -author: "Barnaby Court (@barnabycourt)" -notes: - - In order to register a system, subscription-manager requires either a username and password, or an activationkey and an Organization ID. - - Since 2.5 values for I(server_hostname), I(server_insecure), I(rhsm_baseurl), - I(server_proxy_hostname), I(server_proxy_port), I(server_proxy_user) and - I(server_proxy_password) are no longer taken from the C(/etc/rhsm/rhsm.conf) - config file and default to None. -requirements: - - subscription-manager - - Optionally the C(dbus) Python library; this is usually included in the OS - as it is used by C(subscription-manager). -extends_documentation_fragment: - - community.general.attributes -attributes: - check_mode: - support: none - diff_mode: - support: none -options: - state: - description: - - whether to register and subscribe (C(present)), or unregister (C(absent)) a system - choices: [ "present", "absent" ] - default: "present" - type: str - username: - description: - - access.redhat.com or Red Hat Satellite or Katello username - type: str - password: - description: - - access.redhat.com or Red Hat Satellite or Katello password - type: str - token: - description: - - sso.redhat.com API access token. - type: str - version_added: 6.3.0 - server_hostname: - description: - - Specify an alternative Red Hat Subscription Management or Red Hat Satellite or Katello server - type: str - server_insecure: - description: - - Enable or disable https server certificate verification when connecting to C(server_hostname) - type: str - server_prefix: - description: - - Specify the prefix when registering to the Red Hat Subscription Management or Red Hat Satellite or Katello server. - type: str - version_added: 3.3.0 - server_port: - description: - - Specify the port when registering to the Red Hat Subscription Management or Red Hat Satellite or Katello server. - type: str - version_added: 3.3.0 - rhsm_baseurl: - description: - - Specify CDN baseurl - type: str - rhsm_repo_ca_cert: - description: - - Specify an alternative location for a CA certificate for CDN - type: str - server_proxy_hostname: - description: - - Specify an HTTP proxy hostname. - type: str - server_proxy_scheme: - description: - - Specify an HTTP proxy scheme, for example C(http) or C(https). - type: str - version_added: 6.2.0 - server_proxy_port: - description: - - Specify an HTTP proxy port. - type: str - server_proxy_user: - description: - - Specify a user for HTTP proxy with basic authentication - type: str - server_proxy_password: - description: - - Specify a password for HTTP proxy with basic authentication - type: str - auto_attach: - description: - - Upon successful registration, auto-consume available subscriptions - - Added in favor of deprecated autosubscribe in 2.5. - type: bool - aliases: [autosubscribe] - activationkey: - description: - - supply an activation key for use with registration - type: str - org_id: - description: - - Organization ID to use in conjunction with activationkey - type: str - environment: - description: - - Register with a specific environment in the destination org. Used with Red Hat Satellite or Katello - type: str - pool: - description: - - | - Specify a subscription pool name to consume. Regular expressions accepted. Use I(pool_ids) instead if - possible, as it is much faster. Mutually exclusive with I(pool_ids). - default: '^$' - type: str - pool_ids: - description: - - | - Specify subscription pool IDs to consume. Prefer over I(pool) when possible as it is much faster. - A pool ID may be specified as a C(string) - just the pool ID (ex. C(0123456789abcdef0123456789abcdef)), - or as a C(dict) with the pool ID as the key, and a quantity as the value (ex. - C(0123456789abcdef0123456789abcdef: 2). If the quantity is provided, it is used to consume multiple - entitlements from a pool (the pool must support this). Mutually exclusive with I(pool). - default: [] - type: list - elements: raw - consumer_type: - description: - - The type of unit to register, defaults to system - type: str - consumer_name: - description: - - Name of the system to register, defaults to the hostname - type: str - consumer_id: - description: - - | - References an existing consumer ID to resume using a previous registration - for this system. If the system's identity certificate is lost or corrupted, - this option allows it to resume using its previous identity and subscriptions. - The default is to not specify a consumer ID so a new ID is created. - type: str - force_register: - description: - - Register the system even if it is already registered - type: bool - default: false - release: - description: - - Set a release version - type: str - syspurpose: - description: - - Set syspurpose attributes in file C(/etc/rhsm/syspurpose/syspurpose.json) - and synchronize these attributes with RHSM server. Syspurpose attributes help attach - the most appropriate subscriptions to the system automatically. When C(syspurpose.json) file - already contains some attributes, then new attributes overwrite existing attributes. - When some attribute is not listed in the new list of attributes, the existing - attribute will be removed from C(syspurpose.json) file. Unknown attributes are ignored. - type: dict - suboptions: - usage: - description: Syspurpose attribute usage - type: str - role: - description: Syspurpose attribute role - type: str - service_level_agreement: - description: Syspurpose attribute service_level_agreement - type: str - addons: - description: Syspurpose attribute addons - type: list - elements: str - sync: - description: - - When this option is true, then syspurpose attributes are synchronized with - RHSM server immediately. When this option is false, then syspurpose attributes - will be synchronized with RHSM server by rhsmcertd daemon. - type: bool - default: false -''' - -EXAMPLES = ''' -- name: Register as user (joe_user) with password (somepass) and auto-subscribe to available content. - community.general.redhat_subscription: - state: present - username: joe_user - password: somepass - auto_attach: true - -- name: Same as above but subscribe to a specific pool by ID. - community.general.redhat_subscription: - state: present - username: joe_user - password: somepass - pool_ids: 0123456789abcdef0123456789abcdef - -- name: Register and subscribe to multiple pools. - community.general.redhat_subscription: - state: present - username: joe_user - password: somepass - pool_ids: - - 0123456789abcdef0123456789abcdef - - 1123456789abcdef0123456789abcdef - -- name: Same as above but consume multiple entitlements. - community.general.redhat_subscription: - state: present - username: joe_user - password: somepass - pool_ids: - - 0123456789abcdef0123456789abcdef: 2 - - 1123456789abcdef0123456789abcdef: 4 - -- name: Register and pull existing system data. - community.general.redhat_subscription: - state: present - username: joe_user - password: somepass - consumer_id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - -- name: Register with activationkey and consume subscriptions matching Red Hat Enterprise Server or Red Hat Virtualization - community.general.redhat_subscription: - state: present - activationkey: 1-222333444 - org_id: 222333444 - pool: '^(Red Hat Enterprise Server|Red Hat Virtualization)$' - -- name: Update the consumed subscriptions from the previous example (remove Red Hat Virtualization subscription) - community.general.redhat_subscription: - state: present - activationkey: 1-222333444 - org_id: 222333444 - pool: '^Red Hat Enterprise Server$' - -- name: Register as user credentials into given environment (against Red Hat Satellite or Katello), and auto-subscribe. - community.general.redhat_subscription: - state: present - username: joe_user - password: somepass - environment: Library - auto_attach: true - -- name: Register as user (joe_user) with password (somepass) and a specific release - community.general.redhat_subscription: - state: present - username: joe_user - password: somepass - release: 7.4 - -- name: Register as user (joe_user) with password (somepass), set syspurpose attributes and synchronize them with server - community.general.redhat_subscription: - state: present - username: joe_user - password: somepass - auto_attach: true - syspurpose: - usage: "Production" - role: "Red Hat Enterprise Server" - service_level_agreement: "Premium" - addons: - - addon1 - - addon2 - sync: true -''' - -RETURN = ''' -subscribed_pool_ids: - description: List of pool IDs to which system is now subscribed - returned: success - type: dict - sample: { - "8a85f9815ab905d3015ab928c7005de4": "1" - } -''' - -from os.path import isfile -from os import unlink -import re -import shutil -import tempfile -import json - -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.common.text.converters import to_native -from ansible.module_utils.six.moves import configparser -from ansible.module_utils import distro - - -SUBMAN_CMD = None - - -class RegistrationBase(object): - - REDHAT_REPO = "/etc/yum.repos.d/redhat.repo" - - def __init__(self, module, username=None, password=None, token=None): - self.module = module - self.username = username - self.password = password - self.token = token - - def configure(self): - raise NotImplementedError("Must be implemented by a sub-class") - - def enable(self): - # Remove any existing redhat.repo - if isfile(self.REDHAT_REPO): - unlink(self.REDHAT_REPO) - - def register(self): - raise NotImplementedError("Must be implemented by a sub-class") - - def unregister(self): - raise NotImplementedError("Must be implemented by a sub-class") - - def unsubscribe(self): - raise NotImplementedError("Must be implemented by a sub-class") - - def update_plugin_conf(self, plugin, enabled=True): - plugin_conf = '/etc/yum/pluginconf.d/%s.conf' % plugin - - if isfile(plugin_conf): - tmpfd, tmpfile = tempfile.mkstemp() - shutil.copy2(plugin_conf, tmpfile) - cfg = configparser.ConfigParser() - cfg.read([tmpfile]) - - if enabled: - cfg.set('main', 'enabled', '1') - else: - cfg.set('main', 'enabled', '0') - - fd = open(tmpfile, 'w+') - cfg.write(fd) - fd.close() - self.module.atomic_move(tmpfile, plugin_conf) - - def subscribe(self, **kwargs): - raise NotImplementedError("Must be implemented by a sub-class") - - -class Rhsm(RegistrationBase): - def __init__(self, module, username=None, password=None, token=None): - RegistrationBase.__init__(self, module, username, password, token) - self.module = module - - def enable(self): - ''' - Enable the system to receive updates from subscription-manager. - This involves updating affected yum plugins and removing any - conflicting yum repositories. - ''' - RegistrationBase.enable(self) - self.update_plugin_conf('rhnplugin', False) - self.update_plugin_conf('subscription-manager', True) - - def configure(self, **kwargs): - ''' - Configure the system as directed for registration with RHSM - Raises: - * Exception - if error occurs while running command - ''' - - args = [SUBMAN_CMD, 'config'] - - # Pass supplied **kwargs as parameters to subscription-manager. Ignore - # non-configuration parameters and replace '_' with '.'. For example, - # 'server_hostname' becomes '--server.hostname'. - options = [] - for k, v in sorted(kwargs.items()): - if re.search(r'^(server|rhsm)_', k) and v is not None: - options.append('--%s=%s' % (k.replace('_', '.', 1), v)) - - # When there is nothing to configure, then it is not necessary - # to run config command, because it only returns current - # content of current configuration file - if len(options) == 0: - return - - args.extend(options) - - self.module.run_command(args, check_rc=True) - - @property - def is_registered(self): - ''' - Determine whether the current system - Returns: - * Boolean - whether the current system is currently registered to - RHSM. - ''' - - args = [SUBMAN_CMD, 'identity'] - rc, stdout, stderr = self.module.run_command(args, check_rc=False) - if rc == 0: - return True - else: - return False - - def _can_connect_to_dbus(self): - """ - Checks whether it is possible to connect to the system D-Bus bus. - - :returns: bool -- whether it is possible to connect to the system D-Bus bus. - """ - - try: - # Technically speaking, subscription-manager uses dbus-python - # as D-Bus library, so this ought to work; better be safe than - # sorry, I guess... - import dbus - except ImportError: - self.module.debug('dbus Python module not available, will use CLI') - return False - - try: - bus = dbus.SystemBus() - msg = dbus.lowlevel.SignalMessage('/', 'com.example', 'test') - bus.send_message(msg) - bus.flush() - - except dbus.exceptions.DBusException as e: - self.module.debug('Failed to connect to system D-Bus bus, will use CLI: %s' % e) - return False - - self.module.debug('Verified system D-Bus bus as usable') - return True - - def register(self, username, password, token, auto_attach, activationkey, org_id, - consumer_type, consumer_name, consumer_id, force_register, environment, - release): - ''' - Register the current system to the provided RHSM or Red Hat Satellite - or Katello server - - Raises: - * Exception - if any error occurs during the registration - ''' - # There is no support for token-based registration in the D-Bus API - # of rhsm, so always use the CLI in that case. - if not token and self._can_connect_to_dbus(): - self._register_using_dbus(username, password, auto_attach, - activationkey, org_id, consumer_type, - consumer_name, consumer_id, - force_register, environment, release) - return - self._register_using_cli(username, password, token, auto_attach, - activationkey, org_id, consumer_type, - consumer_name, consumer_id, - force_register, environment, release) - - def _register_using_cli(self, username, password, token, auto_attach, - activationkey, org_id, consumer_type, consumer_name, - consumer_id, force_register, environment, release): - ''' - Register using the 'subscription-manager' command - - Raises: - * Exception - if error occurs while running command - ''' - args = [SUBMAN_CMD, 'register'] - - # Generate command arguments - if force_register: - args.extend(['--force']) - - if org_id: - args.extend(['--org', org_id]) - - if auto_attach: - args.append('--auto-attach') - - if consumer_type: - args.extend(['--type', consumer_type]) - - if consumer_name: - args.extend(['--name', consumer_name]) - - if consumer_id: - args.extend(['--consumerid', consumer_id]) - - if environment: - args.extend(['--environment', environment]) - - if activationkey: - args.extend(['--activationkey', activationkey]) - elif token: - args.extend(['--token', token]) - else: - if username: - args.extend(['--username', username]) - if password: - args.extend(['--password', password]) - - if release: - args.extend(['--release', release]) - - rc, stderr, stdout = self.module.run_command(args, check_rc=True, expand_user_and_vars=False) - - def _register_using_dbus(self, username, password, auto_attach, - activationkey, org_id, consumer_type, consumer_name, - consumer_id, force_register, environment, release): - ''' - Register using D-Bus (connecting to the rhsm service) - - Raises: - * Exception - if error occurs during the D-Bus communication - ''' - import dbus - - SUBSCRIPTION_MANAGER_LOCALE = 'C' - # Seconds to wait for Registration to complete over DBus; - # 10 minutes should be a pretty generous timeout. - REGISTRATION_TIMEOUT = 600 - - def str2int(s, default=0): - try: - return int(s) - except ValueError: - return default - - distro_id = distro.id() - distro_version = tuple(str2int(p) for p in distro.version_parts()) - - # Stop the rhsm service when using systemd (which means Fedora or - # RHEL 7+): this is because the service may not use new configuration bits - # - with subscription-manager < 1.26.5-1 (in RHEL < 8.2); - # fixed later by https://github.com/candlepin/subscription-manager/pull/2175 - # - sporadically: https://bugzilla.redhat.com/show_bug.cgi?id=2049296 - if distro_id == 'fedora' or distro_version[0] >= 7: - cmd = ['systemctl', 'stop', 'rhsm'] - self.module.run_command(cmd, check_rc=True, expand_user_and_vars=False) - - # While there is a 'force' options for the registration, it is actually - # not implemented (and thus it does not work) - # - in RHEL 7 and earlier - # - in RHEL 8 before 8.8: https://bugzilla.redhat.com/show_bug.cgi?id=2118486 - # - in RHEL 9 before 9.2: https://bugzilla.redhat.com/show_bug.cgi?id=2121350 - # Hence, use it only when implemented, manually unregistering otherwise. - # Match it on RHEL, since we know about it; other distributions - # will need their own logic. - dbus_force_option_works = False - if (distro_id == 'rhel' and - ((distro_version[0] == 8 and distro_version[1] >= 8) or - (distro_version[0] == 9 and distro_version[1] >= 2) or - distro_version[0] > 9)): - dbus_force_option_works = True - - if force_register and not dbus_force_option_works: - self.unregister() - - register_opts = {} - if consumer_type: - register_opts['consumer_type'] = consumer_type - if consumer_name: - register_opts['name'] = consumer_name - if consumer_id: - register_opts['consumerid'] = consumer_id - if environment: - # The option for environments used to be 'environment' in versions - # of RHEL before 8.6, and then it changed to 'environments'; since - # the Register*() D-Bus functions reject unknown options, we have - # to pass the right option depending on the version -- funky. - environment_key = 'environment' - if distro_id == 'fedora' or \ - (distro_id == 'rhel' and - ((distro_version[0] == 8 and distro_version[1] >= 6) or - distro_version[0] >= 9)): - environment_key = 'environments' - register_opts[environment_key] = environment - if force_register and dbus_force_option_works: - register_opts['force'] = True - # Wrap it as proper D-Bus dict - register_opts = dbus.Dictionary(register_opts, signature='sv', variant_level=1) - - connection_opts = {} - # Wrap it as proper D-Bus dict - connection_opts = dbus.Dictionary(connection_opts, signature='sv', variant_level=1) - - bus = dbus.SystemBus() - register_server = bus.get_object('com.redhat.RHSM1', - '/com/redhat/RHSM1/RegisterServer') - address = register_server.Start( - SUBSCRIPTION_MANAGER_LOCALE, - dbus_interface='com.redhat.RHSM1.RegisterServer', - ) - - try: - # Use the private bus to register the system - self.module.debug('Connecting to the private DBus') - private_bus = dbus.connection.Connection(address) - - try: - if activationkey: - args = ( - org_id, - [activationkey], - register_opts, - connection_opts, - SUBSCRIPTION_MANAGER_LOCALE, - ) - private_bus.call_blocking( - 'com.redhat.RHSM1', - '/com/redhat/RHSM1/Register', - 'com.redhat.RHSM1.Register', - 'RegisterWithActivationKeys', - 'sasa{sv}a{sv}s', - args, - timeout=REGISTRATION_TIMEOUT, - ) - else: - args = ( - org_id or '', - username, - password, - register_opts, - connection_opts, - SUBSCRIPTION_MANAGER_LOCALE, - ) - private_bus.call_blocking( - 'com.redhat.RHSM1', - '/com/redhat/RHSM1/Register', - 'com.redhat.RHSM1.Register', - 'Register', - 'sssa{sv}a{sv}s', - args, - timeout=REGISTRATION_TIMEOUT, - ) - - except dbus.exceptions.DBusException as e: - # Sometimes we get NoReply but the registration has succeeded. - # Check the registration status before deciding if this is an error. - if e.get_dbus_name() == 'org.freedesktop.DBus.Error.NoReply': - if not self.is_registered(): - # Host is not registered so re-raise the error - raise - else: - raise - # Host was registered so continue - finally: - # Always shut down the private bus - self.module.debug('Shutting down private DBus instance') - register_server.Stop( - SUBSCRIPTION_MANAGER_LOCALE, - dbus_interface='com.redhat.RHSM1.RegisterServer', - ) - - # Make sure to refresh all the local data: this will fetch all the - # certificates, update redhat.repo, etc. - self.module.run_command([SUBMAN_CMD, 'refresh'], - check_rc=True, expand_user_and_vars=False) - - if auto_attach: - args = [SUBMAN_CMD, 'attach', '--auto'] - self.module.run_command(args, check_rc=True, expand_user_and_vars=False) - - # There is no support for setting the release via D-Bus, so invoke - # the CLI for this. - if release: - args = [SUBMAN_CMD, 'release', '--set', release] - self.module.run_command(args, check_rc=True, expand_user_and_vars=False) - - def unsubscribe(self, serials=None): - ''' - Unsubscribe a system from subscribed channels - Args: - serials(list or None): list of serials to unsubscribe. If - serials is none or an empty list, then - all subscribed channels will be removed. - Raises: - * Exception - if error occurs while running command - ''' - items = [] - if serials is not None and serials: - items = ["--serial=%s" % s for s in serials] - if serials is None: - items = ["--all"] - - if items: - args = [SUBMAN_CMD, 'remove'] + items - rc, stderr, stdout = self.module.run_command(args, check_rc=True) - return serials - - def unregister(self): - ''' - Unregister a currently registered system - Raises: - * Exception - if error occurs while running command - ''' - args = [SUBMAN_CMD, 'unregister'] - rc, stderr, stdout = self.module.run_command(args, check_rc=True) - self.update_plugin_conf('rhnplugin', False) - self.update_plugin_conf('subscription-manager', False) - - def subscribe(self, regexp): - ''' - Subscribe current system to available pools matching the specified - regular expression. It matches regexp against available pool ids first. - If any pool ids match, subscribe to those pools and return. - - If no pool ids match, then match regexp against available pool product - names. Note this can still easily match many many pools. Then subscribe - to those pools. - - Since a pool id is a more specific match, we only fallback to matching - against names if we didn't match pool ids. - - Raises: - * Exception - if error occurs while running command - ''' - # See https://github.com/ansible/ansible/issues/19466 - - # subscribe to pools whose pool id matches regexp (and only the pool id) - subscribed_pool_ids = self.subscribe_pool(regexp) - - # If we found any matches, we are done - # Don't attempt to match pools by product name - if subscribed_pool_ids: - return subscribed_pool_ids - - # We didn't match any pool ids. - # Now try subscribing to pools based on product name match - # Note: This can match lots of product names. - subscribed_by_product_pool_ids = self.subscribe_product(regexp) - if subscribed_by_product_pool_ids: - return subscribed_by_product_pool_ids - - # no matches - return [] - - def subscribe_by_pool_ids(self, pool_ids): - """ - Try to subscribe to the list of pool IDs - """ - available_pools = RhsmPools(self.module) - - available_pool_ids = [p.get_pool_id() for p in available_pools] - - for pool_id, quantity in sorted(pool_ids.items()): - if pool_id in available_pool_ids: - args = [SUBMAN_CMD, 'attach', '--pool', pool_id] - if quantity is not None: - args.extend(['--quantity', to_native(quantity)]) - rc, stderr, stdout = self.module.run_command(args, check_rc=True) - else: - self.module.fail_json(msg='Pool ID: %s not in list of available pools' % pool_id) - return pool_ids - - def subscribe_pool(self, regexp): - ''' - Subscribe current system to available pools matching the specified - regular expression - Raises: - * Exception - if error occurs while running command - ''' - - # Available pools ready for subscription - available_pools = RhsmPools(self.module) - - subscribed_pool_ids = [] - for pool in available_pools.filter_pools(regexp): - pool.subscribe() - subscribed_pool_ids.append(pool.get_pool_id()) - return subscribed_pool_ids - - def subscribe_product(self, regexp): - ''' - Subscribe current system to available pools matching the specified - regular expression - Raises: - * Exception - if error occurs while running command - ''' - - # Available pools ready for subscription - available_pools = RhsmPools(self.module) - - subscribed_pool_ids = [] - for pool in available_pools.filter_products(regexp): - pool.subscribe() - subscribed_pool_ids.append(pool.get_pool_id()) - return subscribed_pool_ids - - def update_subscriptions(self, regexp): - changed = False - consumed_pools = RhsmPools(self.module, consumed=True) - pool_ids_to_keep = [p.get_pool_id() for p in consumed_pools.filter_pools(regexp)] - pool_ids_to_keep.extend([p.get_pool_id() for p in consumed_pools.filter_products(regexp)]) - - serials_to_remove = [p.Serial for p in consumed_pools if p.get_pool_id() not in pool_ids_to_keep] - serials = self.unsubscribe(serials=serials_to_remove) - - subscribed_pool_ids = self.subscribe(regexp) - - if subscribed_pool_ids or serials: - changed = True - return {'changed': changed, 'subscribed_pool_ids': subscribed_pool_ids, - 'unsubscribed_serials': serials} - - def update_subscriptions_by_pool_ids(self, pool_ids): - changed = False - consumed_pools = RhsmPools(self.module, consumed=True) - - existing_pools = {} - serials_to_remove = [] - for p in consumed_pools: - pool_id = p.get_pool_id() - quantity_used = p.get_quantity_used() - existing_pools[pool_id] = quantity_used - - quantity = pool_ids.get(pool_id, 0) - if quantity is not None and quantity != quantity_used: - serials_to_remove.append(p.Serial) - - serials = self.unsubscribe(serials=serials_to_remove) - - missing_pools = {} - for pool_id, quantity in sorted(pool_ids.items()): - quantity_used = existing_pools.get(pool_id, 0) - if quantity is None and quantity_used == 0 or quantity not in (None, 0, quantity_used): - missing_pools[pool_id] = quantity - - self.subscribe_by_pool_ids(missing_pools) - - if missing_pools or serials: - changed = True - return {'changed': changed, 'subscribed_pool_ids': list(missing_pools.keys()), - 'unsubscribed_serials': serials} - - def sync_syspurpose(self): - """ - Try to synchronize syspurpose attributes with server - """ - args = [SUBMAN_CMD, 'status'] - rc, stdout, stderr = self.module.run_command(args, check_rc=False) - - -class RhsmPool(object): - ''' - Convenience class for housing subscription information - ''' - - def __init__(self, module, **kwargs): - self.module = module - for k, v in kwargs.items(): - setattr(self, k, v) - - def __str__(self): - return str(self.__getattribute__('_name')) - - def get_pool_id(self): - return getattr(self, 'PoolId', getattr(self, 'PoolID')) - - def get_quantity_used(self): - return int(getattr(self, 'QuantityUsed')) - - def subscribe(self): - args = "subscription-manager attach --pool %s" % self.get_pool_id() - rc, stdout, stderr = self.module.run_command(args, check_rc=True) - if rc == 0: - return True - else: - return False - - -class RhsmPools(object): - """ - This class is used for manipulating pools subscriptions with RHSM - """ - - def __init__(self, module, consumed=False): - self.module = module - self.products = self._load_product_list(consumed) - - def __iter__(self): - return self.products.__iter__() - - def _load_product_list(self, consumed=False): - """ - Loads list of all available or consumed pools for system in data structure - - Args: - consumed(bool): if True list consumed pools, else list available pools (default False) - """ - args = "subscription-manager list" - if consumed: - args += " --consumed" - else: - args += " --available" - lang_env = dict(LANG='C', LC_ALL='C', LC_MESSAGES='C') - rc, stdout, stderr = self.module.run_command(args, check_rc=True, environ_update=lang_env) - - products = [] - for line in stdout.split('\n'): - # Remove leading+trailing whitespace - line = line.strip() - # An empty line implies the end of a output group - if len(line) == 0: - continue - # If a colon ':' is found, parse - elif ':' in line: - (key, value) = line.split(':', 1) - key = key.strip().replace(" ", "") # To unify - value = value.strip() - if key in ['ProductName', 'SubscriptionName']: - # Remember the name for later processing - products.append(RhsmPool(self.module, _name=value, key=value)) - elif products: - # Associate value with most recently recorded product - products[-1].__setattr__(key, value) - # FIXME - log some warning? - # else: - # warnings.warn("Unhandled subscription key/value: %s/%s" % (key,value)) - return products - - def filter_pools(self, regexp='^$'): - ''' - Return a list of RhsmPools whose pool id matches the provided regular expression - ''' - r = re.compile(regexp) - for product in self.products: - if r.search(product.get_pool_id()): - yield product - - def filter_products(self, regexp='^$'): - ''' - Return a list of RhsmPools whose product name matches the provided regular expression - ''' - r = re.compile(regexp) - for product in self.products: - if r.search(product._name): - yield product - - -class SysPurpose(object): - """ - This class is used for reading and writing to syspurpose.json file - """ - - SYSPURPOSE_FILE_PATH = "/etc/rhsm/syspurpose/syspurpose.json" - - ALLOWED_ATTRIBUTES = ['role', 'usage', 'service_level_agreement', 'addons'] - - def __init__(self, path=None): - """ - Initialize class used for reading syspurpose json file - """ - self.path = path or self.SYSPURPOSE_FILE_PATH - - def update_syspurpose(self, new_syspurpose): - """ - Try to update current syspurpose with new attributes from new_syspurpose - """ - syspurpose = {} - syspurpose_changed = False - for key, value in new_syspurpose.items(): - if key in self.ALLOWED_ATTRIBUTES: - if value is not None: - syspurpose[key] = value - elif key == 'sync': - pass - else: - raise KeyError("Attribute: %s not in list of allowed attributes: %s" % - (key, self.ALLOWED_ATTRIBUTES)) - current_syspurpose = self._read_syspurpose() - if current_syspurpose != syspurpose: - syspurpose_changed = True - # Update current syspurpose with new values - current_syspurpose.update(syspurpose) - # When some key is not listed in new syspurpose, then delete it from current syspurpose - # and ignore custom attributes created by user (e.g. "foo": "bar") - for key in list(current_syspurpose): - if key in self.ALLOWED_ATTRIBUTES and key not in syspurpose: - del current_syspurpose[key] - self._write_syspurpose(current_syspurpose) - return syspurpose_changed - - def _write_syspurpose(self, new_syspurpose): - """ - This function tries to update current new_syspurpose attributes to - json file. - """ - with open(self.path, "w") as fp: - fp.write(json.dumps(new_syspurpose, indent=2, ensure_ascii=False, sort_keys=True)) - - def _read_syspurpose(self): - """ - Read current syspurpuse from json file. - """ - current_syspurpose = {} - try: - with open(self.path, "r") as fp: - content = fp.read() - except IOError: - pass - else: - current_syspurpose = json.loads(content) - return current_syspurpose - - -def main(): - - # Load RHSM configuration from file - rhsm = Rhsm(None) - - # Note: the default values for parameters are: - # 'type': 'str', 'default': None, 'required': False - # So there is no need to repeat these values for each parameter. - module = AnsibleModule( - argument_spec={ - 'state': {'default': 'present', 'choices': ['present', 'absent']}, - 'username': {}, - 'password': {'no_log': True}, - 'token': {'no_log': True}, - 'server_hostname': {}, - 'server_insecure': {}, - 'server_prefix': {}, - 'server_port': {}, - 'rhsm_baseurl': {}, - 'rhsm_repo_ca_cert': {}, - 'auto_attach': {'aliases': ['autosubscribe'], 'type': 'bool'}, - 'activationkey': {'no_log': True}, - 'org_id': {}, - 'environment': {}, - 'pool': {'default': '^$'}, - 'pool_ids': {'default': [], 'type': 'list', 'elements': 'raw'}, - 'consumer_type': {}, - 'consumer_name': {}, - 'consumer_id': {}, - 'force_register': {'default': False, 'type': 'bool'}, - 'server_proxy_hostname': {}, - 'server_proxy_scheme': {}, - 'server_proxy_port': {}, - 'server_proxy_user': {}, - 'server_proxy_password': {'no_log': True}, - 'release': {}, - 'syspurpose': { - 'type': 'dict', - 'options': { - 'role': {}, - 'usage': {}, - 'service_level_agreement': {}, - 'addons': {'type': 'list', 'elements': 'str'}, - 'sync': {'type': 'bool', 'default': False} - } - } - }, - required_together=[['username', 'password'], - ['server_proxy_hostname', 'server_proxy_port'], - ['server_proxy_user', 'server_proxy_password']], - mutually_exclusive=[['activationkey', 'username'], - ['activationkey', 'token'], - ['token', 'username'], - ['activationkey', 'consumer_id'], - ['activationkey', 'environment'], - ['activationkey', 'auto_attach'], - ['pool', 'pool_ids']], - required_if=[['state', 'present', ['username', 'activationkey', 'token'], True]], - ) - - rhsm.module = module - state = module.params['state'] - username = module.params['username'] - password = module.params['password'] - token = module.params['token'] - server_hostname = module.params['server_hostname'] - server_insecure = module.params['server_insecure'] - server_prefix = module.params['server_prefix'] - server_port = module.params['server_port'] - rhsm_baseurl = module.params['rhsm_baseurl'] - rhsm_repo_ca_cert = module.params['rhsm_repo_ca_cert'] - auto_attach = module.params['auto_attach'] - activationkey = module.params['activationkey'] - org_id = module.params['org_id'] - if activationkey and not org_id: - module.fail_json(msg='org_id is required when using activationkey') - environment = module.params['environment'] - pool = module.params['pool'] - pool_ids = {} - for value in module.params['pool_ids']: - if isinstance(value, dict): - if len(value) != 1: - module.fail_json(msg='Unable to parse pool_ids option.') - pool_id, quantity = list(value.items())[0] - else: - pool_id, quantity = value, None - pool_ids[pool_id] = quantity - consumer_type = module.params["consumer_type"] - consumer_name = module.params["consumer_name"] - consumer_id = module.params["consumer_id"] - force_register = module.params["force_register"] - server_proxy_hostname = module.params['server_proxy_hostname'] - server_proxy_port = module.params['server_proxy_port'] - server_proxy_user = module.params['server_proxy_user'] - server_proxy_password = module.params['server_proxy_password'] - release = module.params['release'] - syspurpose = module.params['syspurpose'] - - global SUBMAN_CMD - SUBMAN_CMD = module.get_bin_path('subscription-manager', True) - - syspurpose_changed = False - if syspurpose is not None: - try: - syspurpose_changed = SysPurpose().update_syspurpose(syspurpose) - except Exception as err: - module.fail_json(msg="Failed to update syspurpose attributes: %s" % to_native(err)) - - # Ensure system is registered - if state == 'present': - - # Register system - if rhsm.is_registered and not force_register: - if syspurpose and 'sync' in syspurpose and syspurpose['sync'] is True: - try: - rhsm.sync_syspurpose() - except Exception as e: - module.fail_json(msg="Failed to synchronize syspurpose attributes: %s" % to_native(e)) - if pool != '^$' or pool_ids: - try: - if pool_ids: - result = rhsm.update_subscriptions_by_pool_ids(pool_ids) - else: - result = rhsm.update_subscriptions(pool) - except Exception as e: - module.fail_json(msg="Failed to update subscriptions for '%s': %s" % (server_hostname, to_native(e))) - else: - module.exit_json(**result) - else: - if syspurpose_changed is True: - module.exit_json(changed=True, msg="Syspurpose attributes changed.") - else: - module.exit_json(changed=False, msg="System already registered.") - else: - try: - rhsm.enable() - rhsm.configure(**module.params) - rhsm.register(username, password, token, auto_attach, activationkey, org_id, - consumer_type, consumer_name, consumer_id, force_register, - environment, release) - if syspurpose and 'sync' in syspurpose and syspurpose['sync'] is True: - rhsm.sync_syspurpose() - if pool_ids: - subscribed_pool_ids = rhsm.subscribe_by_pool_ids(pool_ids) - elif pool != '^$': - subscribed_pool_ids = rhsm.subscribe(pool) - else: - subscribed_pool_ids = [] - except Exception as e: - module.fail_json(msg="Failed to register with '%s': %s" % (server_hostname, to_native(e))) - else: - module.exit_json(changed=True, - msg="System successfully registered to '%s'." % server_hostname, - subscribed_pool_ids=subscribed_pool_ids) - - # Ensure system is *not* registered - if state == 'absent': - if not rhsm.is_registered: - module.exit_json(changed=False, msg="System already unregistered.") - else: - try: - rhsm.unsubscribe() - rhsm.unregister() - except Exception as e: - module.fail_json(msg="Failed to unregister: %s" % to_native(e)) - else: - module.exit_json(changed=True, msg="System successfully unregistered from %s." % server_hostname) - - -if __name__ == '__main__': - main() diff --git a/rhel-system-roles.spec b/rhel-system-roles.spec index 3575c39..47bac5d 100644 --- a/rhel-system-roles.spec +++ b/rhel-system-roles.spec @@ -1,15 +1,12 @@ -# NOTE: Even though ansible-core is in 8.6, it is only available -# at *runtime*, not at *buildtime* - so we can't have -# ansible-core as a build_dep on RHEL8 -%if 0%{?fedora} || 0%{?rhel} >= 9 -%bcond_without ansible +# NOTE: ansible-core is in rhel-8.6 and newer, but not installable +# in buildroot as it depended on modular Python. +# It has been installable at buildtime in 8.8 and newer. %if 0%{?fedora} BuildRequires: ansible-packaging %else +%if 0%{?rhel} >= 8 BuildRequires: ansible-core >= 2.11.0 %endif -%else -%bcond_with ansible %endif %bcond_with collection_artifact @@ -29,8 +26,8 @@ Name: linux-system-roles %endif Url: https://github.com/linux-system-roles Summary: Set of interfaces for unified system management -Version: 1.21.1 -Release: 1%{?dist} +Version: 1.22.0 +Release: 0.6%{?dist} License: GPLv3+ and MIT and BSD and Python %global _pkglicensedir %{_licensedir}/%{name} @@ -45,24 +42,6 @@ License: GPLv3+ and MIT and BSD and Python %global collection_version %{version} -# Helper macros originally from macros.ansible by Igor Raits -# On RHEL, not available, so we must define those macros locally -# On Fedora, provided by ansible-packager -# 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}} -%if 0%{?rhel} -Provides: ansible-collection(%{collection_namespace}.%{collection_name}) = %{collection_version} -%global ansible_collection_files %{_datadir}/ansible/collections/ansible_collections/%{collection_namespace}/ -%define ansible_roles_dir %{_datadir}/ansible/roles -%if %{without ansible} -# Untar and copy everything instead of galaxy-installing the built artifact when ansible is not available -%define ansible_collection_build() tar -cf %{_tmppath}/%{collection_namespace}-%{collection_name}-%{version}.tar.gz . -%define ansible_collection_install() mkdir -p %{buildroot}%{ansible_collection_files}%{collection_name}; (cd %{buildroot}%{ansible_collection_files}%{collection_name}; tar -xf %{_tmppath}/%{collection_namespace}-%{collection_name}-%{version}.tar.gz) -%else -%define ansible_collection_build() ansible-galaxy collection build -%define ansible_collection_install() ansible-galaxy collection install -n -p %{buildroot}%{_datadir}/ansible/collections %{collection_namespace}-%{collection_name}-%{version}.tar.gz -%endif -%endif # be compatible with the usual Fedora Provides: Provides: ansible-collection-%{collection_namespace}-%{collection_name} = %{collection_version}-%{release} @@ -107,83 +86,86 @@ Requires: (ansible-core >= 2.11.0 or ansible >= 2.9.0) %%global rolestodir %%{?rolestodir} %%{roletodir%{1}} } -%global mainid d6a8e0167e9ed8d089093b7ead1e298241b534e1 +%global mainid f8932b3155a3cb7579a2b3c453578f7bee6bb837 Source: %{url}/auto-maintenance/archive/%{mainid}/auto-maintenance-%{mainid}.tar.gz # BEGIN AUTOGENERATED SOURCES %global rolename1 postfix -%deftag 1 1.3.3 +%deftag 1 1.3.6 %global rolename2 selinux -%deftag 2 1.5.6 +%deftag 2 1.5.9 %global rolename3 timesync -%deftag 3 1.7.2 +%deftag 3 1.7.5 %global rolename4 kdump -%deftag 4 1.2.6 +%deftag 4 1.2.9 %global rolename5 network -%deftag 5 1.11.2 +%deftag 5 1.11.4 %global rolename6 storage -%deftag 6 1.9.6 +%deftag 6 1.9.8 %global rolename7 metrics -%deftag 7 1.8.1 +%deftag 7 1.8.4 %global rolename8 tlog -%deftag 8 1.2.11 +%deftag 8 1.2.14 %global rolename9 kernel_settings -%deftag 9 1.1.11 +%deftag 9 1.1.15 %global rolename10 logging -%deftag 10 1.11.5 +%deftag 10 1.11.7 %global rolename11 nbde_server -%deftag 11 1.3.3 +%deftag 11 1.3.5 %global rolename12 nbde_client -%deftag 12 1.2.10 +%deftag 12 1.2.13 %global rolename13 certificate -%deftag 13 1.1.9 +%deftag 13 1.1.11 %global rolename14 crypto_policies -%deftag 14 1.2.7 +%deftag 14 1.2.9 %global forgeorg15 https://github.com/willshersystems %global repo15 ansible-sshd %global rolename15 sshd -%deftag 15 v0.18.1 +%deftag 15 v0.19.0 %global rolename16 ssh -%deftag 16 1.1.12 +%deftag 16 1.1.15 %global rolename17 ha_cluster -%deftag 17 1.8.7 +%deftag 17 1.9.2 %global rolename18 vpn -%deftag 18 1.5.3 +%deftag 18 1.5.6 %global rolename19 firewall -%deftag 19 1.4.2 +%deftag 19 1.4.4 %global rolename20 cockpit -%deftag 20 1.4.3 +%deftag 20 1.4.5 %global rolename21 podman -%deftag 21 1.1.2 +%deftag 21 1.1.5 %global rolename22 ad_integration -%deftag 22 1.0.2 +%deftag 22 1.1.0 %global rolename23 rhc -%deftag 23 1.1.1 +%deftag 23 1.1.2 %global rolename24 journald -%deftag 24 1.0.0 +%deftag 24 1.0.3 + +%global rolename25 postgresql +%deftag 25 1.0.3 Source1: %{archiveurl1} Source2: %{archiveurl2} @@ -209,14 +191,22 @@ Source21: %{archiveurl21} Source22: %{archiveurl22} Source23: %{archiveurl23} Source24: %{archiveurl24} +Source25: %{archiveurl25} # END AUTOGENERATED SOURCES # Includes with definitions/tags that differ between RHEL and Fedora -Source2301: redhat_subscription.py Source1001: extrasources.inc %include %{SOURCE1001} +# Includes with ansible_collection_build/_install that differ between RHEL versions +Source1002: ansible-packaging.inc + +%include %{SOURCE1002} + +Source1003: vendoring-prep.inc +Source1004: vendoring-build.inc + Source995: CHANGELOG.md BuildArch: noarch @@ -276,23 +266,11 @@ end %prep # BEGIN AUTOGENERATED SETUP -%setup -q -a1 -a2 -a3 -a4 -a5 -a6 -a7 -a8 -a9 -a10 -a11 -a12 -a13 -a14 -a15 -a16 -a17 -a18 -a19 -a20 -a21 -a22 -a23 -a24 -n %{getarchivedir 0} +%setup -q -a1 -a2 -a3 -a4 -a5 -a6 -a7 -a8 -a9 -a10 -a11 -a12 -a13 -a14 -a15 -a16 -a17 -a18 -a19 -a20 -a21 -a22 -a23 -a24 -a25 -n %{getarchivedir 0} # END AUTOGENERATED SETUP -%if 0%{?rhel} -# Untar vendored collection tarballs to corresponding directories -for file in %{SOURCE801} %{SOURCE901} %{SOURCE902}; do - if [[ "$(basename $file)" =~ ([^-]+)-([^-]+)-(.+).tar.gz ]]; then - ns=${BASH_REMATCH[1]} - name=${BASH_REMATCH[2]} - ver=${BASH_REMATCH[3]} - mkdir -p .external/$ns/$name - pushd .external/$ns/$name > /dev/null - tar xfz "$file" - popd > /dev/null - fi -done -%endif +# vendoring prep steps, if any +%include %{SOURCE1003} declare -A ROLESTODIR=(%{rolestodir}) for rolename in %{rolenames}; do @@ -320,11 +298,12 @@ cd ../.. cd %{rolename15} find -P tests examples -name \*.yml | while read file; do - sed -r -i -e "s/ansible-sshd/linux-system-roles.sshd/" \ + sed -r -i -e "s/willshersystems:ansible-sshd/system_role:sshd/" \ + -e "s/ansible-sshd/linux-system-roles.sshd/" \ -e "s/ willshersystems.sshd/ linux-system-roles.sshd/" "$file" done sed -r -i -e "s/ willshersystems.sshd/ linux-system-roles.sshd/" README.md -sed -r -i -e "s/min_ansible_version: 2.8/min_ansible_version: 2.9/" meta/main.yml +sed -r -i -e 's/min_ansible_version: 2.8/min_ansible_version: "2.9"/' meta/main.yml cd .. cd %{rolename7} @@ -340,110 +319,8 @@ if [ "$rolesdir" != "$realrolesdir" ]; then fi cd .. -%if 0%{?rhel} -# Unpack tar.gz to retrieve to be vendored modules and place them in the roles library. -# ansible.posix: -# - library: -# - Module selinux and seboolean for the selinux role -# - Module mount for the storage role -declare -A module_map=( ["selinux.py"]="selinux" ["seboolean.py"]="selinux" ["mount.py"]="storage" ) -for module in "${!module_map[@]}"; do - role="${module_map[${module}]}" - if [ ! -d $role/library ]; then - mkdir $role/library - fi - cp -pL .external/ansible/posix/plugins/modules/$module $role/library/$module - sed -i -e ':a;N;$!ba;s/description:\n\( *\)/description:\n\1- WARNING: Do not use this module directly! It is only for role internal use.\n\1/' -e "s/ansible_collections.ansible.posix.plugins.module_utils/ansible.module_utils.${role}_lsr/" $role/library/$module -done - -# ansible.posix: -# - module_utils: -# - Module_util mount for the storage role -module_map=( ["mount.py"]="storage" ) -for module in "${!module_map[@]}"; do - role="${module_map[${module}]}" - if [ ! -d $role/module_utils/${role}_lsr ]; then - mkdir -p $role/module_utils/${role}_lsr - fi - cp -pL .external/ansible/posix/plugins/module_utils/$module $role/module_utils/${role}_lsr/$module -done - -# community.general: -# - library: -# - Module seport, sefcontext and selogin for the selinux role rolename2 -# - Module ini_file for role tlog -# - rhc modules -module_map=( ["seport.py"]="selinux" ["sefcontext.py"]="selinux" ["selogin.py"]="selinux" ["ini_file.py"]="tlog" - ["redhat_subscription.py"]="rhc" ["rhsm_release.py"]="rhc" ["rhsm_repository.py"]="rhc" ) -for module in "${!module_map[@]}"; do - role="${module_map[${module}]}" - if [ ! -d $role/library ]; then - mkdir $role/library - fi - # version 5.x seems to be broken? - moduledir=.external/community/general/plugins/modules - if [ ! -f $moduledir/$module ]; then - moduledir=.external/community/general/plugins/modules/system - fi - if [ ! -f $moduledir/$module ]; then - moduledir=.external/community/general/plugins/modules/files - fi - cp -pL $moduledir/$module $role/library/$module - ls -alrtF $role/library/$module - sed -i -e ':a;N;$!ba;s/description:\n\( *\)/description:\n\1- WARNING: Do not use this module directly! It is only for role internal use.\n\1/' $role/library/$module -done - -# Fix until the updated redhat_subscription.py is in community.general -cp %{SOURCE2301} rhc/library/redhat_subscription.py -sed -i -e ':a;N;$!ba;s/description:\n\( *\)/description:\n\1- WARNING: Do not use this module directly! It is only for role internal use.\n\1/' rhc/library/redhat_subscription.py - -# containers.podman: -# - library: -# - Module podman_container_info, podman_image and podman_play for the podman role -module_map=( ["podman_container_info.py"]="podman" ["podman_image.py"]="podman" ["podman_play.py"]="podman" ) -for module in "${!module_map[@]}"; do - role="${module_map[${module}]}" - if [ ! -d $role/library ]; then - mkdir $role/library - fi - moduledir=.external/containers/podman/plugins/modules - cp -pL $moduledir/$module $role/library/$module - ls -alrtF $role/library/$module - sed -i -e ':a;N;$!ba;s/description:\n\( *\)/description:\n\1- WARNING: Do not use this module directly! It is only for role internal use.\n\1/' \ - -e "s/ansible_collections.containers.podman.plugins.module_utils.podman/ansible.module_utils.${role}_lsr/" \ - $role/library/$module -done - -# containers.podman: -# - module_utils: -# - Module_util common for the podman role -module_map=( ["common.py"]="podman" ) -for module in "${!module_map[@]}"; do - role="${module_map[${module}]}" - if [ ! -d $role/module_utils/${role}_lsr ]; then - mkdir -p $role/module_utils/${role}_lsr - fi - cp -pL .external/containers/podman/plugins/module_utils/podman/$module $role/module_utils/${role}_lsr/$module -done - -# remove the temporary .external directory after vendoring -rm -rf .external - -# Replacing "linux-system-roles.rolename" with "rhel-system-roles.rolename" in each role -# Replacing "fedora.linux_system_roles." with "redhat.rhel_system_roles" in each role -# This is for the "roles calling other roles" case -# for podman, change the FQCN - using a non-FQCN module name doesn't seem to work, -# even for the legacy role format -# replace community.general for rhc -for rolename in %{rolenames}; do - find $rolename -type f -exec \ - sed -e "s/linux-system-roles[.]${rolename}\\>/%{roleinstprefix}${rolename}/g" \ - -e "s/fedora[.]linux_system_roles[.]/%{collection_namespace}.%{collection_name}./g" \ - -e "s/containers[.]podman[.]/%{collection_namespace}.%{collection_name}./g" \ - -e "s/community[.]general[.]/%{collection_namespace}.%{collection_name}./g" \ - -i {} \; -done -%endif +# vendoring build steps, if any +%include %{SOURCE1004} # Removing symlinks in tests/roles for rolename in %{rolenames}; do @@ -465,14 +342,25 @@ rm %{rolename5}/tests/ensure_provider_tests.py # Drop storage tests/scripts rm -rf %{rolename6}/tests/scripts +# fix system_roles fingerprint in "external" roles +python3 lsr_fingerprint.py + # 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@' '{}' + %build %if %{with html} +# HACK HACK HACK +# pandoc/asciidoc on rhel 8.9 does not like the journald README badge links +# remove all of the badge links from all README.md files +# in the first 14 lines of the file, remove any line that looks like a +# github action badge +# HACK HACK HACK readmes="" +matchstr="actions/workflows/" for role in %{rolenames}; do + sed -e "1,14 {\\,${matchstr},d; /\!\[/d}" -i $role/README.md readmes="${readmes} $role/README.md" done sh md2html.sh $readmes @@ -482,7 +370,7 @@ mkdir .collections %if 0%{?rhel} # Convert the upstream collection readme to the downstream one %{SOURCE998} lsr_role2collection/collection_readme.md -./galaxy_transform.py "%{collection_namespace}" "%{collection_name}" "%{collection_version}" \ +%{python3} ./galaxy_transform.py "%{collection_namespace}" "%{collection_name}" "%{collection_version}" \ "Red Hat Enterprise Linux System Roles Ansible Collection" \ "https://linux-system-roles.github.io" \ "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/administration_and_configuration_tasks_using_system_roles_in_rhel" \ @@ -515,7 +403,7 @@ extra_mapping="--extra-mapping fedora.linux_system_roles:%{collection_namespace} %else extra_mapping="" %endif -LANG=C.utf-8 LC_ALL=C.utf-8 python3 release_collection.py --galaxy-yml galaxy.yml \ +LANG=C.utf-8 LC_ALL=C.utf-8 %{python3} release_collection.py --galaxy-yml galaxy.yml \ --src-path $(pwd) --dest-path $(pwd)/.collections $includes --force --no-update \ --src-owner %{name} --skip-git --skip-check --skip-changelog $extra_mapping --debug @@ -587,16 +475,20 @@ for role in %{rolenames}; do "%{buildroot}%{_pkglicensedir}/$role.LICENSE" fi if [ -d "%{buildroot}%{ansible_roles_dir}/%{roleinstprefix}$role/examples" ]; then - for file in "%{buildroot}%{ansible_roles_dir}/%{roleinstprefix}$role/examples/"*.yml ; do - basename=$(basename "$file" .yml) - newname="$basename" - if [[ "$newname" != example-* ]]; then - newname="example-$newname" + for file in "%{buildroot}%{ansible_roles_dir}/%{roleinstprefix}$role/examples/"* ; do + if [[ "$file" == *.yml ]]; then + basename=$(basename "$file" .yml) + newname="$basename" + if [[ "$newname" != example-* ]]; then + newname="example-$newname" + fi + if [[ "$newname" != *-playbook ]]; then + newname="${newname}-playbook" + fi + cp "$file" "%{buildroot}%{_pkgdocdir}/$role/${newname}.yml" + else + cp "$file" "%{buildroot}%{_pkgdocdir}/$role" fi - if [[ "$newname" != *-playbook ]]; then - newname="${newname}-playbook" - fi - cp "$file" "%{buildroot}%{_pkgdocdir}/$role/${newname}.yml" rm "$file" done if [ -f "%{buildroot}%{ansible_roles_dir}/%{roleinstprefix}$role/examples/inventory" ]; then @@ -610,7 +502,7 @@ for role in %{rolenames}; do fi done -rm %{buildroot}%{ansible_roles_dir}/%{roleinstprefix}*/semaphore +rm -f %{buildroot}%{ansible_roles_dir}/%{roleinstprefix}*/semaphore rm -r %{buildroot}%{ansible_roles_dir}/%{roleinstprefix}*/molecule rm -r %{buildroot}%{ansible_roles_dir}/%{roleinstprefix}*/.[A-Za-z]* @@ -753,6 +645,39 @@ find %{buildroot}%{ansible_roles_dir} -mindepth 1 -maxdepth 1 | \ %endif %changelog +* Thu May 04 2023 Rich Megginson - 1.22.0-0.6 +- Resolves:rhbz#2186910 : fingerprint in config files managed by roles +- Resolves:rhbz#2190478 : ha_cluster - Add possibility to load SBD watchdog kernel modules +- Resolves:rhbz#2190483 : ha_cluster - support for resource and operation defaults +- Resolves:rhbz#2151371 : postgresql - [RFE] system role for PostgreSQL management +- Resolves:rhbz#2179016 : rhc - [RFE] New role for Red Hat subscription management, insights management [rhel-8.9.0] +- Resolves:rhbz#2190480 : ha_cluster - use pcs to setup qdevice certificates if available +- Resolves:rhbz#2186198 : spec: Remove doc fragments from vendored modules +- Resolves:rhbz#2190500 : roles should support running with gather_facts: false +- Resolves:rhbz#2175326 : use ansible-galaxy collection build/install instead of tar +- Resolves:rhbz#2186908 : rhc - RHC system role: activation key registration fails if system is already registered +- Resolves:rhbz#2190499 : selinux - failing test - sshd/tests_firewall_selinux.yml - No package matching 'firewalld' found available, installed or updated + +* Wed May 3 2023 Rich Megginson - 1.22.0-0.5 +- fix issue with postgresql tests + +* Tue May 2 2023 Rich Megginson - 1.22.0-0.4 +- fix issue with ha_cluster vendoring modprobe +- move vendoring into included files + +* Thu Apr 27 2023 Rich Megginson - 1.22.0-0.3 +- fix issues in some tests with ANSIBLE_GATHERING=explicit +- add testing for fingerprints in config files +- fix podman jinja 2.7 issue +- sshd - skip firewall testing if not supported + +* Thu Apr 6 2023 Rich Megginson - 1.22.0-0.2 +- initial 8.9/9.3 + +* Thu Apr 6 2023 Sergei Petrosian - 1.21.1-2 +- Resolves: rhbz#2185002 : Remove doc fragments from vendored modules +- Build collection artifact in the same directory on Fedora and RHEL + * Thu Mar 16 2023 Rich Megginson - 1.21.1-1 - Resolves:rhbz#2144877 : rhc - new role for subscription management/registration/insights - includes the fix for tests_proxy.yml selinux and some test refactoring diff --git a/sources b/sources index 5b9daf9..450087d 100644 --- a/sources +++ b/sources @@ -1,28 +1,29 @@ -SHA512 (ad_integration-1.0.2.tar.gz) = ef717a925e5f59391b0e09704e78aed68f03bc89862a2a5063943d46bbed51bda12e85bd4d59c0a332140adf475f64dd84f6b90bab07d2f0e316a5390b9a92f5 -SHA512 (ansible-posix-1.5.1.tar.gz) = ca2cadb27c230bd2f921797fb61bbb97c578ddd5d782f04cbd232bba84d091102fee872e69ebcfa5fb5c90b0db4fd90c2f97268e43621b233aa5309e5a0f8802 -SHA512 (ansible-sshd-v0.18.1.tar.gz) = e537160b69a1fe096b59a683acf7c5b1cd25b43d8666124da63b78a1664513d1bd3623cf94f2521347ca0a77448622cc329d215af4d2d67ccbe830cfee12befc -SHA512 (auto-maintenance-d6a8e0167e9ed8d089093b7ead1e298241b534e1.tar.gz) = a138b1e1192db8a913c5747b3c92455f41ab75e2c19351e58d69c698681d663c2b192b374934f3acb21a648162188e540fa3751f48b4c3aa0cc6378e745f47c6 -SHA512 (certificate-1.1.9.tar.gz) = 97f1c81d587add9362a8006a3045f48ce321e99866be812fe8ec1e3a302eda03b12f456535288b167997508784b520c9ccb802025bb4089919d117ec2d0d8dbe -SHA512 (cockpit-1.4.3.tar.gz) = 9bc613ea4b1dc25831df3b1503ed6697d1b9fc6a61183cd4feb8a5c29568e1b60534d6b088d6a24f6ea773d44502b10090a92a4c344bf3c4150680095f5a5209 -SHA512 (community-general-6.4.0.tar.gz) = 2c4a63b12af30d7bbe0db8560ae6c35d3952a4031c0bff9177fdcdae115982c83daf10c8c201deb8ac68623800254313445177da3a108dbf987001a4c2be2306 +SHA512 (ad_integration-1.1.0.tar.gz) = 5e94a8af75867425493667b1d5b56706d2cb5e7b28ffe7e361e66e9245bd407cc9572d65f12dbbf1362b3eb7c78370485d0087720c64672fd4677d97714f6655 +SHA512 (ansible-posix-1.5.2.tar.gz) = f99b8e33c6eb4a40903c85f8de093f3e714fecad6e0342d84aee33988220d8e55c7ac2d2a835f5c4d6a23d05cff6eda767e9f61e83cb1146a9ceadf7d1b16f18 +SHA512 (ansible-sshd-v0.19.0.tar.gz) = 06103696ee1810a8cdbb7f26e0542e85e53c6b758dbc9d87e47a3fd024c8c7fb77b54934e227b0ece4712483d89d52b1e94b1ee5cb667e420261928e8e994b53 +SHA512 (auto-maintenance-f8932b3155a3cb7579a2b3c453578f7bee6bb837.tar.gz) = ebae3911dd9d34bdafbe583d29c7aaa5d6eb082adc4a06dbca4cef68c2f37b86cd15d37255fa3e9675c142d8ff5d863d8b7df77b12e32ebad64965dd9d5cea3c +SHA512 (certificate-1.1.11.tar.gz) = e5b0b5070e97125f3ef8cd0f68bb6a309dba61f974d09e4be2410c4cd9bdfb6f619513cb34be1825c9e8a0bd1365e5f2987a750b255e117ac8dff0e290deb143 +SHA512 (cockpit-1.4.5.tar.gz) = abe66beab3fe3692fe09c65fcb937a6d0fdea63df258dd469c3a235004e49b020f2d151a91b5acd59bc20717a80be765b16fee1057fbe978c3e3fb5d24da6c8d +SHA512 (community-general-6.6.0.tar.gz) = f62269029f3248e82c7bbfabdfac46a7782fd7b05c8b9e6ba50f4e7c41edfbe891908a588e6c7c10845cc7056107a4b0482d9b8c6e0159b64a6c0170a2a255a9 SHA512 (containers-podman-1.10.1.tar.gz) = 6b489058ae2c38124d0466bd7dccc28b4f36d00c37520399c7d36e1dddb6bc63358f74cccd511067c355364f83e95f3e5256ffb2f9b3dc9d925df0ff74fde77c -SHA512 (crypto_policies-1.2.7.tar.gz) = 3c47e46f49bfe6116b834cfc32f5242fe866074d8cbbc530ad1391980c8dea8dc418bc9372565cbdd46becbab97de7ed69b4ea425750add0925e279e80954b45 -SHA512 (firewall-1.4.2.tar.gz) = 88ecce48eb84044c980e2320ea8e06053464e9385ee51b2c4022cdac9a48b18c3ba58b108ae7267decc27d6c991a0ec83f1b2aa0f6b719d93c18b9870663d6a7 -SHA512 (ha_cluster-1.8.7.tar.gz) = e67ddfc6a63e88f2fa850caeadf4a060bc9147abb5020140028b96a7027bd0cdd1e89c0167ac481a1b6302ef36dbfec86e1a58ad0effebb4e14a76b26aa59182 -SHA512 (journald-1.0.0.tar.gz) = e2af83530ae5e493c3d0833360c7e9fc43772757920b43e3d8b18093f2f98ab03e1ac9e91adbdd76490bb2b39b6e7a6c6b2f9c09d77d5d817676324634089cd5 -SHA512 (kdump-1.2.6.tar.gz) = 2e0b8ef49970a43d1c64d55a688925e48733f29e8ee862b0c1f5b01572d6e330ca1de01f65412ea492598d2fb43bc4f9d860f29b45a56051b3a4599001b3536f -SHA512 (kernel_settings-1.1.11.tar.gz) = 70b6f851ab12af1bf6b7c95159a42c709c6d8a9d5673672cf2b77310cdea8288fe05d769c424681288bd711ca3f4f519f87caa726c7f0eb6543b7a0ee272a883 -SHA512 (logging-1.11.5.tar.gz) = 8594d4fec3cc6d1fec9feb5a6a2929992f1774dd0c586ab45bcac9f41dc8e9f3d969e417ed855892c281d7c7b5fe29f3da9f5316660c6d268298621fa4ec937f -SHA512 (metrics-1.8.1.tar.gz) = c4373bc925b5b89f47d4abe23e576dba8c8043682e7cd0e564c87474c14e80e347f4fe3ce78ae15bd5eca525c1ab7b9079908651bcf52590fa789fe362453b28 -SHA512 (nbde_client-1.2.10.tar.gz) = 3f9458cbf572bbaeca58a99db2e7613106e265a44082d470e31944d508a142954a9fd96bbb4ab9ba483fd1b1e8973b9c60ed6d00838f46acd57e3d3e1e54b293 -SHA512 (nbde_server-1.3.3.tar.gz) = 41161f373dda9682796fa3d9940b9e0c39db030b6588c6313f1863c455f213335bb867ddea04bd4719c2d41aa54f0c79fa92e33403b35199f581cbccada4b59b -SHA512 (network-1.11.2.tar.gz) = 642c8d9158be816109d4a153b6c844e4276648d3ae253ff7225eaf19be24c0c494e8bbe3547097ed2def89d5d12d2cd464da4b4a0344e14f36fd4d419073bb5a -SHA512 (podman-1.1.2.tar.gz) = 627bdca8053a2e7b817f2c039dea3ce4a2ec1bf116a455ce812bd1d6f6fc01214a02d582a8789ffd6f8657c959fad773423000ef773fa47e314059a12a70aa6a -SHA512 (postfix-1.3.3.tar.gz) = 93cb2ec4764d5ea7922298194e5ed8613bac50a6646e4410bb608c8590e5f4a1b7aa3a6251bc9551ab3ba2033394a2700542f6377d9bf08676c8ee2b963710de -SHA512 (rhc-1.1.1.tar.gz) = 3cba735d52bee486068867b8881e4a627deb2d56bc408b1fe51af2289506abe379de2c61a0dbf7779af8b0f3963dd218971b8f1be0f0fdfec6ebbd487ffd111c -SHA512 (selinux-1.5.6.tar.gz) = 7467d3f048735151ab2f54949b8ef4af0e5a0a4b808558e0a4bc7bc2f6adcf1e2e4003d5709e3d6b6c4f75ebf2a6ac678e98fe46764e04d373efbd69d4b84afa -SHA512 (ssh-1.1.12.tar.gz) = b3041110726467bb9711babc2dd327622cacb31e3ba19f5f0036b538575ebe71b55521eb7f7e7cb6e5fc22ee230f2909c3eb2308ac163144c72422211f979d6d -SHA512 (storage-1.9.6.tar.gz) = a8de206da08fdc2ad467e493e3a601b72d3aa31133b7d2878ef3b920ad767ea7090b51518eea40de5b7b652fa68d11d14324beb62354956cacd8f6e9c05cc850 -SHA512 (timesync-1.7.2.tar.gz) = 0410ef3934ca080f968253a6f5b655e5d7467808af0320f1eb3237eb758415010f8bfe74447ea949fe9d30af63f7b145c455c5485c12227768b8567bb89b024b -SHA512 (tlog-1.2.11.tar.gz) = 98240b3042ff3640a7eccedc4f8b2a99749b2507d7ff7588fa8a2f8cc1004433389b11f654ee5887039e427858eeb891bfd434131daa2bf62b4cd4678c0fe62b -SHA512 (vpn-1.5.3.tar.gz) = fcd0f3c5beaf96f9e07d968562753d2742b9ef32f95c42f1f1093f9de60e0c44772df35964ccc5db8ee0d720ed93f081a96c8e6fd2877b15c8cc1c7cfc451016 +SHA512 (crypto_policies-1.2.9.tar.gz) = e8e5a1b3fdad448a59ac3bba451ebdacc757f2c59b779a5f7ed20c19aee79c323c48bf723f5be684eab522ec3ebae60defe5bf426d1cd6701b4efdc79669d72e +SHA512 (firewall-1.4.4.tar.gz) = 19a04369298e80accfaa57e9ca5c2c34b53e05ea78a1cecac46548d6440e54e19f0978742e5852aaf4516de4ccdfa22bb547f6623f05888cdef22df99155cab9 +SHA512 (ha_cluster-1.9.2.tar.gz) = c491aae3e99eae0e4f71248ab2f21de0da18c371649d8421d663cd49aea47b845e7adea19c02d5728ca20cf9299eaed8783124abed617d865601ee373153f239 +SHA512 (journald-1.0.3.tar.gz) = b7d3a33c16ee8aec11047f34d7d788c6bceb9fe6ef3b8a7d75eb9c461d72e40acb0c5c1e1f1cbe720e0fc530bf609789724295cddb7790eeaee7a850d09d6574 +SHA512 (kdump-1.2.9.tar.gz) = b33927fd777a012d949a029ae827b914b26fdafdce8b92475d91f98e0ab445dc30461a1a5d964ec404f5e004e9c203923bdd654af39cae0aa46be70fa82c5935 +SHA512 (kernel_settings-1.1.15.tar.gz) = dd74ce866357958a477dbbb84f95677224049135d5d245aeab979fde1da194b07d205a189526e3f0cb39e9c97b526e50eb46e19322289183f3b698fd02c8b4b1 +SHA512 (logging-1.11.7.tar.gz) = 4628b0fe6799ed0cff1cabfef3492cebbd55f99cfceb2b2f0db1b47408d2bf497b309024f19522495e5f9562d88a0117839b8bb4d57a56b41a780ee06b6a4280 +SHA512 (metrics-1.8.4.tar.gz) = 74a4ddc1133c437ea3fb49388bf73aef0d4a12ecf81a42aa5cc2f4bb85d1c984ec0d18db470f6fb32645d8542507876fee15c96486d21467eeeba91e57fd06df +SHA512 (nbde_client-1.2.13.tar.gz) = b35544ee32a6e0aa54985fbc1225f7e7ba124ecb89065545716a58edf6c7c54ef466aed2d3330a453720d3b4336195814abe831c175c10505ce134b43a202ab6 +SHA512 (nbde_server-1.3.5.tar.gz) = 8e4730ea02ed3c85c2b2530b627cc0600251961556cd1c89872db6ca6420eec6aee6d016190fa99d4d1ebe118af3ea017d9c1646ed430ca9fa8a07f0839c1658 +SHA512 (network-1.11.4.tar.gz) = 0984041cf312879a2c65690a481f87a5ced61df4e19e0c4775346461851e4a96753ebbde048ca84083b648ff09fea5bdb85e1a65d065cd03f7d1561d9debc312 +SHA512 (podman-1.1.5.tar.gz) = dfe6e362f7d151eb8d92fe64bd67980d20d019475d3872d1ca353ef27acec1d055d1d53baf0e7f081b11077219db6405367f514092aa3687308756757bb41fd4 +SHA512 (postfix-1.3.6.tar.gz) = 8409adb897e56663ebb5d149f539dfebd70135812fd164b3fa55af56b9601015d0f288448eb38e538b77a71e921719f956ddac9d3d95a46acd382560ac72752e +SHA512 (postgresql-1.0.3.tar.gz) = 8aa19cada6a9ac067cd070faee046106a3c93aef3a439973ffa7531442691ecef4150fe3b39684d60ba1f3b5f34319b67cba4df204677b358f34f046128c3813 +SHA512 (rhc-1.1.2.tar.gz) = 18a59153859fca40c571acd114e8e94800cc784a7ff15e3867c2842e0006a66b525e6894954e0d38f86f35debfe768fd0ce6daa9435f80136c07ac8a786f986f +SHA512 (selinux-1.5.9.tar.gz) = df9e2c7594ae3b437b8eb2d0a83e3c0d996323af2f5d6509a01a1297fcf18b8f779cb8975c7cf3c2c8fbd6a391b6b8a2206cc38d16690bdb6c29c7187f1364c8 +SHA512 (ssh-1.1.15.tar.gz) = 0901382d0c5859a797fb4d0191a50bf3cec36bfe141cdbc0a03bfaec0c565d180538b51d21c2f7cf763f788315a9392206a084e7cd026b77a7aa437cddefcf7d +SHA512 (storage-1.9.8.tar.gz) = c43e8aa29b8d44409c8409c08c87af80650928bb56497f6b04a9b6e0984c110a333e2c315ca640bfa20092216aa7d650b460681603226fe0857366016fab48c7 +SHA512 (timesync-1.7.5.tar.gz) = 6a7ff71a6152e74706836ec32671f1d1dff46b675816e584aa2761acbb88874f6e62d892a74555c3534ba7851a114bef30a18f79620ec707d0829c46c3ce8a33 +SHA512 (tlog-1.2.14.tar.gz) = 05b0e23c578b159895a41ec662e0a6a02654bfb966f335a698071635503caa0f27b682fac15aa1948933e2e039eebf1511b527479d92091c5a8edc6d66a19251 +SHA512 (vpn-1.5.6.tar.gz) = f4c1fb07d92f9b27fbb846cdce2bb5e138f4e13a9c9bf3495947c8addc4b4fe0a011f0ee6062bff10d5281fbacd7235a0d91a99656d9fa76c5519245db2a7d95 diff --git a/vendoring-build.inc b/vendoring-build.inc new file mode 100644 index 0000000..ad60e97 --- /dev/null +++ b/vendoring-build.inc @@ -0,0 +1,103 @@ +# Unpack tar.gz to retrieve to be vendored modules and place them in the roles library. +# ansible.posix: +# - library: +# - Module selinux and seboolean for the selinux role +# - Module mount for the storage role +declare -A module_map=( ["selinux.py"]="selinux" ["seboolean.py"]="selinux" ["mount.py"]="storage" ) +for module in "${!module_map[@]}"; do + role="${module_map[${module}]}" + if [ ! -d $role/library ]; then + mkdir $role/library + fi + cp -pL .external/ansible/posix/plugins/modules/$module $role/library/$module + sed -i -e ':a;N;$!ba;s/description:\n\( *\)/description:\n\1- WARNING: Do not use this module directly! It is only for role internal use.\n\1/' -e "s/ansible_collections.ansible.posix.plugins.module_utils/ansible.module_utils.${role}_lsr/" $role/library/$module +done + +# ansible.posix: +# - module_utils: +# - Module_util mount for the storage role +module_map=( ["mount.py"]="storage" ) +for module in "${!module_map[@]}"; do + role="${module_map[${module}]}" + if [ ! -d $role/module_utils/${role}_lsr ]; then + mkdir -p $role/module_utils/${role}_lsr + fi + cp -pL .external/ansible/posix/plugins/module_utils/$module $role/module_utils/${role}_lsr/$module +done + +# community.general: +# - library: +# - Module seport, sefcontext and selogin for the selinux role rolename2 +# - Module ini_file for role tlog +# - rhc modules +# - ha_cluster uses modprobe +module_map=( ["seport.py"]="selinux" ["sefcontext.py"]="selinux" ["selogin.py"]="selinux" ["ini_file.py"]="tlog" + ["redhat_subscription.py"]="rhc" ["rhsm_release.py"]="rhc" ["rhsm_repository.py"]="rhc" + ["modprobe.py"]="ha_cluster" ) +for module in "${!module_map[@]}"; do + role="${module_map[${module}]}" + if [ ! -d $role/library ]; then + mkdir $role/library + fi + # version 5.x seems to be broken? + moduledir=.external/community/general/plugins/modules + if [ ! -f $moduledir/$module ]; then + moduledir=.external/community/general/plugins/modules/system + fi + if [ ! -f $moduledir/$module ]; then + moduledir=.external/community/general/plugins/modules/files + fi + cp -pL $moduledir/$module $role/library/$module + ls -alrtF $role/library/$module + sed -i -e ':a;N;$!ba;s/description:\n\( *\)/description:\n\1- WARNING: Do not use this module directly! It is only for role internal use.\n\1/' $role/library/$module + + # Remove doc_fragments + sed -i '/^extends_documentation_fragment:/,/^[^ -]/{/^extends/d;/^[ -]/d}' $role/library/$module +done + +# containers.podman: +# - library: +# - Module podman_container_info, podman_image and podman_play for the podman role +module_map=( ["podman_container_info.py"]="podman" ["podman_image.py"]="podman" ["podman_play.py"]="podman" ) +for module in "${!module_map[@]}"; do + role="${module_map[${module}]}" + if [ ! -d $role/library ]; then + mkdir $role/library + fi + moduledir=.external/containers/podman/plugins/modules + cp -pL $moduledir/$module $role/library/$module + ls -alrtF $role/library/$module + sed -i -e ':a;N;$!ba;s/description:\n\( *\)/description:\n\1- WARNING: Do not use this module directly! It is only for role internal use.\n\1/' \ + -e "s/ansible_collections.containers.podman.plugins.module_utils.podman/ansible.module_utils.${role}_lsr/" \ + $role/library/$module +done + +# containers.podman: +# - module_utils: +# - Module_util common for the podman role +module_map=( ["common.py"]="podman" ) +for module in "${!module_map[@]}"; do + role="${module_map[${module}]}" + if [ ! -d $role/module_utils/${role}_lsr ]; then + mkdir -p $role/module_utils/${role}_lsr + fi + cp -pL .external/containers/podman/plugins/module_utils/podman/$module $role/module_utils/${role}_lsr/$module +done + +# remove the temporary .external directory after vendoring +rm -rf .external + +# Replacing "linux-system-roles.rolename" with "rhel-system-roles.rolename" in each role +# Replacing "fedora.linux_system_roles." with "redhat.rhel_system_roles" in each role +# This is for the "roles calling other roles" case +# for podman, change the FQCN - using a non-FQCN module name doesn't seem to work, +# even for the legacy role format +# replace community.general for rhc +for rolename in %{rolenames}; do + find $rolename -type f -exec \ + sed -e "s/linux-system-roles[.]${rolename}\\>/%{roleinstprefix}${rolename}/g" \ + -e "s/fedora[.]linux_system_roles[.]/%{collection_namespace}.%{collection_name}./g" \ + -e "s/containers[.]podman[.]/%{collection_namespace}.%{collection_name}./g" \ + -e "s/community[.]general[.]/%{collection_namespace}.%{collection_name}./g" \ + -i {} \; +done diff --git a/vendoring-prep.inc b/vendoring-prep.inc new file mode 100644 index 0000000..66ea974 --- /dev/null +++ b/vendoring-prep.inc @@ -0,0 +1,12 @@ +# Untar vendored collection tarballs to corresponding directories +for file in %{SOURCE801} %{SOURCE901} %{SOURCE902}; do + if [[ "$(basename $file)" =~ ([^-]+)-([^-]+)-(.+).tar.gz ]]; then + ns=${BASH_REMATCH[1]} + name=${BASH_REMATCH[2]} + ver=${BASH_REMATCH[3]} + mkdir -p .external/$ns/$name + pushd .external/$ns/$name > /dev/null + tar xfz "$file" + popd > /dev/null + fi +done