#19 WIP: Update to upstream 5.1.0
Merged a year ago by kevin. Opened a year ago by dmsimard.
rpms/ dmsimard/ansible rawhide  into  rawhide

file modified
+1
@@ -111,3 +111,4 @@ 

  /ansible-2.9.25.tar.gz

  /ansible-2.9.26.tar.gz

  /ansible-2.9.27.tar.gz

+ /ansible-5.1.0.tar.gz

@@ -1,76 +0,0 @@ 

- diff --color -Nur ansible.2.9.22.orig/lib/ansible/modules/system/hostname.py ansible-2.9.22/lib/ansible/modules/system/hostname.py

- --- ansible.2.9.22.orig/lib/ansible/modules/system/hostname.py	2021-05-24 14:18:02.000000000 -0700

- +++ ansible-2.9.22/lib/ansible/modules/system/hostname.py	2021-06-19 10:09:53.078883364 -0700

- @@ -782,6 +782,10 @@

-      distribution = 'Neon'

-      strategy_class = DebianStrategy

-  

- +class RockyLinuxHostname(Hostname):

- +    platform = 'Linux'

- +    distribution = 'Rocky'

- +    strategy_class = SystemdStrategy

-  

-  def main():

-      module = AnsibleModule(

- diff --color -Nur ansible.2.9.22.orig/lib/ansible/module_utils/facts/system/distribution.py ansible-2.9.22/lib/ansible/module_utils/facts/system/distribution.py

- --- ansible.2.9.22.orig/lib/ansible/module_utils/facts/system/distribution.py	2021-05-24 14:18:01.000000000 -0700

- +++ ansible-2.9.22/lib/ansible/module_utils/facts/system/distribution.py	2021-06-19 10:09:38.680877684 -0700

- @@ -467,7 +467,7 @@

-      OS_FAMILY_MAP = {'RedHat': ['RedHat', 'Fedora', 'CentOS', 'Scientific', 'SLC',

-                                  'Ascendos', 'CloudLinux', 'PSBM', 'OracleLinux', 'OVS',

-                                  'OEL', 'Amazon', 'Virtuozzo', 'XenServer', 'Alibaba',

- -                                'AlmaLinux'],

- +                                'AlmaLinux', 'Rocky'],

-                       'Debian': ['Debian', 'Ubuntu', 'Raspbian', 'Neon', 'KDE neon',

-                                  'Linux Mint', 'SteamOS', 'Devuan', 'Kali', 'Cumulus Linux'],

-                       'Suse': ['SuSE', 'SLES', 'SLED', 'openSUSE', 'openSUSE Tumbleweed',

- diff --color -Nur ansible.2.9.22.orig/test/units/module_utils/facts/system/distribution/fixtures/rockylinux_8_3.json ansible-2.9.22/test/units/module_utils/facts/system/distribution/fixtures/rockylinux_8_3.json

- --- ansible.2.9.22.orig/test/units/module_utils/facts/system/distribution/fixtures/rockylinux_8_3.json	1969-12-31 16:00:00.000000000 -0800

- +++ ansible-2.9.22/test/units/module_utils/facts/system/distribution/fixtures/rockylinux_8_3.json	2021-06-19 10:12:39.019948830 -0700

- @@ -0,0 +1,46 @@

- +{

- +    "name": "Rocky 8.3",

- +    "distro": {

- +        "codename": "",

- +        "id": "rocky",

- +        "name": "Rocky Linux",

- +        "version": "8.3",

- +        "version_best": "8.3",

- +        "lsb_release_info": {},

- +        "os_release_info": {

- +            "name": "Rocky Linux",

- +            "version": "8.3",

- +            "id": "rocky",

- +            "id_like": "rhel fedora",

- +            "version_id": "8.3",

- +            "platform_id": "platform:el8",

- +            "pretty_name": "Rocky Linux 8.3",

- +            "ansi_color": "0;31",

- +            "cpe_name": "cpe:/o:rocky:rocky:8",

- +            "home_url": "https://rockylinux.org/",

- +            "bug_report_url": "https://bugs.rockylinux.org/",

- +            "rocky_support_product": "Rocky Linux",

- +            "rocky_support_product_version": "8"

- +        }

- +    },

- +    "input": {

- +        "/etc/redhat-release": "Rocky Linux release 8.3\n",

- +        "/etc/system-release": "Rocky Linux release 8.3\n",

- +        "/etc/rocky-release": "Rocky Linux release 8.3\n",

- +        "/etc/os-release": "NAME=\"Rocky Linux\"\nVERSION=\"8.3\"\nID=\"rocky\"\nID_LIKE=\"rhel fedora\"\nVERSION_ID=\"8.3\"\nPLATFORM_ID=\"platform:el8\"\nPRETTY_NAME=\"Rocky Linux 8.3\"\nANSI_COLOR=\"0;31\"\nCPE_NAME=\"cpe:/o:rocky:rocky:8\"\nHOME_URL=\"https://rockylinux.org/\"\nBUG_REPORT_URL=\"https://bugs.rockylinux.org/\"\nROCKY_SUPPORT_PRODUCT=\"Rocky Linux\"\nROCKY_SUPPORT_PRODUCT_VERSION=\"8\"\n",

- +        "/usr/lib/os-release": "NAME=\"Rocky Linux\"\nVERSION=\"8.3\"\nID=\"rocky\"\nID_LIKE=\"rhel fedora\"\nVERSION_ID=\"8.3\"\nPLATFORM_ID=\"platform:el8\"\nPRETTY_NAME=\"Rocky Linux 8.3\"\nANSI_COLOR=\"0;31\"\nCPE_NAME=\"cpe:/o:rocky:rocky:8\"\nHOME_URL=\"https://rockylinux.org/\"\nBUG_REPORT_URL=\"https://bugs.rockylinux.org/\"\nROCKY_SUPPORT_PRODUCT=\"Rocky Linux\"\nROCKY_SUPPORT_PRODUCT_VERSION=\"8\"\n"

- +    },

- +    "platform.dist": [

- +        "rocky",

- +        "8.3",

- +        ""

- +    ],

- +    "result": {

- +        "distribution": "Rocky",

- +        "distribution_version": "8.3",

- +        "distribution_release": "NA",

- +        "distribution_major_version": "8",

- +        "os_family": "RedHat"

- +    },

- +    "platform.release": "4.18.0-240.22.1.el8.x86_64"

- +}

@@ -1,12 +0,0 @@ 

- diff --color -Nur ansible-2.9.23.orig/docs/docsite/_extensions/pygments_lexer.py ansible-2.9.23/docs/docsite/_extensions/pygments_lexer.py

- --- ansible-2.9.23.orig/docs/docsite/_extensions/pygments_lexer.py	2021-06-21 23:04:48.000000000 -0700

- +++ ansible-2.9.23/docs/docsite/_extensions/pygments_lexer.py	2021-07-10 12:33:05.790899630 -0700

- @@ -178,7 +178,7 @@

-          See http://www.sphinx-doc.org/en/stable/extdev/index.html#dev-extensions.

-      """

-      for lexer in [

- -        AnsibleOutputLexer(startinline=True)

- +        AnsibleOutputLexer

-      ]:

-          app.add_lexer(lexer.name, lexer)

-          for alias in lexer.aliases:

@@ -1,15 +0,0 @@ 

- diff --color -Nur ansible-2.9.27.orig/test/units/module_utils/acme/fixtures/csr_1.pem ansible-2.9.27/test/units/module_utils/acme/fixtures/csr_1.pem

- --- ansible-2.9.27.orig/test/units/module_utils/acme/fixtures/csr_1.pem 2021-10-11 08:18:57.217846900 -0700

- +++ ansible-2.9.27/test/units/module_utils/acme/fixtures/csr_1.pem      2021-10-26 15:19:37.479752918 -0700

- @@ -1,4 +1,4 @@

- ------BEGIN NEW CERTIFICATE REQUEST-----

- +-----BEGIN CERTIFICATE REQUEST-----

-  MIIBJTCBzQIBADAWMRQwEgYDVQQDEwthbnNpYmxlLmNvbTBZMBMGByqGSM49AgEG

-  CCqGSM49AwEHA0IABACc9MgAFwMBJjoU0ZI18cIHnW1juoKG2DN5VrM60uvBvEEs

-  4V0egJkNyM2Q4pp001zu14VcpQ0/Ei8xOOPxKZugVTBTBgkqhkiG9w0BCQ4xRjBE

- @@ -6,4 +6,4 @@

-  AjAAMA8GA1UdDwEB/wQFAwMHgAAwCgYIKoZIzj0EAwIDRwAwRAIgcDyoRmwFVBDl

-  FvbFZtiSd5wmJU1ltM6JtcfnLWnjY54CICruOByrropFUkOKKb4xXOYsgaDT93Wr

-  URnCJfTLr2T3

- ------END NEW CERTIFICATE REQUEST-----

- +-----END CERTIFICATE REQUEST-----

@@ -1,12 +0,0 @@ 

- diff --color -Nur ansible-2.9.27.orig/lib/ansible/config/base.yml ansible-2.9.27/lib/ansible/config/b

- ase.yml

- --- ansible-2.9.27.orig/lib/ansible/config/base.yml     2021-10-11 08:18:55.681846900 -0700

- +++ ansible-2.9.27/lib/ansible/config/base.yml  2021-11-01 10:40:38.928873116 -0700

- @@ -1450,6 +1450,7 @@

-        '8': /usr/libexec/platform-python

-      fedora:

-        '23': /usr/bin/python3

- +    oracle: *rhelish

-      redhat: *rhelish

-      rhel: *rhelish

-      ubuntu:

@@ -1,81 +0,0 @@ 

- diff --color -Nur ansible-2.9.27.orig/test/units/modules/cloud/openstack/test_os_server.py ansible-2.9.27/test/units/modules/cloud/openstack/test_os_server.py

- --- ansible-2.9.27.orig/test/units/modules/cloud/openstack/test_os_server.py	2021-10-11 08:18:57.290846800 -0700

- +++ ansible-2.9.27/test/units/modules/cloud/openstack/test_os_server.py	2021-10-26 14:36:44.086550302 -0700

- @@ -22,7 +22,7 @@

-      module.'''

-  

-      doc = inspect.getdoc(func)

- -    cfg = yaml.load(doc)

- +    cfg = yaml.load(doc, Loader=yaml.CLoader)

-  

-      for task in cfg:

-          for module, params in task.items():

- diff --color -Nur ansible-2.9.27.orig/test/units/modules/remote_management/oneview/test_oneview_ethernet_network.py ansible-2.9.27/test/units/modules/remote_management/oneview/test_oneview_ethernet_network.py

- --- ansible-2.9.27.orig/test/units/modules/remote_management/oneview/test_oneview_ethernet_network.py	2021-10-11 08:18:57.447847000 -0700

- +++ ansible-2.9.27/test/units/modules/remote_management/oneview/test_oneview_ethernet_network.py	2021-10-26 14:37:25.647363390 -0700

- @@ -141,7 +141,7 @@

-          self.resource.update.return_value = data_merged

-          self.mock_ov_client.connection_templates.get.return_value = {"uri": "uri"}

-  

- -        self.mock_ansible_module.params = yaml.load(YAML_PARAMS_WITH_CHANGES)

- +        self.mock_ansible_module.params = yaml.load(YAML_PARAMS_WITH_CHANGES, Loader=yaml.CLoader)

-  

-          EthernetNetworkModule().run()

-  

- @@ -155,7 +155,7 @@

-          self.resource.get_by.return_value = [DICT_PARAMS_WITH_CHANGES]

-          self.mock_ov_client.connection_templates.get.return_value = {"uri": "uri"}

-  

- -        self.mock_ansible_module.params = yaml.load(YAML_PARAMS_WITH_CHANGES)

- +        self.mock_ansible_module.params = yaml.load(YAML_PARAMS_WITH_CHANGES, Loader=yaml.CLoader)

-  

-          EthernetNetworkModule().run()

-  

- @@ -174,7 +174,7 @@

-          self.mock_ov_client.connection_templates.get.return_value = {

-              "bandwidth": DICT_PARAMS_WITH_CHANGES['bandwidth']}

-  

- -        self.mock_ansible_module.params = yaml.load(YAML_PARAMS_WITH_CHANGES)

- +        self.mock_ansible_module.params = yaml.load(YAML_PARAMS_WITH_CHANGES, Loader=yaml.CLoader)

-  

-          EthernetNetworkModule().run()

-  

- @@ -191,7 +191,7 @@

-          self.resource.get_by.return_value = [DEFAULT_ENET_TEMPLATE]

-          self.resource.update.return_value = data_merged

-  

- -        self.mock_ansible_module.params = yaml.load(YAML_PARAMS_WITH_CHANGES)

- +        self.mock_ansible_module.params = yaml.load(YAML_PARAMS_WITH_CHANGES, Loader=yaml.CLoader)

-  

-          EthernetNetworkModule().run()

-  

- @@ -329,7 +329,7 @@

-              "max": 1

-          }}

-  

- -        self.mock_ansible_module.params = yaml.load(YAML_RESET_CONNECTION_TEMPLATE)

- +        self.mock_ansible_module.params = yaml.load(YAML_RESET_CONNECTION_TEMPLATE, Loader=yaml.CLoader)

-  

-          EthernetNetworkModule().run()

-  

- @@ -340,7 +340,7 @@

-      def test_should_fail_when_reset_not_existing_ethernet_network(self):

-          self.resource.get_by.return_value = [None]

-  

- -        self.mock_ansible_module.params = yaml.load(YAML_RESET_CONNECTION_TEMPLATE)

- +        self.mock_ansible_module.params = yaml.load(YAML_RESET_CONNECTION_TEMPLATE, Loader=yaml.CLoader)

-  

-          EthernetNetworkModule().run()

-  

- diff --color -Nur ansible-2.9.27.orig/test/units/plugins/action/test_synchronize.py ansible-2.9.27/test/units/plugins/action/test_synchronize.py

- --- ansible-2.9.27.orig/test/units/plugins/action/test_synchronize.py   2021-10-11 08:18:57.476847000 -0700

- +++ ansible-2.9.27/test/units/plugins/action/test_synchronize.py        2021-10-26 15:22:02.968085259 -0700

- @@ -121,7 +121,7 @@

-          metapath = os.path.join(fixturepath, 'meta.yaml')

-          with open(metapath, 'rb') as f:

-              fdata = f.read()

- -        test_meta = yaml.load(fdata)

- +        test_meta = yaml.load(fdata, Loader=yaml.CLoader)

-  

-          # load initial play context vars

-          if '_play_context' in test_meta:

@@ -1,78 +0,0 @@ 

- diff -Nur ansible-2.9.6.orig/test/units/galaxy/test_collection_install.py ansible-2.9.6/test/units/galaxy/test_collection_install.py

- --- ansible-2.9.6.orig/test/units/galaxy/test_collection_install.py	2020-03-04 21:40:01.000000000 -0800

- +++ ansible-2.9.6/test/units/galaxy/test_collection_install.py	2020-03-06 13:35:48.489822740 -0800

- @@ -204,40 +204,40 @@

-          collection.CollectionRequirement.from_path(collection_artifact[0], True)

-  

-  

- -def test_build_requirement_from_path_no_version(collection_artifact, monkeypatch):

- -    manifest_path = os.path.join(collection_artifact[0], b'MANIFEST.json')

- -    manifest_value = json.dumps({

- -        'collection_info': {

- -            'namespace': 'namespace',

- -            'name': 'name',

- -            'version': '',

- -            'dependencies': {}

- -        }

- -    })

- -    with open(manifest_path, 'wb') as manifest_obj:

- -        manifest_obj.write(to_bytes(manifest_value))

- -

- -    mock_display = MagicMock()

- -    monkeypatch.setattr(Display, 'display', mock_display)

- -

- -    actual = collection.CollectionRequirement.from_path(collection_artifact[0], True)

- -

- -    # While the folder name suggests a different collection, we treat MANIFEST.json as the source of truth.

- -    assert actual.namespace == u'namespace'

- -    assert actual.name == u'name'

- -    assert actual.b_path == collection_artifact[0]

- -    assert actual.api is None

- -    assert actual.skip is True

- -    assert actual.versions == set(['*'])

- -    assert actual.latest_version == u'*'

- -    assert actual.dependencies == {}

- -

- -    assert mock_display.call_count == 1

- -

- -    actual_warn = ' '.join(mock_display.mock_calls[0][1][0].split('\n'))

- -    expected_warn = "Collection at '%s' does not have a valid version set, falling back to '*'. Found version: ''" \

- -        % to_text(collection_artifact[0])

- -    assert expected_warn in actual_warn

- +#def test_build_requirement_from_path_no_version(collection_artifact, monkeypatch):

- +#    manifest_path = os.path.join(collection_artifact[0], b'MANIFEST.json')

- +#    manifest_value = json.dumps({

- +#        'collection_info': {

- +#            'namespace': 'namespace',

- +#            'name': 'name',

- +#            'version': '',

- +#            'dependencies': {}

- +#        }

- +#    })

- +#    with open(manifest_path, 'wb') as manifest_obj:

- +#        manifest_obj.write(to_bytes(manifest_value))

- +#

- +#    mock_display = MagicMock()

- +#    monkeypatch.setattr(Display, 'display', mock_display)

- +#

- +#    actual = collection.CollectionRequirement.from_path(collection_artifact[0], True)

- +#

- +#    # While the folder name suggests a different collection, we treat MANIFEST.json as the source of truth.

- +#    assert actual.namespace == u'namespace'

- +#    assert actual.name == u'name'

- +#    assert actual.b_path == collection_artifact[0]

- +#    assert actual.api is None

- +#    assert actual.skip is True

- +#    assert actual.versions == set(['*'])

- +#    assert actual.latest_version == u'*'

- +#    assert actual.dependencies == {}

- +#

- +#    assert mock_display.call_count == 1

- +#

- +#    actual_warn = ' '.join(mock_display.mock_calls[0][1][0].split('\n'))

- +#    expected_warn = "Collection at '%s' does not have a valid version set, falling back to '*'. Found version: ''" \

- +#        % to_text(collection_artifact[0])

- +#    assert expected_warn in actual_warn

-  

-  

-  def test_build_requirement_from_tar(collection_artifact):

file removed
-46
@@ -1,46 +0,0 @@ 

- #!/usr/bin/python3

- 

- import argparse

- import json

- import re

- import sys

- 

- 

- def main():

-     parser = argparse.ArgumentParser()

-     group = parser.add_mutually_exclusive_group(required=True)

-     group.add_argument(

-         "-P", "--provides", action="store_const", const="provides", dest="action"

-     )

-     group.add_argument(

-         "-R", "--requires", action="store_const", const="requires", dest="action"

-     )

-     args = parser.parse_args()

- 

-     files = sys.stdin.read().splitlines()

- 

-     for f in files:

-         with open(f, "r") as fobj:

-             info = json.load(fobj)["collection_info"]

-             if args.action == "provides":

-                 print(

-                     f"ansible-collection({info['namespace']}.{info['name']}) = {info['version']}"

-                 )

-             if args.action == "requires":

-                 print("(ansible >= 2.9.0 or ansible-core >= 2.11.0)")

-                 for dep, req in info.get("dependencies", {}).items():

-                     print(f"ansible-collection({dep})", end="")

-                     if req == "*":

-                         print()

-                         continue

-                     m = re.match(r"^>=(\d+\.\d+\.\d+)$", req)

-                     if m:

-                         print(f" >= {m.group(1)}")

-                         continue

-                     raise NotImplementedError(

-                         "Generation of dependencies different than '*' or '>=' is not supported yet"

-                     )

- 

- 

- if __name__ == "__main__":

-     main()

file removed
-3
@@ -1,3 +0,0 @@ 

- %__ansible_provides %{_rpmconfigdir}/ansible-generator --provides

- %__ansible_requires %{_rpmconfigdir}/ansible-generator --requires

- %__ansible_path ^%{_datadir}/ansible/collections/ansible_collections/[^/]+/[^/]+/MANIFEST.json$

file added
+5
@@ -0,0 +1,5 @@ 

+ addFilter("E: non-executable-script")

+ addFilter("W: files-duplicate")

+ addFilter("W: name-repeated-in-summary")

+ # This is not egrep, it's "find -regextype posix-egrep"

+ addFilter("W: deprecated-grep")

file modified
+74 -244
@@ -1,131 +1,30 @@ 

- # Note to maintainers: main and all fedora branches can be merged.

- # epel8 and epel7 and should be updated seperately.

- 

- # in Fedora and EPEL8 build with docs and tests by default

- %global with_docs 1

- 

- # Disable tests on f29/f30 and epel8 for now.

- # epel8 is missing 2 required packages.

- # fedora29 and fedora30 have too old pytest

- %if 0%{?fedora} < 31 || 0%{?rhel} >= 8

+ # TODO: Re-enable docs and tests once possible

+ %global with_docs 0

  %global with_tests 0

- %else

- %global with_tests 1

- %endif

- 

- Name: ansible

- Summary: SSH-based configuration management, deployment, and task execution system

- Version: 2.9.27

- Release: 2%{?dist}

- 

- License: GPLv3+

- Source0: https://releases.ansible.com/ansible/%{name}-%{version}.tar.gz

- Source1: ansible.attr

- Source2: ansible-generator

- Source3: macros.ansible

- Url: http://ansible.com

- BuildArch: noarch

- 

- # add patch for Rocky linux: rhbz#1968728

- Patch1: ansible-2.9.22-rocky.patch

- 

- # Disable failing test

- Patch2: ansible-2.9.6-disable-test_build_requirement_from_path_no_version.patch

- # Fix Python 3.9 compatibility

- # Backported from upstream: https://github.com/ansible/ansible/pull/67891

- Patch3: fix-python-3.9-compatibility.patch

- 

- # Fix to build docs with sphinx > 4.0

- Patch4: ansible-2.9.23-sphinx4.patch

- 

- # compatiblity with pyyaml > 6 for some tests

- Patch5: ansible-2.9.27-pyyaml-6-compat.patch

- 

- # compatibility with openssl v3

- Patch6: ansible-2.9.27-openssl-3-compat.patch

+ %global ansible_licensedir %{_defaultlicensedir}/ansible

+ %global ansible_docdir %{_defaultdocdir}/ansible

  

- # add patch for Oracle linux: rhbz#2018369

- Patch7: ansible-2.9.27-oracle.patch

+ Name:           ansible

+ Summary:        Curated set of Ansible collections included in addition to ansible-core

+ Version:        5.1.0

+ Release:        1%{?dist}

  

- # We used to have a ansible-python3 package that a number of other things

- # started depending on, so we should now provide/obsolete it until they

- # can all adjust to just needing ansible.

- Provides:      ansible-python3 = %{version}-%{release}

- Obsoletes:     ansible-python3 < %{version}-%{release}

+ License:        GPLv3+

+ Source0:        %{pypi_source}

+ Url:            https://ansible.com

+ BuildArch:      noarch

  

- # Conflict with the ansible-base package for now.

- Conflicts: ansible-base > 2.10.0

- # Conflict with the ansible-core package for now also.

- Conflicts: ansible-core > 2.11.0

+ BuildRequires:  findutils

+ BuildRequires:  python3-devel

+ BuildRequires:  python3-setuptools

  

  %if 0%{?with_tests}

- #

- # For tests

- #

- # These two exist on both fedora and rhel8

- #

- BuildRequires: python3-packaging

- BuildRequires: python3-pexpect

- #

- # These only exist on Fedora. RHEL8 will just skip tests that need them.

- #

- %if 0%{?fedora}

- BuildRequires: python3-paramiko

- BuildRequires: python3-winrm

- 

- BuildRequires: python3-crypto

- BuildRequires: python3-pbkdf2

- BuildRequires: python3-httmock

- BuildRequires: python3-gitlab

- BuildRequires: python3-boto3

- BuildRequires: python3-botocore

- BuildRequires: python3-coverage

- BuildRequires: python3-passlib

+ # TODO build-requires

  %endif

- %endif

- # For Docs/tests

- BuildRequires: git-core

- BuildRequires: openssl

+ 

  %if 0%{?with_docs}

- BuildRequires: python3-sphinx

- BuildRequires: python3-sphinx-theme-alabaster

- BuildRequires: python3-sphinx-notfound-page

- BuildRequires: asciidoc

- BuildRequires: python3-straight-plugin

+ # TODO build-requires

  %endif

- BuildRequires: python3-devel

- BuildRequires: python3-setuptools

- # accelerate is the only thing that makes keyczar mandatory.  Since accelerate

- # is deprecated, just ignore it

- #BuildRequires: python-keyczar

- BuildRequires: python3-six

- # We pin Pytest to version 4 for now

- # as there are some test failures with

- # version 5. See rhbz#1841968

- BuildRequires: %{py3_dist pytest}

- BuildRequires: python3-pytest-xdist

- BuildRequires: python3-pytest-mock

- BuildRequires: python3-requests

- BuildRequires: python3-mock

- BuildRequires: python3-jinja2

- BuildRequires: python3-pyyaml

- BuildRequires: python3-cryptography

- BuildRequires: python3-pyvmomi

- BuildRequires: make

- 

- # RHEL8 doesn't have python3-paramiko or python3-winrm (yet), but Fedora does

- Recommends: python3-paramiko

- Recommends: python3-winrm

- # accelerate is the only thing that makes keyczar mandatory.  Since accelerate

- # is deprecated, just ignore it

- #Requires: python3-keyczar

- Requires: python3-setuptools

- Requires: python3-six

- Requires: python3-jinja2

- Requires: python3-pyyaml

- Requires: sshpass

- # needed for json_query filter

- Requires: python3-jmespath

  

  %description

  Ansible is a radically simple model-driven configuration management,
@@ -134,155 +33,86 @@ 

  on remote nodes. Extension modules can be written in any language and

  are transferred to managed machines automatically.

  

- %package -n ansible-doc

- Summary: Documentation for Ansible

+ This package provides a curated set of Ansible collections included in addition

+ to ansible-core.

  

- %description -n ansible-doc

+ %prep

+ %autosetup -n ansible-%{version}

  

- Ansible is a radically simple model-driven configuration management,

- multi-node deployment, and remote task execution system. Ansible works

- over SSH and does not require any software or daemons to be installed

- on remote nodes. Extension modules can be written in any language and

- are transferred to managed machines automatically.

+ # Remove unnecessary files and directories included in the Ansible collection release tarballs

+ # Tracked upstream in part by: https://github.com/ansible-community/community-topics/issues/29

+ echo "[START] Delete unnecessary files and directories"

  

- This package installs extensive documentation for ansible

+ # Collection tarballs contain a lot of hidden files and directories

+ hidden_pattern=".*\.(DS_Store|all-contributorsrc|ansible-lint|azure-pipelines|circleci|codeclimate.yml|flake8|galaxy_install_info|gitattributes|github|gitignore|gitkeep|gitlab-ci.yml|idea|keep|mypy_cache|nojekyll|orig|plugin-cache.yaml|pre-commit-config.yaml|project|pydevproject|pytest_cache|pytest_cache|readthedocs.yml|settings|swp|travis.yml|vscode|yamllint|yamllint.yaml|zuul.d|zuul.yaml)$"

+ find ansible_collections -regextype posix-egrep -regex "${hidden_pattern}" -print -depth -exec rm -rf {} \;

  

- %package -n ansible-test

- Summary: Tool for testing ansible plugin and module code

- Requires: %{name} = %{version}-%{release}

+ # TODO: Delete (bulky) tests for now but we should run sanity and unit tests soon.

+ find ansible_collections -type d -wholename "*tests/integration" -print -depth -exec rm -rf {} \;

+ find ansible_collections -type d -wholename "*tests/unit" -print -depth -exec rm -rf {} \;

+ find ansible_collections -type d -wholename "*tests/sanity" -print -depth -exec rm -rf {} \;

+ find ansible_collections -type d -wholename "*tests/regression" -print -depth -exec rm -rf {} \;

  

- %description -n ansible-test

- Ansible is a radically simple model-driven configuration management,

- multi-node deployment, and remote task execution system. Ansible works

- over SSH and does not require any software or daemons to be installed

- on remote nodes. Extension modules can be written in any language and

- are transferred to managed machines automatically.

+ # https://github.com/ansible-collections/kubernetes.core/pull/298

+ rm -rf ansible_collections/kubernetes/core/molecule

  

- This package installs the ansible-test command for testing modules and plugins

- developed for ansible.

+ # rpmlint W: pem-certificate

+ find ansible_collections/cyberark/conjur -type f -name "*.pem" -print -delete

  

+ # rpmlint E: zero-length

+ find -type f -name "*requirements.txt" -size 0 -print -delete

+ rm -f ansible_collections/community/zabbix/roles/zabbix_agent/files/win_sample/doSomething.ps1

  

- %prep

- %autosetup -p1

- cp -a %{S:1} %{S:2} %{S:3} .

+ echo "[END] Delete unnecessary files and directories"

  

  %build

- 

- # Fix some files shebangs

- sed -i -e 's|/usr/bin/env python|/usr/bin/python3|' test/lib/ansible_test/_data/*.py test/lib/ansible_test/_data/*/*.py test/lib/ansible_test/_data/*/*/*.py docs/bin/find-plugin-refs.py

- 

- # These we have to supress or the package will depend on /usr/bin/pwsh and not be installable.

- sed -i -s 's|/usr/bin/env pwsh||' test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/ps_argspec.ps1

- sed -i -s 's|/usr/bin/env pwsh||' test/lib/ansible_test/_data/sanity/pslint/pslint.ps1

- sed -i -s 's|/usr/bin/env pwsh||' test/lib/ansible_test/_data/requirements/sanity.ps1

- 

- # disable the python -s shbang flag as we want to be able to find non system modules

- %global py3_shbang_opts %(echo %{py3_shbang_opts} | sed 's/-s//')

+ %py3_shebang_fix ansible_collections

  %py3_build

  

- %if 0%{?with_docs}

-   make PYTHON=/usr/bin/python3 SPHINXBUILD=sphinx-build-3 webdocs

- %else

- make PYTHON=/usr/bin/python3 -Cdocs/docsite config cli keywords modules plugins testing

- %endif

- 

  %install

  %py3_install

  

- # Create system directories that Ansible defines as default locations in

- # ansible/config/base.yml

- DATADIR_LOCATIONS='%{_datadir}/ansible/collections

- %{_datadir}/ansible/collections/ansible_collections

- %{_datadir}/ansible/plugins/doc_fragments

- %{_datadir}/ansible/plugins/action

- %{_datadir}/ansible/plugins/become

- %{_datadir}/ansible/plugins/cache

- %{_datadir}/ansible/plugins/callback

- %{_datadir}/ansible/plugins/cliconf

- %{_datadir}/ansible/plugins/connection

- %{_datadir}/ansible/plugins/filter

- %{_datadir}/ansible/plugins/httpapi

- %{_datadir}/ansible/plugins/inventory

- %{_datadir}/ansible/plugins/lookup

- %{_datadir}/ansible/plugins/modules

- %{_datadir}/ansible/plugins/module_utils

- %{_datadir}/ansible/plugins/netconf

- %{_datadir}/ansible/roles

- %{_datadir}/ansible/plugins/strategy

- %{_datadir}/ansible/plugins/terminal

- %{_datadir}/ansible/plugins/test

- %{_datadir}/ansible/plugins/vars'

- 

- UPSTREAM_DATADIR_LOCATIONS=$(grep -ri default lib/ansible/config/base.yml| tr ':' '\n' | grep '/usr/share/ansible')

- 

- if [ "$SYSTEM_LOCATIONS" != "$UPSTREAM_SYSTEM_LOCATIONS" ] ; then

- 	echo "The upstream Ansible datadir locations have changed.  Spec file needs to be updated"

- 	exit 1

- fi

- 

- mkdir -p $RPM_BUILD_ROOT%{_datadir}/ansible/plugins/

- for location in $DATADIR_LOCATIONS ; do

- 	mkdir $RPM_BUILD_ROOT"$location"

- done

- mkdir -p $RPM_BUILD_ROOT/etc/ansible/

- mkdir -p $RPM_BUILD_ROOT/etc/ansible/roles/

- 

- cp examples/hosts $RPM_BUILD_ROOT/etc/ansible/

- cp examples/ansible.cfg $RPM_BUILD_ROOT/etc/ansible/

- mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man1

- cp -v docs/man/man1/*.1 $RPM_BUILD_ROOT/%{_mandir}/man1/

- 

- cp -pr docs/docsite/rst .

- %if 0%{?with_docs}

-   cp -pr docs/docsite/_build/html %{_builddir}/%{name}-%{version}/html

- %endif

- 

- install -Dpm0644 -t %{buildroot}%{_fileattrsdir} ansible.attr

- install -Dpm0644 -t %{buildroot}%{_rpmmacrodir} macros.ansible

- install -Dpm0755 -t %{buildroot}%{_rpmconfigdir} ansible-generator

- 

+ # Install docs and licenses

+ (

+   mkdir -p "%{buildroot}%{ansible_docdir}" "%{buildroot}%{ansible_licensedir}"

+   cd ansible_collections

+   # This finds the license file for each collection, copies it to

+   # `%%{ansible_licensedir}/collection_namespace/collection_name`, and then adds

+   # `%%license /path/to/license` to the %%files list. See `man find` for more info.

+   # The extra percent signs are needed to escape RPM.

+   find . -mindepth 3 -type f \( -name LICENSE -o -name COPYING \) \

+          -exec cp -p --parents '{}' '%{buildroot}%{ansible_licensedir}' \; \

+          -printf '%%%%license %%%%{ansible_licensedir}/%%P\n'  | tee -a ../files.list

+   # This does the same thing, but for READMEs.

+   find . -mindepth 3 -type f -name 'README.*' \

+          -exec cp -p --parents '{}' '%{buildroot}%{ansible_docdir}' \; \

+          -printf '%%%%doc %%%%{ansible_docdir}/%%P\n' | tee -a ../files.list

+ )

  

  %check

  %if 0%{?with_tests}

- ln -s /usr/bin/pytest-3 bin/pytest

- pathfix.py -i %{__python3} -p test/lib/ansible_test/_data/cli/ansible_test_cli_stub.py

- # This test needs a module not packaged in Fedora so disable it.

- rm -f test/units/modules/cloud/cloudstack/test_cs_traffic_type.py

- # These tests are failing with pytest 6

- rm -f test/units/module_utils/facts/hardware/test_sunos_get_uptime_facts.py

- rm -f test/units/modules/source_control/test_gitlab_runner.py

- rm -f test/units/plugins/lookup/test_aws_secret.py

- rm -f test/units/plugins/lookup/test_aws_ssm.py

- make PYTHON=/usr/bin/python3 tests-py3

+ # TODO: Run tests

  %endif

  

- %files

+ %files -f files.list

  %license COPYING

- %doc README.rst PKG-INFO changelogs/CHANGELOG-v2.9.rst

- %doc %{_mandir}/man1/ansible*

- %config(noreplace) %{_sysconfdir}/ansible/

- %{_bindir}/ansible*

- %{_datadir}/ansible/

- %{python3_sitelib}/ansible

- %{python3_sitelib}/ansible_test

+ %doc README.rst PKG-INFO porting_guide_5.rst CHANGELOG-v5.rst

+ # Note (dmsimard): This ansible package installs collections to the python sitelib to mirror the UX

+ # when installing the ansible package from PyPi.

+ # This allows users to install individual collections manually with ansible-galaxy (~/.ansible/collections/ansible_collections)

+ # or via standalone distribution packages to datadir (/usr/share).

+ # Both will have precedence over the collections installed in the python sitelib.

+ %{python3_sitelib}/ansible_collections

  %{python3_sitelib}/*egg-info

- %{_fileattrsdir}/ansible.attr

- %{_rpmmacrodir}/macros.ansible

- %{_rpmconfigdir}/ansible-generator

- %exclude %{_bindir}/ansible-test

- %exclude %{python3_sitelib}/ansible_test

- 

- %files -n ansible-doc

- %doc rst

- %if 0%{?with_docs}

- %doc html

- %endif

- 

- %files -n ansible-test

- %{_bindir}/ansible-test

- %{python3_sitelib}/ansible_test

  

  %changelog

+ * Tue Jan 11 2022 David Moreau-Simard <moi@dmsimard.com> - 5.1.0-1

+ - Update to latest upstream release

+ - Refactor to take into account split from ansible-core after ansible 2.9, see: https://fedoraproject.org/wiki/Changes/Ansible5

+ - Remove patches intended for Ansible 2.9

+ - Removed packaging macros (soon included in ansible-packaging, see rhbz#2038591)

+ - Removed provides/obsoletes on ansible-python3

+ 

  * Mon Nov 01 2021 Kevin Fenzi <kevin@scrye.com> - 2.9.27-2

  - Add patch for oracle linux Fixes rhbz#2018369

  

@@ -1,43 +0,0 @@ 

- diff --color -Nur ansible-2.9.16.orig/test/lib/ansible_test/_data/completion/docker.txt ansible-2.9.16/test/lib/ansible_test/_data/completion/docker.txt

- --- ansible-2.9.16.orig/test/lib/ansible_test/_data/completion/docker.txt	2020-12-14 15:48:25.000000000 -0800

- +++ ansible-2.9.16/test/lib/ansible_test/_data/completion/docker.txt	2020-12-17 11:38:44.409269125 -0800

- @@ -1,4 +1,4 @@

- -default name=quay.io/ansible/default-test-container:1.10.1 python=3.6,2.6,2.7,3.5,3.7,3.8 seccomp=unconfined

- +default name=quay.io/ansible/default-test-container:1.10.1 python=3.6,2.6,2.7,3.5,3.7,3.8,3.9,3.10 seccomp=unconfined

-  centos6 name=quay.io/ansible/centos6-test-container:1.26.0 python=2.6 seccomp=unconfined

-  centos7 name=quay.io/ansible/centos7-test-container:1.8.0 python=2.7 seccomp=unconfined

-  centos8 name=quay.io/ansible/centos8-test-container:1.10.0 python=3.6 seccomp=unconfined

- diff --color -Nur ansible-2.9.16.orig/test/lib/ansible_test/_data/sanity/compile/compile.py ansible-2.9.16/test/lib/ansible_test/_data/sanity/compile/compile.py

- --- ansible-2.9.16.orig/test/lib/ansible_test/_data/sanity/compile/compile.py	2020-12-14 15:48:25.000000000 -0800

- +++ ansible-2.9.16/test/lib/ansible_test/_data/sanity/compile/compile.py	2020-12-17 11:36:47.712080958 -0800

- @@ -3,9 +3,16 @@

-  from __future__ import (absolute_import, division, print_function)

-  __metaclass__ = type

-  

- -import parser

- -import sys

- +import warnings

- +

- +with warnings.catch_warnings():

- +    # The parser module is deprecated as of Python 3.9.

- +    # This implementation will need to be updated to use another solution.

- +    # Until then, disable the deprecation warnings to prevent test failures.

- +    warnings.simplefilter('ignore', DeprecationWarning)

- +    import parser

-  

- +import sys

-  

-  def main():

-      status = 0

- diff --color -Nur ansible-2.9.16.orig/test/lib/ansible_test/_internal/util.py ansible-2.9.16/test/lib/ansible_test/_internal/util.py

- --- ansible-2.9.16.orig/test/lib/ansible_test/_internal/util.py	2020-12-14 15:48:25.000000000 -0800

- +++ ansible-2.9.16/test/lib/ansible_test/_internal/util.py	2020-12-17 11:36:47.713080960 -0800

- @@ -110,6 +110,8 @@

-      '3.6',

-      '3.7',

-      '3.8',

- +    '3.9',

- +    '3.10',

-  )

-  

-  

file removed
-7
@@ -1,7 +0,0 @@ 

- %ansible_collection_url() https://galaxy.ansible.com/%{collection_namespace}/%{collection_name}

- 

- %ansible_collection_build() ansible-galaxy collection build

- 

- %ansible_collection_install() ansible-galaxy collection install -n -p %{buildroot}%{_datadir}/ansible/collections %{collection_namespace}-%{collection_name}-%{version}.tar.gz

- 

- %ansible_collection_files %{_datadir}/ansible/collections/ansible_collections/%{collection_namespace}/

You should not remove this or ansible-generator. These macros are used by the ansible-collection-* packages.

file modified
+1 -1
@@ -1,1 +1,1 @@ 

- SHA512 (ansible-2.9.27.tar.gz) = 99987b8a1d243ef3496d66178774c33b05951daaff584b12e645c0176391805f90d00780e86adec01316b28645287489326218c0de7c10084552da90848735c7

+ SHA512 (ansible-5.1.0.tar.gz) = 445cb3cc0bd31f13476e242bc48bc0213547ede514ce94528d689b5e1f75a52e355a8cf58b9331dcdb005d9c48ece478aa69429383a99eff8acd800a2296035a

rebased onto 2e7bd6460b9362f8f98de3cac7071a6e7be72c5c

a year ago

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

The rpm-linter job picks up a lot of issues:
2 packages and 1 specfiles checked; 8165 errors, 380 warnings.

Some breakdown:

> curl -s https://gist.githubusercontent.com/dmsimard/3db2e2dda73acf8fd7115a55d6c6e5ae/raw/2fefff5394c54363654abfe56bdae5cde6f11e36/rpm-lint.txt |awk '{print $3}' |sort |uniq -c |sort -rn
   7678 non-executable-script
    359 zero-length
    332 hidden-file-or-dir
    123 version-control-internal-file
     44 pem-certificate
      3 backup-file-in-package
      2 uncompressed-zip
      2 invalid-version
      1 incoherent-version-in-changelog
      1 devel-file-in-non-devel-package

The rpm-install-test fails on quite an oddly specific error:

Transaction Summary
================================================================================
Install  13 Packages

Total size: 46 M
Total download size: 3.4 M
Installed size: 369 M
Downloading Packages:
(1/12): python3-bcrypt-3.2.0-1.fc35.x86_64.rpm   73 kB/s |  43 kB     00:00    
(2/12): python3-jmespath-0.10.0-4.fc35.noarch.r 1.5 MB/s |  46 kB     00:00    
(3/12): libsodium-1.0.18-8.fc35.x86_64.rpm      253 kB/s | 161 kB     00:00    
(4/12): python3-ntlm-auth-1.5.0-4.fc35.noarch.r 1.2 MB/s |  53 kB     00:00    
(5/12): python3-paramiko-2.8.0-1.fc36.noarch.rp 4.2 MB/s | 287 kB     00:00    
(6/12): python3-pyasn1-0.4.8-7.fc35.noarch.rpm  2.3 MB/s | 134 kB     00:00    
(7/12): python3-pynacl-1.4.0-4.fc35.x86_64.rpm  2.8 MB/s | 108 kB     00:00    
(8/12): python3-requests_ntlm-1.1.0-16.fc35.noa 557 kB/s |  18 kB     00:00    
(9/12): python3-resolvelib-0.5.5-3.fc35.noarch. 1.0 MB/s |  31 kB     00:00    
(10/12): python3-winrm-0.4.1-4.fc35.noarch.rpm  2.4 MB/s |  80 kB     00:00    
(11/12): python3-xmltodict-0.12.0-13.fc35.noarc 822 kB/s |  22 kB     00:00    
(12/12): ansible-core-2.12.0-1.fc36.noarch.rpm  2.9 MB/s | 2.4 MB     00:00    
--------------------------------------------------------------------------------
Total                                           3.9 MB/s | 3.4 MB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Error: Transaction test error:
  file /usr/lib/python3.10/site-packages/ansible_collections/google/cloud/tests/integration/targets/gcp_compute_region_target_https_proxy/meta/main.yml conflicts between attempted installs of ansible-5.0.0rc1-1.fc36.noarch and ansible-5.0.0rc1-1.fc36.noarch

A lot of these errors (include that google.cloud integration test one) are due to unnecessary files that are included in the ansible galaxy collection release tarballs.

I will first do an exercise of trying to tidy up the obvious unnecessary files and see if we can get that number in a more reasonable territory.

1 new commit added

  • Remove unnecessary files and address rpmlint errors
a year ago

In https://src.fedoraproject.org/fork/dmsimard/rpms/ansible/c/4910dc7897c1ed8ff20d3cab471ba854647f8d08 I did a reasonable cleanup and got the following locally:

# ...
+ rm -rf ansible_collections/hpe/nimble/tests/sanity/ignore-2.10.txt
+ count=24587
+ for tests in $(find ansible_collections | grep -E "tests/unit|tests/integration|tests/utils|tests/sanity|tests/runner|tests/regression")
+ rm -rf ansible_collections/hpe/nimble/tests/sanity/ignore-2.11.txt
+ count=24588
+ rm -rf ansible_collections/kubernetes/core/molecule
+ echo 'Over 24588 files and directories removed.'
Over 24588 files and directories removed.

Between that and the two rules in the rpmlintrc:
- addFilter("E: non-executable-script") <-- because ansible modules are not executable
- addFilter("W: files-duplicate") <-- noisy, wasn't included by zuul but got a sizeable number when running locally

I got the rpm-lint errors/warnings down to <20 or so and should have also fixed the transaction test error in the process.

This also shrunk down the size of ansible-5.0.0rc1-1.fc36.noarch.rpm from 43M to 33M.

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

Between that and the two rules in the rpmlintrc:
- addFilter("E: non-executable-script") <-- because ansible modules are not executable

You should do something like this1, instead.

You should not remove this or ansible-generator. These macros are used by the ansible-collection-* packages.

You should not remove this or ansible-generator. These macros are used by the ansible-collection-* packages.

Actually, these are already included in ansible-core. I think we can remove them as long as we make sure all of the packages that depend on them switch their BuildRequires to ansible-core.

Does epel support %pypi_source? If so, you should probably use that instead.

Does epel support %pypi_source? If so, you should probably use that instead.

I'm not sure if this will ever make it to EPEL 8, but it is a good idea to remain compatible in this case.

This is where the rpmlint changelog error comes from. The changelog version does not match the Version tag.

We also need to figure out how to handle the license and README files, which need to be marked with %license and %doc, respectively. My understanding is that each collection has its own license and README.

If you take a look at this ansible specfile1 that someone else created, you'll see what I mean. It seems that the only reasonable way to do this is to programmatically find these files, save the output to a file, and pass that to %files -f. This is how %pyproject_save_files works. @kevin, do you have any ideas here? This is obviously not an ideal situation.


If the source package includes the text of the license(s) in its own file, then that file, containing the text of the license(s) for the package must be included in %license.

-- https://docs.fedoraproject.org/en-US/packaging-guidelines/LicensingGuidelines/#_license_text

A few comments/etc.

  • On the nuked tests: Is there any value to keeping them and running them in %check? I would guess they all pass upstream, but it might be nice to run any we can easily at least on build so we know when something breaks downstream.

  • I have no magic idea on the license/readmes, other than we could pull them all out and include them in %license (but then we would have to de-ambiguate them, but perhaps that could be done with the prefix dir they were in or something?)

  • We should update the package summary here to talk about this being the collection of collections, the engine being in ansible-core, etc.

  • We should update everything that buildrequires: ansible to buildrequire: ansible-core (not really this pr's thing, but just mentioning it). We should be able to do that anytime.

Between that and the two rules in the rpmlintrc:
- addFilter("E: non-executable-script") <-- because ansible modules are not executable

You should do something like this[1], instead.

[1]: https://src.fedoraproject.org/rpms/ansible-collection-community-general/blob/rawhide/f/ansible-collection-community-general.spec#_25

Thanks for reviewing @gotmax23 !

My understanding from that command is that it removes shebangs from all non-executable python files.

There's a mention of shebangs in the Ansible docs but I asked #ansible-devel about whether or not the shebangs were required and was recommended that they are kept to avoid unexpected issues.

it turns out that removing the shebang doesn't break (most) modules because it actually defaults back to /usr/bin/python but it is otherwise used to determine the interpreter to use.

I've never done ansible modules in perl or ruby but apparently it's a thing. I also know that the intent of a shebang is to set an interpreter should the file be executable (hence the rpmlint warning), thus Ansible is "special" in how it wants to use and parse them.

The odds of breaking an Ansible python module by removing the shebang are low given the default behavior but it not something people are expected to rely on.

You should not remove this or ansible-generator. These macros are used by the ansible-collection-* packages.

Actually, these are already included in ansible-core. I think we can remove them as long as we make sure all of the packages that depend on them switch their BuildRequires to ansible-core.

Good catch -- indeed, if they are already in ansible-core we should do that.

Does epel support %pypi_source? If so, you should probably use that instead.

I'm not sure if this will ever make it to EPEL 8, but it is a good idea to remain compatible in this case.

Good question -- I merely replaced the existing source with the right one here.
If %pypi_source works wherever we want to use it, we can switch to that -- I don't have a strong opinion about this.

This is where the rpmlint changelog error comes from. The changelog version does not match the Version tag.

Right, that was intentional -- ansible 5.0.0 is being released tomorrow and my expectation was that the source version would match the changelog version when that happens.

We also need to figure out how to handle the license and README files, which need to be marked with %license and %doc, respectively. My understanding is that each collection has its own license and README.

Fairly accurate, yes.

If you take a look at this ansible specfile[1] that someone else created, you'll see what I mean. It seems that the only reasonable way to do this is to programmatically find these files, save the output to a file, and pass that to %files -f. This is how %pyproject_save_files works.

I had taken a glance at that spec a while back and there are perhaps opportunities to draw inspiration from it but the approach you suggest is interesting and I didn't know you could do that -- thanks for sharing.

The READMEs and the license files are probably the minimum to include, indeed.

One of the things on my to-do list is to learn how the docs are built nowadays in order to understand if we can include them easily in the package. We are definitely building documentation that includes the collections from the package to end up with something like this: https://docs.ansible.com/ansible/latest/collections/index_module.html

On the other hand, if you have ideas of how we could make this easier upstream, I am also glad to hear them. I may not be able to do everything myself but I will probably know who to talk to.

A few comments/etc.

  • On the nuked tests: Is there any value to keeping them and running them in %check? I would guess they all pass upstream, but it might be nice to run any we can easily at least on build so we know when something breaks downstream.

I would like to do that, yes -- though it is a potential rabbithole that I didn't want to go down just yet. In a nutshell: there's unit tests (python) and integration tests (playbooks) and they are typically run with ansible-test which is quite opinionated.

I would be curious to know if there's any precedent or prior art for running ansible-test within the context of building an rpm.

  • I have no magic idea on the license/readmes, other than we could pull them all out and include them in %license (but then we would have to de-ambiguate them, but perhaps that could be done with the prefix dir they were in or something?)

The spec file that gotmax123 linked includes the relative path to the files. Is that what you mean by disambiguate ?

  • We should update the package summary here to talk about this being the collection of collections, the engine being in ansible-core, etc.

Indeed.

  • We should update everything that buildrequires: ansible to buildrequire: ansible-core (not really this pr's thing, but just mentioning it). We should be able to do that anytime.

Right, especially if we remove the macros here which are now duplicated in ansible-core.

The spec file that gotmax123 linked includes the relative path to the files. Is that what you mean by disambiguate ?

Unfortunately, those relative paths don't actually work and they cause rpmbuild to fall.
So, that "example" specfile doesn't even build. Instead of creating the proper directory structure under /usr/share/doc/ansible, RPM tries to copy every single README into the top level directory which obviously doesn't work. The same issue occurs with the license files.

  • We should update everything that buildrequires: ansible to buildrequire: ansible-core (not really this pr's thing, but just mentioning it). We should be able to do that anytime.

Right, especially if we remove the macros here which are now duplicated in ansible-core.

We should also use this opportunity to get rid this and fix the packages that still depend on ansible-python3:

# We used to have a ansible-python3 package that a number of other things

# started depending on, so we should now provide/obsolete it until they 

# can all adjust to just needing ansible.

Provides:      ansible-python3 = %{version}-%{release}

Obsoletes:     ansible-python3 < %{version}-%{release}

We also need to figure out how to handle the license and README files, which need to be marked with %license and %doc, respectively. My understanding is that each collection has its own license and README.

Fairly accurate, yes.

If you take a look at this ansible specfile1 that someone else created, you'll see what I mean. It seems that the only reasonable way to do this is to programmatically find these files, save the output to a file, and pass that to %files -f. This is how %pyproject_save_files works.

I had taken a glance at that spec a while back and there are perhaps opportunities to draw inspiration from it but the approach you suggest is interesting and I didn't know you could do that -- thanks for sharing.

The READMEs and the license files are probably the minimum to include, indeed.

I took a stab at this. Here1 is a gist containing a Git patch that you can apply on top of your PR. I should probably clean it up and add some explanatory comments (the find commands are a little ugly), but I wanted to see what you thought about the patch first.

Between that and the two rules in the rpmlintrc:
- addFilter("E: non-executable-script") <-- because ansible modules are not executable

You should do something like this[1], instead.

[1]: https://src.fedoraproject.org/rpms/ansible-collection-community-general/blob/rawhide/f/ansible-collection-community-general.spec#_25

Thanks for reviewing @gotmax23 !

My understanding from that command is that it removes shebangs from all non-executable python files.

There's a mention of shebangs in the Ansible docs but I asked #ansible-devel about whether or not the shebangs were required and was recommended that they are kept to avoid unexpected issues.

it turns out that removing the shebang doesn't break (most) modules because it actually defaults back to /usr/bin/python but it is otherwise used to determine the interpreter to use.

I've never done ansible modules in perl or ruby but apparently it's a thing. I also know that the intent of a shebang is to set an interpreter should the file be executable (hence the rpmlint warning), thus Ansible is "special" in how it wants to use and parse them.

The odds of breaking an Ansible python module by removing the shebang are low given the default behavior but it not something people are expected to rely on.

Fair enough. Thanks for looking into this!

1 new commit added

  • Update to 5.0.1 and incorporate review feedback
a year ago

Pushed a commit that updates to 5.0.1 and incorporates some of the feedback so far.

@gotmax23 I've applied your docs/license patch for now but I think it needs a bit of tweaking to reduce some of the false positives it gets (like /usr/share/doc/ansible/awx/awx/tools/roles/template_galaxy/templates/README.md.j2 or /usr/share/doc/ansible/netapp/ontap/playbooks/examples/json_query/README.md for example).
Maybe we could add a maxdepth to the find in addition to the mindepth ?

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

Pushed a commit that updates to 5.0.1 and incorporates some of the feedback so far.

Looks good.

@gotmax23 I've applied your docs/license patch for now but I think it needs a bit of tweaking to reduce some of the false positives it gets (like /usr/share/doc/ansible/awx/awx/tools/roles/template_galaxy/templates/README.md.j2 or /usr/share/doc/ansible/netapp/ontap/playbooks/examples/json_query/README.md for example).
Maybe we could add a maxdepth to the find in addition to the mindepth ?

You are welcome to add -maxdepth. Just make sure you account for the fact that some of the collections contain roles that have their own license files and READMEs. Alternatively, we can use -not -path to exclude specific files. It probably makes sense to ask the maintainers of the collections that have the same license file duplicated in the roles/* directories to remove them if possible.

You should remove this. It is unnecessary as this requirement is already covered by the RPM Python runtime dependency generator.

From the Fedora Python Packaging Guidelines:

Dependencies covered by the generators SHOULD NOT be repeated in the .spec file. (For example, if the generator finds a requests dependency, then Requires: python3-requests is redundant.)

The only other nitpick I see is:

warning: File listed twice: /usr/share/doc/ansible
warning: File listed twice: /usr/share/licenses/ansible

Should not list those twice?

I know that some of the Red Hat people are off right now, so if that's the case, feel free to respond whenever you get back 😀.

The only other nitpick I see is:

warning: File listed twice: /usr/share/doc/ansible
warning: File listed twice: /usr/share/licenses/ansible

Should not list those twice?

We can fix that by removing %doc README.rst PKG-INFO porting_guide_5.rst CHANGELOG-v5.rst and %license COPYING and installing those files manually. Alternatively, we can remove %license %{ansible_licensedir} and %{ansible_docdir} and have the find command add the path of each license/README it finds to a file to pass to %files -f, as I originally suggested. Or, we can just ignore it.

Besides that, I think this PR should be good to go.

From eef9bb35088854769108df94a312b08e33fdb85f Mon Sep 17 00:00:00 2001
From: Maxwell G <gotmax@e.email>
Date: Tue, 21 Dec 2021 22:23:05 -0600
Subject: [PATCH] A couple changes

- Satisfy my OCD brain by fixing the indentation
- Remove seemingly unnecessary python3-pip BR
- Update the LICENSE and README logic
---
 ansible.spec | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/ansible.spec b/ansible.spec
index fce7143..11751bc 100644
--- a/ansible.spec
+++ b/ansible.spec
@@ -4,22 +4,19 @@
 %global ansible_licensedir %{_defaultlicensedir}/ansible
 %global ansible_docdir %{_defaultdocdir}/ansible

-Name: ansible
-Summary: Curated set of Ansible collections included in addition to ansible-core
-Version: 5.0.1
-Release: 1%{?dist}
+Name:           ansible
+Summary:        Curated set of Ansible collections included in addition to ansible-core
+Version:        5.1.0
+Release:        1%{?dist}

-License: GPLv3+
-Source0: https://pypi.io/packages/source/a/%{name}/%{name}-%{version}.tar.gz
-Url: https://ansible.com
-BuildArch: noarch
-
-Requires: ansible-core >= 2.12.0
+License:        GPLv3+
+Source0:        %{pypi_source}
+Url:            https://ansible.com
+BuildArch:      noarch

 BuildRequires:  findutils
 BuildRequires:  python3-devel
 BuildRequires:  python3-setuptools
-BuildRequires:  python3-pip

 %if 0%{?with_tests}
 # TODO build-requires
@@ -70,8 +67,17 @@ echo "Over ${count} files and directories removed."
 (
   mkdir -p "%{buildroot}%{ansible_docdir}" "%{buildroot}%{ansible_licensedir}"
   cd ansible_collections
-  find . -mindepth 3 -type f \( -name LICENSE -o -name COPYING \) -print -exec cp -p --parents '{}' '%{buildroot}%{ansible_licensedir}' \;
-  find . -mindepth 3 -type f -name 'README.*' -print -exec cp -p --parents '{}' '%{buildroot}%{ansible_docdir}' \;
+  # This finds the license file for each collection, copies it to
+  # `%%{ansible_licensedir}/collection_namespace/collection_name`, and then adds
+  # `%%license /path/to/license` to the %%files list. See `man find` for more info.
+  # The extra percent signs are needed to escape RPM.
+  find . -mindepth 3 -type f \( -name LICENSE -o -name COPYING \) \
+         -exec cp -p --parents '{}' '%{buildroot}%{ansible_licensedir}' \; \
+         -printf '%%%%license %%%%{ansible_licensedir}/%%P\n'  | tee -a ../files.list
+  # This does the same thing, but for READMEs.
+  find . -mindepth 3 -type f -name 'README.*' \
+         -exec cp -p --parents '{}' '%{buildroot}%{ansible_docdir}' \; \
+         -printf '%%%%doc %%%%{ansible_docdir}/%%P\n' | tee -a ../files.list
 )

 %check
@@ -79,11 +85,9 @@ echo "Over ${count} files and directories removed."
 # TODO: Run tests
 %endif

-%files
+%files -f files.list
 %license COPYING
-%license %{ansible_licensedir}
 %doc README.rst PKG-INFO porting_guide_5.rst CHANGELOG-v5.rst
-%{ansible_docdir}
 # Note (dmsimard): The ansible package installs collections to the python sitelib to mirror the UX
 # when installing the ansible package from PyPi.
 # Standalone collection packages may install to datadir (/usr/share) instead and they will
@@ -92,7 +96,7 @@ echo "Over ${count} files and directories removed."
 %{python3_sitelib}/*egg-info

 %changelog
-* Tue Nov 23 2021 David Moreau-Simard <moi@dmsimard.com> - 5.0.1-1
+* Tue Nov 23 2021 David Moreau-Simard <moi@dmsimard.com> - 5.1.0-1
 - Update to latest upstream release

 * Mon Nov 01 2021 Kevin Fenzi <kevin@scrye.com> - 2.9.27-2
-- 
2.33.1

Hi and apologies for neglecting this PR.

I will do another round of changes based on feedback and we can determine if it's good to go afterwards.

Thanks for your patience !

3 new commits added

  • Add source for 5.1.0
  • Escape periods in pattern match to avoid false positives
  • Update to 5.1.0 and incorporate feedback
a year ago

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.

rebased onto 44ef4d0d05c7a274cd153ad44cb1d775925fe1e8

a year ago

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.

rebased onto 62eb1098d8163baddf9664d0ffd65ee611e58455

a year ago

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

Hi and apologies for neglecting this PR.

I will do another round of changes based on feedback and we can determine if it's good to go afterwards.

Thanks for your patience !

No problem! Thanks again for all your work on this, @dmsimard! It looks like there are still some rpmlint errors to fix. I left some comments about them below. I think you should also remove the bundled .egg-info in %prep. Besides that, everything LGTM.

# Spurious
ansible.noarch: W: name-repeated-in-summary C Ansible

# Ideally, upstream can remove these files from git entirely.
# Otherwise, you can use `find -type f -name '*requirements.txt' -size 0`
# to find all *empty* requirements.txt files. To delete them, you can pass
`-delete -print` to find or loop over the output and use `rm -rf` as you have been.
ansible.noarch: E: zero-length /usr/lib/python3.10/site-packages/ansible_collections/ansible/posix/requirements.txt
ansible.noarch: E: zero-length /usr/lib/python3.10/site-packages/ansible_collections/cloud/common/requirements.txt
ansible.noarch: E: zero-length /usr/lib/python3.10/site-packages/ansible_collections/community/okd/test-requirements.txt

ansible.noarch: W: hidden-file-or-dir /usr/lib/python3.10/site-packages/ansible_collections/community/grafana/.all-contributorsrc
ansible.noarch: E: zero-length /usr/lib/python3.10/site-packages/ansible_collections/community/zabbix/roles/zabbix_agent/files/win_sample/doSomething.ps1

# You should add these endings to your regex
ansible.noarch: W: hidden-file-or-dir /usr/lib/python3.10/site-packages/ansible_collections/containers/podman/docs/.nojekyll
ansible.noarch: E: zero-length /usr/lib/python3.10/site-packages/ansible_collections/containers/podman/docs/.nojekyll
ansible.noarch: W: hidden-file-or-dir /usr/lib/python3.10/site-packages/ansible_collections/cyberark/conjur/.codeclimate.yml

# I would just manually `rm -rf ansible_collections/cberark/conjur/roles/*/tests`
ansible.noarch: W: pem-certificate /usr/lib/python3.10/site-packages/ansible_collections/cyberark/conjur/roles/conjur_host_identity/tests/conjur.pem
ansible.noarch: W: pem-certificate /usr/lib/python3.10/site-packages/ansible_collections/cyberark/conjur/tests/conjur_variable/conjur.pem
ansible.noarch: W: pem-certificate /usr/lib/python3.10/site-packages/ansible_collections/cyberark/conjur/tests/conjur_variable/test_cases/retrieve-variable-bad-certs/bad-cert.pem

ansible.noarch: W: hidden-file-or-dir /usr/lib/python3.10/site-packages/ansible_collections/dellemc/os10/roles/os10_prefix_list/meta/.galaxy_install_info
ansible.noarch: E: zero-length /usr/lib/python3.10/site-packages/ansible_collections/ibm/qradar/test-requirements.txt

# You should add these endings to your regex
ansible.noarch: W: hidden-file-or-dir /usr/lib/python3.10/site-packages/ansible_collections/kubernetes/core/.zuul.d
ansible.noarch: W: hidden-file-or-dir /usr/lib/python3.10/site-packages/ansible_collections/kubernetes/core/.zuul.d
ansible.noarch: W: hidden-file-or-dir /usr/lib/python3.10/site-packages/ansible_collections/mellanox/onyx/.project
ansible.noarch: W: hidden-file-or-dir /usr/lib/python3.10/site-packages/ansible_collections/mellanox/onyx/.pydevproject
ansible.noarch: W: hidden-file-or-dir /usr/lib/python3.10/site-packages/ansible_collections/netbox/netbox/.readthedocs.yml
ansible.noarch: E: zero-length /usr/lib/python3.10/site-packages/ansible_collections/openvswitch/openvswitch/requirements.txt

# See above
ansible.noarch: E: zero-length /usr/lib/python3.10/site-packages/ansible_collections/splunk/es/requirements.txt
ansible.noarch: E: zero-length /usr/lib/python3.10/site-packages/ansible_collections/splunk/es/test-requirements.txt
ansible.src: W: name-repeated-in-summary C Ansible
2 packages and 1 specfiles checked; 9 errors, 14 warnings.

1 new commit added

  • Tweak file deletion and fix rpmlint warnings
a year ago

Should have addressed most issues in this last commit I think.
I took some time to clean things up a bit too. It sort of grew organically and became a bit unwieldy :)

I also fired off a scratch build: https://koji.fedoraproject.org/koji/taskinfo?taskID=81084450

I think you should also remove the bundled .egg-info in %prep.

@gotmax23 could I ask you to please expand on why ? It seems to me it was included before and so I left it there: https://src.fedoraproject.org/rpms/ansible/blob/rawhide/f/ansible.spec#_268

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

1 new commit added

  • Fix more rpmlint warnings and errors
a year ago

Plenty of new rpmlint warnings/errors because we don't delete unit tests anymore in expectation that we'll be able to run them in %check soon -- I'll leave them out for now so we can at least land this PR and we can take care of %check in another PR.

3 new commits added

  • Fix more rpmlint warnings and errors
  • Tweak file deletion and fix rpmlint warnings
  • Refactor and update to upstream 5.1.0
a year ago

Build succeeded.

This looks ready to merge now. I would switch find [...] -depth -exec rm -rf {} \; to find [...] -delete to be more concise, but everything else looks great.

I have also started working on enabling unit tests in ansible-collection-community-general. Hopefully, that can serve as a guide for how to implement it here.

Kevin, I would be happy to help maintain this package if that's something you're interested in.

This looks ready to merge now. I would switch find [...] -depth -exec rm -rf {} \; to find [...] -delete to be more concise, but everything else looks great.

The results from the find include a mixture of both files and directories and my understanding is that -delete doesn't work for directories, just files.

I also agree that this is a good start to continue working on if there are no objections to merge it as is but I can also squash those last few commits into the first one so it's cleaner.

+1 to merge and iterate from here. ;)

@gotmax23 happy to have you co-maintain...

rebased onto c947a30

a year ago

I've squashed the commits, cleaned up the comment about why the package installs the collections in python sitelib and also updated the changelog to be meaningful.

Ship it :)

I've added you both too, so you can merge/build/etc.

Thanks for all the work on this.

Pull-Request has been merged by kevin

a year ago

Build succeeded.

We just effectively caused FTI issues for the two packages that still depend on ansible-python3: python3-ansible-inventory-grapher and python3-testinfra. We should fix those packages ASAP.

I would recommend changing Requires: ansible-python3 to the following:

%if 0%{?fedora} >= 36
Requires: ansible-core
%else
Requires: (ansible-core or ansible)
%endif

This will allow users to choose between ansible 2.9 and ansible-core 2.11 when available, while avoiding unnecessarily pulling in the entire collections bundle on F36 and above. Packages that really do require other content that's not part of ansible-core should depend on the appropriate collection (ansible-collection(namespace.name)), instead of the entire bundle, if possible.

We just effectively caused FTI issues for the two packages that still depend on ansible-python3: python3-ansible-inventory-grapher and python3-testinfra. We should fix those packages ASAP.

I would recommend changing Requires: ansible-python3 to the following:

spec %if 0%{?fedora} >= 36 Requires: ansible-core %else Requires: (ansible-core or ansible) %endif

This will allow users to choose between ansible 2.9 and ansible-core 2.11 when available, while avoiding unnecessarily pulling in the entire collections bundle on F36 and above. Packages that really do require other content that's not part of ansible-core should depend on the appropriate collection (ansible-collection(namespace.name)), instead of the entire bundle, if possible.

https://src.fedoraproject.org/rpms/python-testinfra/pull-request/4