Skip to content

Commit

Permalink
Merge pull request #40 from RedHatSatellite/rel310
Browse files Browse the repository at this point in the history
Release 3.1.0
  • Loading branch information
evgeni authored Jan 28, 2022
2 parents 780e5c4 + 3015e36 commit d6845f8
Show file tree
Hide file tree
Showing 154 changed files with 12,529 additions and 9,631 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ jobs:
git checkout gh-pages
rm -rf $(basename ${GITHUB_REF})
mv docs/_build/html $(basename ${GITHUB_REF})
ln --force --no-dereference --symbolic $(dirname v*/index.html | sort --version-sort --reverse | head -n1) latest
git show origin/develop:docs/_gh_include/header.inc > index.html
(echo develop; dirname *.*.*/index.html | sort --version-sort --reverse) | xargs -I@@ -n1 echo '<div class="col-md-4 center"><a href="@@/" class="btn-doc btn"><i class="fa fa-newspaper-o"></i><p>@@</p></a></div>' >> index.html
(echo develop; echo latest; dirname *.*.*/index.html | sort --version-sort --reverse) | xargs -I@@ -n1 echo '<div class="col-md-4 center"><a href="@@/" class="btn-doc btn"><i class="fa fa-newspaper-o"></i><p>@@</p></a></div>' >> index.html
git show origin/develop:docs/_gh_include/footer.inc >> index.html
git add $(basename ${GITHUB_REF}) index.html
git add $(basename ${GITHUB_REF}) latest index.html
git commit -m "update docs for $(basename ${GITHUB_REF})" || true
- name: push docs
run: git push origin gh-pages
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
with:
python-version: ${{ matrix.python }}
- name: Restore pip cache
uses: actions/[email protected].6
uses: actions/[email protected].7
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
with:
python-version: "3.8"
- name: Restore pip cache
uses: actions/[email protected].6
uses: actions/[email protected].7
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
Expand All @@ -101,7 +101,7 @@ jobs:
with:
python-version: "3.8"
- name: Restore pip cache
uses: actions/[email protected].6
uses: actions/[email protected].7
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
Expand All @@ -126,7 +126,7 @@ jobs:
with:
python-version: "3.8"
- name: Restore pip cache
uses: actions/[email protected].6
uses: actions/[email protected].7
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ venv/
docs/plugins/
docs/_build/
changelogs/.plugin-cache.yaml
importer_result.json
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Anton <[email protected]> <[email protected]>
Bernhard Hopfenmüller <[email protected]> <[email protected]>
Bernhard Hopfenmüller <[email protected]> <[email protected]>
Baptiste Agasse <[email protected]> <[email protected]>
Baptiste Agasse <[email protected]> <[email protected]>
Christoffer Reijer <[email protected]> <[email protected]>
Christoffer Reijer <[email protected]> <[email protected]>
Eric D. Helms <[email protected]> <[email protected]>
Manisha Singhal <[email protected]> <[email protected]>
Matthias Dellweg <[email protected]> <[email protected]>
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,30 @@ redhat.satellite Release Notes

This changelog describes changes after version 0.8.1.

v3.1.0
======

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

- Warn if the user tries to use a plain HTTP server URL and fail if the URL is neither HTTPS nor HTTP.
- new ``compute_profiles`` role to manage compute profiles
- new ``compute_resources`` role to manage compute resources
- new ``content_view_publish`` role to publish a list of content views (https://github.com/theforeman/foreman-ansible-modules/issues/1209)
- new ``domains`` role to manage domains
- new ``operatingsystems`` role to manage operating systems
- new ``provisioning_templates`` role to manage provisioning templates
- new ``settings`` role to manage settings
- new ``subnets`` role to manage subnets
- repository - new ``download_concurrency`` parameter (https://github.com/theforeman/foreman-ansible-modules/issues/1273)

Bugfixes
--------

- callback plugin - include timezone information in the callback reported data (https://github.com/theforeman/foreman-ansible-modules/issues/1171)
- hostgroup, location - don't fail when trying to delete a Hostgroup or Location where the parent is already absent
- inventory plugin - fetch *all* facts, not only the first 250, when using the old Hosts API

v3.0.0
======

Expand Down
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
NAMESPACE := $(shell python -c 'import yaml; print(yaml.safe_load(open("galaxy.yml"))["namespace"])')
NAME := $(shell python -c 'import yaml; print(yaml.safe_load(open("galaxy.yml"))["name"])')
VERSION := $(shell python -c 'import yaml; print(yaml.safe_load(open("galaxy.yml"))["version"])')
PYTHON_COMMAND ?= python
NAMESPACE := $(shell $(PYTHON_COMMAND) -c 'import yaml; print(yaml.safe_load(open("galaxy.yml"))["namespace"])')
NAME := $(shell $(PYTHON_COMMAND) -c 'import yaml; print(yaml.safe_load(open("galaxy.yml"))["name"])')
VERSION := $(shell $(PYTHON_COMMAND) -c 'import yaml; print(yaml.safe_load(open("galaxy.yml"))["version"])')
MANIFEST := build/collections/ansible_collections/$(NAMESPACE)/$(NAME)/MANIFEST.json

ROLES := $(wildcard roles/*)
Expand All @@ -9,7 +10,7 @@ METADATA := galaxy.yml LICENSE README.md meta/runtime.yml requirements.txt chang
$(foreach PLUGIN_TYPE,$(PLUGIN_TYPES),$(eval _$(PLUGIN_TYPE) := $(filter-out %__init__.py,$(wildcard plugins/$(PLUGIN_TYPE)/*.py))))
DEPENDENCIES := $(METADATA) $(foreach PLUGIN_TYPE,$(PLUGIN_TYPES),$(_$(PLUGIN_TYPE))) $(foreach ROLE,$(ROLES),$(wildcard $(ROLE)/*/*)) $(foreach ROLE,$(ROLES),$(ROLE)/README.md)

PYTHON_VERSION = $(shell python -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))')
PYTHON_VERSION = $(shell $(PYTHON_COMMAND) -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))')
COLLECTION_COMMAND ?= ansible-galaxy
SANITY_OPTS = --venv
TEST =
Expand Down Expand Up @@ -45,6 +46,7 @@ lint: $(MANIFEST) | tests/test_playbooks/vars/server.yml
ansible-lint -v roles/*
ansible-playbook --syntax-check tests/test_playbooks/*.yml | grep -v '^$$'
flake8 --ignore=E402,W503 --max-line-length=160 plugins/ tests/
GALAXY_IMPORTER_CONFIG=tests/galaxy-importer.cfg python -m galaxy_importer.main $(NAMESPACE)-$(NAME)-$(VERSION).tar.gz

sanity: $(MANIFEST)
# Fake a fresh git repo for ansible-test
Expand Down Expand Up @@ -81,7 +83,7 @@ clean_%: FORCE $(MANIFEST)
setup: test-setup

test-setup: | tests/test_playbooks/vars/server.yml
pip install --upgrade 'pip<20'
pip install --upgrade pip
pip install --upgrade -r requirements-dev.txt

tests/test_playbooks/vars/server.yml:
Expand All @@ -90,6 +92,7 @@ tests/test_playbooks/vars/server.yml:

dist-test: $(MANIFEST)
SATELLITE_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"
SATELLITE_SERVER_URL=http://foreman.example.test ansible -m $(NAMESPACE).$(NAME).organization -a "username=admin password=changeme name=collectiontest" localhost 2>&1| grep -q "You have configured a plain HTTP server URL."
ansible-doc $(NAMESPACE).$(NAME).organization | grep -q "Manage Organization"

$(MANIFEST): $(NAMESPACE)-$(NAME)-$(VERSION).tar.gz
Expand Down
36 changes: 36 additions & 0 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -523,3 +523,39 @@ releases:
- drop-ansible28.yml
- validate-inventory-certs.yml
release_date: '2021-11-11'
3.1.0:
changes:
bugfixes:
- callback plugin - include timezone information in the callback reported data
(https://github.com/theforeman/foreman-ansible-modules/issues/1171)
- hostgroup, location - don't fail when trying to delete a Hostgroup or Location
where the parent is already absent
- inventory plugin - fetch *all* facts, not only the first 250, when using the
old Hosts API
minor_changes:
- Warn if the user tries to use a plain HTTP server URL and fail if the URL
is neither HTTPS nor HTTP.
- new ``compute_profiles`` role to manage compute profiles
- new ``compute_resources`` role to manage compute resources
- new ``content_view_publish`` role to publish a list of content views (https://github.com/theforeman/foreman-ansible-modules/issues/1209)
- new ``domains`` role to manage domains
- new ``operatingsystems`` role to manage operating systems
- new ``provisioning_templates`` role to manage provisioning templates
- new ``settings`` role to manage settings
- new ``subnets`` role to manage subnets
- repository - new ``download_concurrency`` parameter (https://github.com/theforeman/foreman-ansible-modules/issues/1273)
fragments:
- 1171-timezone.yml
- 1209-content_views_role.yml
- 1301-failsafe-parents.yml
- 1303-foreman-repository-download-concurrency.yml
- add-compute-profile-role.yml
- add-compute-resource-role.yml
- add-domains-role.yml
- add-operatingsystems-role.yml
- add-provisioning-templates-role.yml
- add-settings-role.yml
- add-subnets-role.yml
- explicit-http-warning.yml
- inventory-facts-batch-size.yml
release_date: '2022-01-14'
4 changes: 3 additions & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,21 @@ authors:
- "achevalet <[email protected]>"
- "calvingsmith <[email protected]>"
- "furhouse <[email protected]>"
- "gardar <[email protected]>"
- "igramic <[email protected]>"
- "jerrejkw <[email protected]>"
- "marco <[email protected]>"
- "metalcated <[email protected]>"
- "russianguppie <[email protected]>"
- "willtome <[email protected]>"
version: "3.0.0"
version: "3.1.0"
license:
- "GPL-3.0-or-later"
tags:
- foreman
- katello
- satellite
- infrastructure
readme: "README.md"
homepage: "https://access.redhat.com/products/red-hat-satellite"
repository: "https://github.com/RedHatSatellite/satellite-ansible-collection"
Expand Down
14 changes: 4 additions & 10 deletions plugins/callback/foreman.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ def get_time():
def get_now():
"""
Return the current timestamp as a string to be sent over the network.
The time is always in UTC *with* timezone information, so that Ruby
DateTime can easily parse it.
"""
return datetime.utcnow().isoformat()
return datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S+00:00")


class CallbackModule(CallbackBase):
Expand Down Expand Up @@ -283,7 +285,6 @@ def send_reports_proxy_host_report(self, stats):
changes.
"""
for host in stats.processed.keys():
total = stats.summarize(host)
report = {
"host": host,
"reported_at": get_now(),
Expand All @@ -292,17 +293,10 @@ def send_reports_proxy_host_report(self, stats):
"total": int(get_time() - self.start_time)
}
},
"status": {
"applied": total['changed'],
"failed": total['failures'] + total['unreachable'],
"skipped": total['skipped'],
},
"summary": stats.summarize(host),
"results": self.items[host],
"check_mode": self.check_mode,
}
if self.check_mode:
report['status']['pending'] = total['changed']
report['status']['applied'] = 0

self._send_data('report', 'proxy', host, report)
self.items[host] = []
Expand Down
16 changes: 14 additions & 2 deletions plugins/inventory/foreman.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,20 @@ def _get_json(self, url, ignore_errors=None, params=None):
break
elif isinstance(json['results'], MutableMapping):
# /facts are returned as dict in 'results'
results = json['results']
break
if not isinstance(results, MutableMapping):
results = {}

# check for end of paging
if len(json['results']) == 0:
break

for host, facts in json['results'].items():
if host not in results:
results[host] = {}
results[host].update(facts)

# get next page
params['page'] += 1
else:
# /hosts 's 'results' is a list of all hosts, returned is paginated
results = results + json['results']
Expand Down
17 changes: 14 additions & 3 deletions plugins/module_utils/foreman_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,11 @@ def __init__(self, **kwargs):
self._foremanapi_password = self.foreman_params.pop('password')
self._foremanapi_validate_certs = self.foreman_params.pop('validate_certs')

if self._foremanapi_server_url.lower().startswith('http://'):
self.warn("You have configured a plain HTTP server URL. All communication will happen unencrypted.")
elif not self._foremanapi_server_url.lower().startswith('https://'):
self.fail_json(msg="The server URL needs to be either HTTPS or HTTP!")

self.task_timeout = 60
self.task_poll = 4

Expand Down Expand Up @@ -1315,6 +1320,8 @@ def __init__(self, **kwargs):
if 'parent' in self.foreman_spec and self.foreman_spec['parent'].get('type') == 'entity':
if 'resouce_type' not in self.foreman_spec['parent']:
self.foreman_spec['parent']['resource_type'] = self.foreman_spec['entity']['resource_type']
if 'failsafe' not in self.foreman_spec['parent']:
self.foreman_spec['parent']['failsafe'] = True
current, parent = split_fqn(self.foreman_params[self.entity_key])
if isinstance(self.foreman_params.get('parent'), six.string_types):
if parent:
Expand Down Expand Up @@ -1424,10 +1431,14 @@ def __init__(self, **kwargs):
def run(self, **kwargs):
""" lookup entities, ensure entity, remove sensitive data, manage parameters.
"""
parent_name = self.foreman_params.get('parent')
if ('parent' in self.foreman_spec and self.foreman_spec['parent'].get('type') == 'entity'
and self.desired_absent and 'parent' in self.foreman_params and self.lookup_entity('parent') is None):
# Parent does not exist so just exit here
return None
and 'parent' in self.foreman_params and self.lookup_entity('parent') is None):
if self.desired_absent:
# Parent does not exist so just exit here
return None
else:
self.fail_json(msg="Couldn't find parent '{0}' for '{1}'.".format(parent_name, self.foreman_params['name']))
if not self.desired_absent:
self.auto_lookup_entities()
entity = self.lookup_entity('entity')
Expand Down
8 changes: 8 additions & 0 deletions plugins/modules/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@
- Repository SSL client private key
required: false
type: str
download_concurrency:
description:
- download concurrency for sync from upstream
- as the API does not return this value, this will break idempotence for this module
required: false
type: int
version_added: 3.0.0
download_policy:
description:
- download policy for sync from upstream
Expand Down Expand Up @@ -294,6 +301,7 @@ def main():
ssl_client_cert=dict(type='entity', resource_type='content_credentials', scope=['organization']),
ssl_client_key=dict(type='entity', resource_type='content_credentials', scope=['organization'], no_log=False),
download_policy=dict(choices=['background', 'immediate', 'on_demand']),
download_concurrency=dict(type='int'),
mirror_on_sync=dict(type='bool', default=True),
verify_ssl_on_sync=dict(type='bool'),
upstream_username=dict(),
Expand Down
3 changes: 2 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ rstcheck
docker
ruamel.yaml.clib<0.2.3; python_version < '3.6'
cryptography<3.1; python_version < '3.6'
-r requirements-lint.txt
-r requirements.txt
pylint==2.6.0; python_version >= '3.6'
voluptuous==0.12.1 # from https://github.com/ansible/ansible/raw/devel/test/lib/ansible_test/_data/requirements/sanity.validate-modules.txt
pycodestyle==2.8.0 # from https://github.com/ansible/ansible/raw/devel/test/lib/ansible_test/_data/requirements/sanity.pep8.txt
yamllint==1.26.3; python_version >= '3.5' # from https://github.com/ansible/ansible/raw/devel/test/lib/ansible_test/_data/requirements/sanity.yamllint.txt
1 change: 1 addition & 0 deletions requirements-lint.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
flake8
yamllint
ansible-lint
galaxy-importer
54 changes: 54 additions & 0 deletions roles/compute_profiles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
redhat.satellite.compute_profiles
===================================

This role creates and manages Compute Profiles.

Role Variables
--------------

This role supports the [Common Role Variables](https://github.com/theforeman/foreman-ansible-modules/blob/develop/README.md#common-role-variables).

The main data structure for this role is the list of `satellite_compute_profiles`. Each `compute_profile` requires the following fields:

- `name`: The name of the compute profile.

The following fields are optional and will be omitted by default:

- `description`: Description of the compute profile
- `compute_attributes`: List of attributes for the profile on specific compute resources.

Example Playbooks
-----------------

Create a compute profile named `1-Small` with a VMware spec of 1 single core CPU, 2 GiB of memory, 15 GiB of disk, and a VMXNET3 network card connected to `VM Network`:

```yaml
- hosts: localhost
roles:
- role: redhat.satellite.compute_profiles
vars:
satellite_server_url: https://satellite.example.com
satellite_username: "admin"
satellite_password: "changeme"
satellite_organization: "Default Organization"
satellite_compute_profiles:
- name: "1-Small"
compute_attributes:
- compute_resource: "VMware"
vm_attrs:
cluster: "cluster01"
path: /Datacenters/ha-datacenter/vm/
memoryHotAddEnabled: true
cpuHotAddEnabled: true
cpus: 1
corespersocket: 1
memory_mb: 2048
volumes_attributes:
0:
datastore: "datastore1"
size_gb: 15
interfaces_attributes:
0:
type: "VirtualVmxnet3"
network: "VM Network"
```
Loading

0 comments on commit d6845f8

Please sign in to comment.