Skip to content

Commit

Permalink
Merge pull request #29 from RedHatSatellite/rel211
Browse files Browse the repository at this point in the history
release 2.1.1
  • Loading branch information
evgeni authored Jun 24, 2021
2 parents fcbb2aa + 1b1e755 commit c02ca44
Show file tree
Hide file tree
Showing 26 changed files with 1,595 additions and 528 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
with:
python-version: ${{ matrix.python }}
- name: Restore pip cache
uses: actions/[email protected].5
uses: actions/[email protected].6
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
with:
python-version: "3.7"
- name: Restore pip cache
uses: actions/[email protected].5
uses: actions/[email protected].6
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
Expand All @@ -128,7 +128,7 @@ jobs:
with:
python-version: "3.7"
- name: Restore pip cache
uses: actions/[email protected].5
uses: actions/[email protected].6
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
Expand All @@ -153,7 +153,7 @@ jobs:
with:
python-version: "3.7"
- name: Restore pip cache
uses: actions/[email protected].5
uses: actions/[email protected].6
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
Expand Down
4 changes: 4 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ Richard Stempfl <[email protected]> <[email protected]>
Richard Stempfl <[email protected]> <[email protected]>
Adam Růžička <[email protected]>
Adam Růžička <[email protected]> <[email protected]>
Yifat Makias <[email protected]>
Yifat Makias <[email protected]> <[email protected]>
Quirin Pamp <[email protected]> <[email protected]>
Quirin Pamp <[email protected]>
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ redhat.satellite Release Notes

This changelog describes changes after version 0.8.1.

v2.1.1
======

Bugfixes
--------

- external_usergroup - always lookup the ID of the usergroup, instead of passing the name to the API (https://bugzilla.redhat.com/show_bug.cgi?id=1967649)
- host, hostgroup - don't override already set parameters when passing an activation key only (and vice versa) (https://bugzilla.redhat.com/show_bug.cgi?id=1967904)

v2.1.0
======

Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,11 @@ branding:
sed -i 's/foreman.example.com/satellite.example.com/g' plugins/*/*.py docs/cvmanager.md roles/*/README.md roles/*/*/*.yml
sed -i 's#theforeman/foreman-ansible-modules#RedHatSatellite/satellite-ansible-collection#g' .github/workflows/*.yml
sed -i 's/theforeman-foreman/redhat-satellite/g' .github/workflows/*.yml
sed -i 's/Foreman Ansible Modules/Red Hat Satellite Ansible Collection/g' docs/index.rst docs/conf.py docs/cvmanager.md
sed -i 's/Foreman Ansible Modules/Red Hat Satellite Ansible Collection/g' docs/index.rst docs/conf.py docs/cvmanager.md docs/_gh_include/*.inc
sed -i 's/The Foreman Project/Red Hat, Inc./g' docs/conf.py
sed -i '/FOREMAN_\w/ s/FOREMAN_/SATELLITE_/g' plugins/doc_fragments/foreman.py plugins/module_utils/foreman_helper.py Makefile
sed -i '/foreman_\w/ s/foreman_/satellite_/g' roles/*/README.md roles/*/*/*.yml
sed -i 's#theforeman.github.io/foreman-ansible-modules#redhatsatellite.github.io/satellite-ansible-collection#g' roles/*/README.md
sed -i '/foreman_\w.*:/ s/foreman_/satellite_/g' tests/test_playbooks/*_role.yml docs/cvmanager.md
rm -rf tests/test_playbooks/scc_* tests/test_playbooks/tasks/scc_* tests/test_playbooks/fixtures/scc_* plugins/modules/scc_*.py tests/fixtures/apidoc/scc_*.json
rm -rf tests/test_playbooks/snapshot* tests/test_playbooks/tasks/snapshot* tests/test_playbooks/fixtures/snapshot* plugins/modules/snapshot.py tests/fixtures/apidoc/snapshot.json
Expand Down
11 changes: 11 additions & 0 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -459,3 +459,14 @@ releases:
name: subscription_info
namespace: ''
release_date: '2021-05-20'
2.1.1:
changes:
bugfixes:
- external_usergroup - always lookup the ID of the usergroup, instead of passing
the name to the API (https://bugzilla.redhat.com/show_bug.cgi?id=1967649)
- host, hostgroup - don't override already set parameters when passing an activation
key only (and vice versa) (https://bugzilla.redhat.com/show_bug.cgi?id=1967904)
fragments:
- bz1967649-usergroup_lookup.yml
- bz1967904-dont_override_params.yml
release_date: '2021-06-22'
4 changes: 2 additions & 2 deletions docs/_gh_include/header.inc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<html>
<head>
<title>Foreman Ansible Modules documentation index</title>
<title>Red Hat Satellite Ansible Collection documentation index</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" media="all" href="https://theforeman.org/static/css/bootstrap.min.css"/>
<link rel="stylesheet" media="all" href="https://theforeman.org/static/css/bootstrap-responsive.min.css"/>
Expand All @@ -10,7 +10,7 @@
</head>

<body style="margin:0px 15px">
<h1>Foreman Ansible Modules</h1>
<h1>Red Hat Satellite Ansible Collection</h1>

<hr />

Expand Down
7 changes: 6 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Welcome to Red Hat Satellite Ansible Collection' documentation!
:caption: User documentation

README
Changelog <CHANGELOG>
plugins/index
Filters <filters>
roles/index
Expand All @@ -26,6 +25,12 @@ Welcome to Red Hat Satellite Ansible Collection' documentation!
testing
releasing

.. toctree::
:maxdepth: 2
:caption: General

Changelog <CHANGELOG>

Indices and tables
==================

Expand Down
6 changes: 3 additions & 3 deletions galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ authors:
- "Paul Gration <[email protected]>"
- "Peter Ondrejka <[email protected]>"
- "Philipp <[email protected]>"
- "Quirin Pamp <[email protected]>"
- "Quirin Pamp <[email protected]>"
- "Richard Stempfl <[email protected]>"
- "Sam <[email protected]>"
- "Samir Jha <[email protected]>"
- "Sean O'Keeffe <[email protected]>"
- "Stoned Elipot <[email protected]>"
- "TTherouanne <[email protected]>"
- "William Bradford Clark <[email protected]>"
- "Yifat Makias <[email protected]>"
- "achevalet <[email protected]>"
- "calvingsmith <[email protected]>"
- "furhouse <[email protected]>"
Expand All @@ -65,8 +66,7 @@ authors:
- "metalcated <[email protected]>"
- "russianguppie <[email protected]>"
- "willtome <[email protected]>"
- "yifatmakias <[email protected]>"
version: "2.1.0"
version: "2.1.1"
license:
- "GPL-3.0-or-later"
tags:
Expand Down
1 change: 1 addition & 0 deletions plugins/callback/foreman.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ def append_result(self, result, failed=False):
host = result._host.get_name()
value = result._result
value['failed'] = failed
value['module'] = result._task.action
self.items[host].append((name, value))
self.check_mode = result._task.check_mode
if 'ansible_facts' in value:
Expand Down
28 changes: 21 additions & 7 deletions plugins/module_utils/foreman_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@ class ParametersMixinBase(object):
def validate_parameters(self):
parameters = self.foreman_params.get('parameters')
if parameters is not None:
if len(parameters) != len(set(param['name'] for param in parameters)):
self.fail_json(msg="There are duplicate keys in 'parameters'.")
parameter_names = [param['name'] for param in parameters]
duplicate_params = set([x for x in parameter_names if parameter_names.count(x) > 1])
if duplicate_params:
self.fail_json(msg="There are duplicate keys in 'parameters': {0}.".format(duplicate_params))


class ParametersMixin(ParametersMixinBase):
Expand Down Expand Up @@ -311,14 +313,26 @@ def __init__(self, **kwargs):
mutually_exclusive = kwargs.pop('mutually_exclusive', []) + [['medium', 'kickstart_repository']]
super(HostMixin, self).__init__(foreman_spec=foreman_spec, required_plugins=required_plugins, mutually_exclusive=mutually_exclusive, **kwargs)

if 'activation_keys' in self.foreman_params:
if 'parameters' not in self.foreman_params:
self.foreman_params['parameters'] = []
ak_param = {'name': 'kt_activation_keys', 'parameter_type': 'string', 'value': self.foreman_params.pop('activation_keys')}
self.foreman_params['parameters'].append(ak_param)
def run(self, **kwargs):
entity = self.lookup_entity('entity')

if not self.desired_absent:
if 'activation_keys' in self.foreman_params:
if 'parameters' not in self.foreman_params:
parameters = [param for param in (entity or {}).get('parameters', []) if param['name'] != 'kt_activation_keys']
else:
parameters = self.foreman_params['parameters']
ak_param = {'name': 'kt_activation_keys', 'parameter_type': 'string', 'value': self.foreman_params.pop('activation_keys')}
self.foreman_params['parameters'] = parameters + [ak_param]
elif 'parameters' in self.foreman_params and entity is not None:
ak_param = next((param for param in entity.get('parameters') if param['name'] == 'kt_activation_keys'), None)
if ak_param:
self.foreman_params['parameters'].append(ak_param)

self.validate_parameters()

return super(HostMixin, self).run(**kwargs)


class ForemanAnsibleModule(AnsibleModule):
""" Baseclass for all foreman related Ansible modules.
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/external_usergroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@ def main():
module = ForemanExternalUsergroupModule(
foreman_spec=dict(
name=dict(required=True),
usergroup=dict(required=True),
usergroup=dict(required=True, type='entity', ensure=False),
auth_source=dict(required=True, aliases=['auth_source_ldap'], type='entity', flat_name='auth_source_id', resource_type='auth_sources'),
auth_source_ldap=dict(type='entity', invisible=True, flat_name='auth_source_id'),
auth_source_external=dict(type='entity', invisible=True, flat_name='auth_source_id'),
),
)

params = {"usergroup_id": module.foreman_params.pop('usergroup')}
entity = None

with module.api_connection():
params = module.scope_for('usergroup')
# There is no way to find by name via API search, so we need
# to iterate over all external user groups of a given usergroup
for external_usergroup in module.list_resource("external_usergroups", params=params):
Expand Down
2 changes: 1 addition & 1 deletion roles/repositories/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This role supports the [Common Role Variables](https://github.com/theforeman/for
Each product is represented as a dictionary and can include `repository_sets` which represent Red Hat Repositories and should be used when the product name matches an existing Red Hat Product.
Each element of `repository_sets` must have a `name` and should specify the `basearch` and/or `releasever` only when multiple versions are available for that Product.
All repository sets for a Red Hat Product can be enabled by omitting `repository_sets` and instead specifying that the Product has `all_repositories: True`. When using this option it is also necessary to specify a list of repository `label`s for the Product (e.g. rhel-7-server-rpms). Be wary that this option can result in enabling a large number of unused repositories that, if added to sync plans, can greatly increase sync times and rapidly fill disk space.
Custom (i.e. non Red Hat) Products can also be defined, with associated `repositories` which represent custom repositories, and are required to have a `name`, `url`, and `content_type`; they may require additional fields and can take any parameter supported by [redhat.satellite.repository](https://theforeman.github.io/foreman-ansible-modules/develop/plugins/repository_module.html).
Custom (i.e. non Red Hat) Products can also be defined, with associated `repositories` which represent custom repositories, and are required to have a `name`, `url`, and `content_type`; they may require additional fields and can take any parameter supported by [redhat.satellite.repository](https://redhatsatellite.github.io/satellite-ansible-collection/develop/plugins/repository_module.html).
A variety of examples are demonstrated in the data structure below:

```yaml
Expand Down
2 changes: 1 addition & 1 deletion tests/test_playbooks/content_credentials_role.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
satellite_content_credentials:
- name: RPM-GPG-KEY-foreman
content_type: gpg_key
content: "{{ lookup('url', 'https://yum.theforeman.org/releases/latest/RPM-GPG-KEY-foreman', split_lines=False) }}"
content: "{{ lookup('url', 'https://yum.theforeman.org/releases/2.4/RPM-GPG-KEY-foreman', split_lines=False) }}"
- name: RPM-GPG-KEY-my-repo2
content_type: gpg_key
content: |
Expand Down
5 changes: 5 additions & 0 deletions tests/test_playbooks/external_usergroup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
auth_source_ldap_attr_login: dc=vagrant,dc=vm
auth_source_ldap_groups_base: cn=groups,cn=accounts,dc=vagrant,dc=vm
auth_source_ldap_tls: false
- include: tasks/external_usergroup.yml
vars:
external_usergroup_state: absent
auth_source_ldap: "Example LDAP"
usergroup: "internal_group"

- hosts: tests
collections:
Expand Down
Loading

0 comments on commit c02ca44

Please sign in to comment.