Skip to content

Commit

Permalink
Merge pull request #13 from RedHatSatellite/r130
Browse files Browse the repository at this point in the history
release 1.3.0
  • Loading branch information
evgeni authored Sep 23, 2020
2 parents f3771c6 + d14e793 commit 697ed49
Show file tree
Hide file tree
Showing 144 changed files with 15,786 additions and 24,456 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@ redhat.satellite Release Notes

This changelog describes changes after version 0.8.1.

v1.3.0
======

Minor Changes
-------------

- external_usergroup - rename the ``auth_source_ldap`` parameter to ``auth_source`` (``auth_source_ldap`` is still supported via an alias)
- server URL and credentials can now also be specified using environment variables (https://github.com/theforeman/foreman-ansible-modules/issues/837)
- subnet - add support for external IPAM (https://github.com/theforeman/foreman-ansible-modules/issues/966)

Bugfixes
--------

- content_view - remove CVs from lifecycle environments before deleting them (https://bugzilla.redhat.com/show_bug.cgi?id=1875314)
- external_usergroup - support non-LDAP external groups (https://github.com/theforeman/foreman-ansible-modules/issues/956)
- host - properly scope image lookups by the compute resource (https://bugzilla.redhat.com/show_bug.cgi?id=1878693)
- inventory plugin - include empty parent groups in the inventory (https://github.com/theforeman/foreman-ansible-modules/issues/919)

New Modules
-----------

- redhat.satellite.status_info - Get status info

v1.2.0
======

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ tests/test_playbooks/vars/server.yml:
@echo "For recording, please adjust $@ to match your reference server."

dist-test: $(MANIFEST)
ansible -m $(NAMESPACE).$(NAME).organization -a "username=admin password=changeme server_url=https://foreman.example.test name=collectiontest" localhost | grep -q "Failed to connect to Foreman server"
FOREMAN_SERVER_URL=https://foreman.example.test ansible -m $(NAMESPACE).$(NAME).organization -a "username=admin password=changeme name=collectiontest" localhost | grep -q "Failed to connect to Foreman server.*foreman.example.test"
ansible-doc $(NAMESPACE).$(NAME).organization | grep -q "Manage Organization"

$(MANIFEST): $(NAMESPACE)-$(NAME)-$(VERSION).tar.gz
Expand Down
26 changes: 26 additions & 0 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,29 @@ releases:
- bz1855008-single_call_parameters.yaml
- bz1871978-template_kinds.yaml
release_date: '2020-09-03'
1.3.0:
changes:
bugfixes:
- content_view - remove CVs from lifecycle environments before deleting them
(https://bugzilla.redhat.com/show_bug.cgi?id=1875314)
- external_usergroup - support non-LDAP external groups (https://github.com/theforeman/foreman-ansible-modules/issues/956)
- host - properly scope image lookups by the compute resource (https://bugzilla.redhat.com/show_bug.cgi?id=1878693)
- inventory plugin - include empty parent groups in the inventory (https://github.com/theforeman/foreman-ansible-modules/issues/919)
minor_changes:
- external_usergroup - rename the ``auth_source_ldap`` parameter to ``auth_source``
(``auth_source_ldap`` is still supported via an alias)
- server URL and credentials can now also be specified using environment variables
(https://github.com/theforeman/foreman-ansible-modules/issues/837)
- subnet - add support for external IPAM (https://github.com/theforeman/foreman-ansible-modules/issues/966)
fragments:
- 837-env-fallback.yaml
- 919-include-empty-parent-groups.yml
- 956-external_usergroup-non-ldap.yaml
- 966-subnet-external_ipam.yaml
- bz1875314-content_view-remove.yaml
- bz1878693-scope_image_lookups.yaml
modules:
- description: Get status info
name: status_info
namespace: ''
release_date: '2020-09-22'
2 changes: 1 addition & 1 deletion docs/developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ This is usually combined with `flat_name=<entity>_ids`. If no flat_name is provi
The module must handle the entities separately.
See domain parameters in [`domain`](../plugins/modules/domain.py) for an example.
The sub entities must be described by `foreman_spec=<sub_entity>_spec`.
* `type='invisible'` The parameter is available to the API call, but it will be excluded from Ansible's `argument_spec`.
* `invisible=True` The parameter is available to the API call, but it will be excluded from Ansible's `argument_spec`.
* `search_by='login'`: Used with `type='entity'` or `type='entity_list'`. Field used to search the sub entity. Defaults to value provided by `ENTITY_KEYS` or 'name' if no value found.
* `search_operator='~'`: Used with `type='entity'` or `type='entity_list'`. Operator used to search the sub entity. Defaults to '='. For fuzzy search use '~'.
* `resource_type='organizations'`: Used with `type='entity'` or `type='entity_list'`. Resource type used to build API resource PATH. Defaults to pluralized entity key.
Expand Down
4 changes: 3 additions & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ authors:
- "Nikhil Jain <[email protected]>"
- "Olivier <[email protected]>"
- "Ondrej Prazak <[email protected]>"
- "Ondřej Ezr <[email protected]>"
- "Patrick Creech <[email protected]>"
- "Paul Armstrong <[email protected]>"
- "Paul Gration <[email protected]>"
Expand All @@ -44,6 +45,7 @@ authors:
- "Richard Stempfl <[email protected]>"
- "Sam <[email protected]>"
- "Sean O'Keeffe <[email protected]>"
- "Stoned Elipot <[email protected]>"
- "TTherouanne <[email protected]>"
- "William Bradford Clark <[email protected]>"
- "calvingsmith <[email protected]>"
Expand All @@ -52,7 +54,7 @@ authors:
- "metalcated <[email protected]>"
- "russianguppie <[email protected]>"
- "willtome <[email protected]>"
version: "1.2.0"
version: "1.3.0"
license:
- "GPL-3.0-or-later"
tags:
Expand Down
11 changes: 8 additions & 3 deletions plugins/callback/foreman.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@
- requests (python library)
options:
url:
description: URL to the Foreman server
description:
- URL of the Foreman server.
env:
- name: FOREMAN_URL
- name: FOREMAN_SERVER_URL
- name: FOREMAN_SERVER
required: True
default: http://localhost:3000
ini:
- section: callback_foreman
key: url
client_cert:
description: X509 certificate to authenticate to Foreman if https is used
description:
- X509 certificate to authenticate to Foreman if https is used
env:
- name: FOREMAN_SSL_CERT
default: /etc/foreman/client_cert.pem
Expand All @@ -40,7 +44,8 @@
key: client_cert
aliases: [ ssl_cert ]
client_key:
description: the corresponding private key
description:
- the corresponding private key
env:
- name: FOREMAN_SSL_KEY
default: /etc/foreman/client_key.pem
Expand Down
42 changes: 34 additions & 8 deletions plugins/doc_fragments/foreman.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,27 @@ class ModuleDocFragment(object):
- apypie
options:
server_url:
description: URL of the Foreman server
description:
- URL of the Foreman server.
- If the value is not specified in the task, the value of environment variable C(FOREMAN_SERVER_URL) will be used instead.
required: true
type: str
username:
description: Username accessing the Foreman server
description:
- Username accessing the Foreman server.
- If the value is not specified in the task, the value of environment variable C(FOREMAN_USERNAME) will be used instead.
required: true
type: str
password:
description: Password of the user accessing the Foreman server
description:
- Password of the user accessing the Foreman server.
- If the value is not specified in the task, the value of environment variable C(FOREMAN_PASSWORD) will be used instead.
required: true
type: str
validate_certs:
description: Whether or not to verify the TLS certificates of the Foreman server
description:
- Whether or not to verify the TLS certificates of the Foreman server.
- If the value is not specified in the task, the value of environment variable C(FOREMAN_VALIDATE_CERTS) will be used instead.
default: true
type: bool
'''
Expand Down Expand Up @@ -184,10 +192,6 @@ class ModuleDocFragment(object):
- Mutually exclusive with I(kickstart_repository).
required: False
type: str
operatingsystem:
description: Operatingsystem title
required: False
type: str
pxe_loader:
description: PXE Bootloader
required: false
Expand Down Expand Up @@ -291,3 +295,25 @@ class ModuleDocFragment(object):
required: false
type: str
'''

OPERATINGSYSTEMS = '''
options:
operatingsystems:
description:
- List of operating systems the entity should be assigned to.
- Operating systems are looked up by their title which is composed as "<name> <major>.<minor>".
- You can omit the version part as long as you only have one operating system by that name.
required: false
type: list
elements: str
'''

OPERATINGSYSTEM = '''
options:
operatingsystem:
description:
- Operating systems are looked up by their title which is composed as "<name> <major>.<minor>".
- You can omit the version part as long as you only have one operating system by that name.
type: str
required: False
'''
30 changes: 23 additions & 7 deletions plugins/inventory/foreman.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,33 @@
required: True
choices: ['redhat.satellite.foreman']
url:
description: url to foreman
description:
- URL of the Foreman server.
default: 'http://localhost:3000'
env:
- name: FOREMAN_SERVER
- name: FOREMAN_SERVER_URL
- name: FOREMAN_URL
user:
description: foreman authentication user
description:
- Username accessing the Foreman server.
required: True
env:
- name: FOREMAN_USER
- name: FOREMAN_USERNAME
password:
description: foreman authentication password
description:
- Password of the user accessing the Foreman server.
required: True
env:
- name: FOREMAN_PASSWORD
validate_certs:
description: verify SSL certificate if using https
description:
- Whether or not to verify the TLS certificates of the Foreman server.
type: boolean
default: False
env:
- name: FOREMAN_VALIDATE_CERTS
group_prefix:
description: prefix to apply to foreman groups
default: foreman_
Expand Down Expand Up @@ -239,9 +248,16 @@ def _populate(self):
# create directly mapped groups
group_name = host.get('hostgroup_title', host.get('hostgroup_name'))
if group_name:
group_name = to_safe_group_name('%s%s' % (self.get_option('group_prefix'), group_name.lower().replace(" ", "")))
group_name = self.inventory.add_group(group_name)
self.inventory.add_child(group_name, host_name)
parent_name = None
group_label_parts = []
for part in group_name.split('/'):
group_label_parts.append(part.lower().replace(" ", ""))
gname = to_safe_group_name('%s%s' % (self.get_option('group_prefix'), '/'.join(group_label_parts)))
result_gname = self.inventory.add_group(gname)
if parent_name:
self.inventory.add_child(parent_name, result_gname)
parent_name = result_gname
self.inventory.add_child(result_gname, host_name)

if self.get_option('legacy_hostvars'):
hostvars = self._get_hostvars(host)
Expand Down
27 changes: 13 additions & 14 deletions plugins/module_utils/foreman_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from collections import defaultdict
from functools import wraps

from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.basic import AnsibleModule, missing_required_lib, env_fallback
from ansible.module_utils._text import to_bytes, to_native
from ansible.module_utils import six

Expand All @@ -42,7 +42,7 @@
PYYAML_IMP_ERR = traceback.format_exc()

parameter_foreman_spec = dict(
id=dict(type='invisible'),
id=dict(invisible=True),
name=dict(required=True),
value=dict(type='raw', required=True),
parameter_type=dict(default='string', choices=['string', 'boolean', 'integer', 'real', 'array', 'hash', 'yaml', 'json']),
Expand Down Expand Up @@ -302,10 +302,10 @@ def __init__(self, **kwargs):

self.foreman_spec, gen_args = _foreman_spec_helper(kwargs.pop('foreman_spec', {}))
argument_spec = dict(
server_url=dict(required=True),
username=dict(required=True),
password=dict(required=True, no_log=True),
validate_certs=dict(type='bool', default=True),
server_url=dict(required=True, fallback=(env_fallback, ['FOREMAN_SERVER_URL', 'FOREMAN_SERVER', 'FOREMAN_URL'])),
username=dict(required=True, fallback=(env_fallback, ['FOREMAN_USERNAME', 'FOREMAN_USER'])),
password=dict(required=True, no_log=True, fallback=(env_fallback, ['FOREMAN_PASSWORD'])),
validate_certs=dict(type='bool', default=True, fallback=(env_fallback, ['FOREMAN_VALIDATE_CERTS'])),
)
argument_spec.update(gen_args)
argument_spec.update(kwargs.pop('argument_spec', {}))
Expand Down Expand Up @@ -425,7 +425,7 @@ def connect(self):
verify_ssl=self._foremanapi_validate_certs,
)

self.ping()
self.status()

self._patch_templates_resource_name()
self._patch_location_api()
Expand All @@ -434,7 +434,7 @@ def connect(self):
self.check_required_plugins()

@_exception2fail_json(msg="Failed to connect to Foreman server: {0}")
def ping(self):
def status(self):
return self.foremanapi.resource('home').call('status')

def _resource(self, resource):
Expand Down Expand Up @@ -494,11 +494,8 @@ def find_resource(self, resource, search, params=None, failsafe=False, thin=None
else:
error_msg = "no"
self.fail_json(msg="Found {0} results while searching for {1} with {2}".format(error_msg, resource, search))
if result:
if thin:
result = {'id': result['id']}
else:
result = self.show_resource(resource, result['id'], params=params)
if result and not thin:
result = self.show_resource(resource, result['id'], params=params)
return result

def find_resource_by(self, resource, search_field, value, **kwargs):
Expand Down Expand Up @@ -1124,6 +1121,7 @@ def _foreman_spec_helper(spec):
'failsafe',
'flat_name',
'foreman_spec',
'invisible',
'resolve',
'resource_type',
'scope',
Expand Down Expand Up @@ -1162,6 +1160,7 @@ def _foreman_spec_helper(spec):
argument_value = {k: v for (k, v) in value.items() if k not in _FILTER_SPEC_KEYS}

foreman_type = value.get('type')
ansible_invisible = value.get('invisible', False)
flat_name = value.get('flat_name')

if foreman_type == 'entity':
Expand Down Expand Up @@ -1194,7 +1193,7 @@ def _foreman_spec_helper(spec):

foreman_spec[key] = foreman_value

if foreman_type != 'invisible':
if not ansible_invisible:
argument_spec[key] = argument_value

return foreman_spec, argument_spec
Expand Down
12 changes: 4 additions & 8 deletions plugins/modules/architecture.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,10 @@
updated_name:
description: New architecture name. When this parameter is set, the module will not be idempotent.
type: str
operatingsystems:
description: List of operating systems the architecture should be assigned to
required: false
type: list
elements: str
extends_documentation_fragment:
- redhat.satellite.foreman
- redhat.satellite.foreman.entity_state
- redhat.satellite.foreman.operatingsystems
'''

EXAMPLES = '''
Expand All @@ -55,7 +51,7 @@
- "TestOS2"
server_url: "https://satellite.example.com"
username: "admin"
password: "secret"
password: "changeme"
state: present
- name: "Update an Architecture"
Expand All @@ -66,15 +62,15 @@
- "TestOS4"
server_url: "https://satellite.example.com"
username: "admin"
password: "secret"
password: "changeme"
state: present
- name: "Delete an Architecture"
redhat.satellite.architecture:
name: "i386"
server_url: "https://satellite.example.com"
username: "admin"
password: "secret"
password: "changeme"
state: absent
'''

Expand Down
Loading

0 comments on commit 697ed49

Please sign in to comment.