mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-01 02:43:16 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1357e47f92 | ||
|
|
cc6d4209d4 | ||
|
|
01134d4625 | ||
|
|
16089ab2de | ||
|
|
0da4607c7f | ||
|
|
46cbf60c2d | ||
|
|
e7d86f5add | ||
|
|
ee4c76fa43 | ||
|
|
095d09ec12 | ||
|
|
d9ed00fb12 | ||
|
|
94bb204e29 | ||
|
|
9b1f450102 | ||
|
|
dd3bc067f5 | ||
|
|
15916cd61f | ||
|
|
02a257569a | ||
|
|
c486e42faa |
@@ -29,14 +29,14 @@ schedules:
|
||||
always: true
|
||||
branches:
|
||||
include:
|
||||
- stable-8
|
||||
- stable-7
|
||||
- stable-6
|
||||
- cron: 0 11 * * 0
|
||||
displayName: Weekly (old stable branches)
|
||||
always: true
|
||||
branches:
|
||||
include:
|
||||
- stable-5
|
||||
- stable-6
|
||||
|
||||
variables:
|
||||
- name: checkoutPath
|
||||
|
||||
@@ -6,6 +6,34 @@ Community General Release Notes
|
||||
|
||||
This changelog describes changes after version 5.0.0.
|
||||
|
||||
v6.6.7
|
||||
======
|
||||
|
||||
Release Summary
|
||||
---------------
|
||||
|
||||
Bugfix release.
|
||||
|
||||
From now on, community.general 6.x.y will only receive major bugfixes and security fixes anymore.
|
||||
|
||||
|
||||
Bugfixes
|
||||
--------
|
||||
|
||||
- composer - fix impossible to run ``working_dir`` dependent commands. The module was throwing an error when trying to run a ``working_dir`` dependent command, because it tried to get the command help without passing the ``working_dir`` (https://github.com/ansible-collections/community.general/issues/3787).
|
||||
- github_deploy_key - fix pagination behaviour causing a crash when only a single page of deploy keys exist (https://github.com/ansible-collections/community.general/pull/7375).
|
||||
- gitlab_group_members - fix gitlab constants call in ``gitlab_group_members`` module (https://github.com/ansible-collections/community.general/issues/7467).
|
||||
- gitlab_project_members - fix gitlab constants call in ``gitlab_project_members`` module (https://github.com/ansible-collections/community.general/issues/7467).
|
||||
- gitlab_protected_branches - fix gitlab constants call in ``gitlab_protected_branches`` module (https://github.com/ansible-collections/community.general/issues/7467).
|
||||
- gitlab_user - fix gitlab constants call in ``gitlab_user`` module (https://github.com/ansible-collections/community.general/issues/7467).
|
||||
- lxc connection plugin - properly evaluate options (https://github.com/ansible-collections/community.general/pull/7369).
|
||||
- memset module utils - make compatible with ansible-core 2.17 (https://github.com/ansible-collections/community.general/pull/7379).
|
||||
- redhat_subscription - use the right D-Bus options for the consumer type when
|
||||
registering a RHEL system older than 9 or a RHEL 9 system older than 9.2
|
||||
and using ``consumer_type``
|
||||
(https://github.com/ansible-collections/community.general/pull/7378).
|
||||
- selective callback plugin - fix length of task name lines in output always being 3 characters longer than desired (https://github.com/ansible-collections/community.general/pull/7374).
|
||||
|
||||
v6.6.6
|
||||
======
|
||||
|
||||
|
||||
@@ -1573,3 +1573,49 @@ releases:
|
||||
- 7301-fix-backend-config-string-encapsulation.yml
|
||||
- 7303-mail-incorrect-header-parsing.yml
|
||||
release_date: '2023-10-08'
|
||||
6.6.7:
|
||||
changes:
|
||||
bugfixes:
|
||||
- composer - fix impossible to run ``working_dir`` dependent commands. The module
|
||||
was throwing an error when trying to run a ``working_dir`` dependent command,
|
||||
because it tried to get the command help without passing the ``working_dir``
|
||||
(https://github.com/ansible-collections/community.general/issues/3787).
|
||||
- github_deploy_key - fix pagination behaviour causing a crash when only a single
|
||||
page of deploy keys exist (https://github.com/ansible-collections/community.general/pull/7375).
|
||||
- gitlab_group_members - fix gitlab constants call in ``gitlab_group_members``
|
||||
module (https://github.com/ansible-collections/community.general/issues/7467).
|
||||
- gitlab_project_members - fix gitlab constants call in ``gitlab_project_members``
|
||||
module (https://github.com/ansible-collections/community.general/issues/7467).
|
||||
- gitlab_protected_branches - fix gitlab constants call in ``gitlab_protected_branches``
|
||||
module (https://github.com/ansible-collections/community.general/issues/7467).
|
||||
- gitlab_user - fix gitlab constants call in ``gitlab_user`` module (https://github.com/ansible-collections/community.general/issues/7467).
|
||||
- lxc connection plugin - properly evaluate options (https://github.com/ansible-collections/community.general/pull/7369).
|
||||
- memset module utils - make compatible with ansible-core 2.17 (https://github.com/ansible-collections/community.general/pull/7379).
|
||||
- 'redhat_subscription - use the right D-Bus options for the consumer type when
|
||||
|
||||
registering a RHEL system older than 9 or a RHEL 9 system older than 9.2
|
||||
|
||||
and using ``consumer_type``
|
||||
|
||||
(https://github.com/ansible-collections/community.general/pull/7378).
|
||||
|
||||
'
|
||||
- selective callback plugin - fix length of task name lines in output always
|
||||
being 3 characters longer than desired (https://github.com/ansible-collections/community.general/pull/7374).
|
||||
release_summary: 'Bugfix release.
|
||||
|
||||
|
||||
From now on, community.general 6.x.y will only receive major bugfixes and
|
||||
security fixes anymore.
|
||||
|
||||
'
|
||||
fragments:
|
||||
- 3787-pass-composer-working-dir.yml
|
||||
- 6.6.7.yml
|
||||
- 7369-fix-lxc-options.yml
|
||||
- 7374-fix-selective-callback-taskname-length.yml
|
||||
- 7375-fix-github-deploy-key-pagination.yml
|
||||
- 7378-redhat_subscription-dbus-consumer-type.yaml
|
||||
- 7379-url.yml
|
||||
- 7467-fix-gitlab-constants-calls.yml
|
||||
release_date: '2023-11-04'
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace: community
|
||||
name: general
|
||||
version: 6.6.6
|
||||
version: 6.6.7
|
||||
readme: README.md
|
||||
authors:
|
||||
- Ansible (https://github.com/ansible)
|
||||
|
||||
@@ -115,8 +115,8 @@ class CallbackModule(CallbackBase):
|
||||
line_length = 120
|
||||
if self.last_skipped:
|
||||
print()
|
||||
msg = colorize("# {0} {1}".format(task_name,
|
||||
'*' * (line_length - len(task_name))), 'bold')
|
||||
line = "# {0} ".format(task_name)
|
||||
msg = colorize("{0}{1}".format(line, '*' * (line_length - len(line))), 'bold')
|
||||
print(msg)
|
||||
|
||||
def _indent_text(self, text, indent_level):
|
||||
|
||||
@@ -60,7 +60,7 @@ class Connection(ConnectionBase):
|
||||
def __init__(self, play_context, new_stdin, *args, **kwargs):
|
||||
super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
|
||||
|
||||
self.container_name = self._play_context.remote_addr
|
||||
self.container_name = None
|
||||
self.container = None
|
||||
|
||||
def _connect(self):
|
||||
@@ -68,12 +68,14 @@ class Connection(ConnectionBase):
|
||||
super(Connection, self)._connect()
|
||||
|
||||
if not HAS_LIBLXC:
|
||||
msg = "lxc bindings for python2 are not installed"
|
||||
msg = "lxc python bindings are not installed"
|
||||
raise errors.AnsibleError(msg)
|
||||
|
||||
if self.container:
|
||||
return
|
||||
|
||||
self.container_name = self.get_option('remote_addr')
|
||||
|
||||
self._display.vvv("THIS IS A LOCAL LXC DIR", host=self.container_name)
|
||||
self.container = _lxc.Container(self.container_name)
|
||||
if self.container.state == "STOPPED":
|
||||
@@ -118,7 +120,7 @@ class Connection(ConnectionBase):
|
||||
super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
|
||||
|
||||
# python2-lxc needs bytes. python3-lxc needs text.
|
||||
executable = to_native(self._play_context.executable, errors='surrogate_or_strict')
|
||||
executable = to_native(self.get_option('executable'), errors='surrogate_or_strict')
|
||||
local_cmd = [executable, '-c', to_native(cmd, errors='surrogate_or_strict')]
|
||||
|
||||
read_stdout, write_stdout = None, None
|
||||
|
||||
@@ -14,8 +14,9 @@ from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||
from ansible.module_utils.urls import open_url, urllib_error
|
||||
from ansible.module_utils.urls import open_url
|
||||
from ansible.module_utils.basic import json
|
||||
import ansible.module_utils.six.moves.urllib.error as urllib_error
|
||||
|
||||
|
||||
class Response(object):
|
||||
|
||||
@@ -170,10 +170,15 @@ def get_available_options(module, command='install'):
|
||||
return command_help_json['definition']['options']
|
||||
|
||||
|
||||
def composer_command(module, command, arguments="", options=None, global_command=False):
|
||||
def composer_command(module, command, arguments="", options=None):
|
||||
if options is None:
|
||||
options = []
|
||||
|
||||
global_command = module.params['global_command']
|
||||
|
||||
if not global_command:
|
||||
options.extend(['--working-dir', "'%s'" % module.params['working_dir']])
|
||||
|
||||
if module.params['executable'] is None:
|
||||
php_path = module.get_bin_path("php", True, ["/usr/local/bin"])
|
||||
else:
|
||||
@@ -217,7 +222,6 @@ def main():
|
||||
module.fail_json(msg="Use the 'arguments' param for passing arguments with the 'command'")
|
||||
|
||||
arguments = module.params['arguments']
|
||||
global_command = module.params['global_command']
|
||||
available_options = get_available_options(module=module, command=command)
|
||||
|
||||
options = []
|
||||
@@ -234,9 +238,6 @@ def main():
|
||||
option = "--%s" % option
|
||||
options.append(option)
|
||||
|
||||
if not global_command:
|
||||
options.extend(['--working-dir', "'%s'" % module.params['working_dir']])
|
||||
|
||||
option_params = {
|
||||
'prefer_source': 'prefer-source',
|
||||
'prefer_dist': 'prefer-dist',
|
||||
@@ -260,7 +261,7 @@ def main():
|
||||
else:
|
||||
module.exit_json(skipped=True, msg="command '%s' does not support check mode, skipping" % command)
|
||||
|
||||
rc, out, err = composer_command(module, command, arguments, options, global_command)
|
||||
rc, out, err = composer_command(module, command, arguments, options)
|
||||
|
||||
if rc != 0:
|
||||
output = parse_out(err)
|
||||
|
||||
@@ -227,7 +227,7 @@ class GithubDeployKey(object):
|
||||
yield self.module.from_json(resp.read())
|
||||
|
||||
links = {}
|
||||
for x, y in findall(r'<([^>]+)>;\s*rel="(\w+)"', info["link"]):
|
||||
for x, y in findall(r'<([^>]+)>;\s*rel="(\w+)"', info.get("link", '')):
|
||||
links[y] = x
|
||||
|
||||
url = links.get('next')
|
||||
|
||||
@@ -276,11 +276,11 @@ def main():
|
||||
ensure_gitlab_package(module)
|
||||
|
||||
access_level_int = {
|
||||
'guest': gitlab.GUEST_ACCESS,
|
||||
'reporter': gitlab.REPORTER_ACCESS,
|
||||
'developer': gitlab.DEVELOPER_ACCESS,
|
||||
'maintainer': gitlab.MAINTAINER_ACCESS,
|
||||
'owner': gitlab.OWNER_ACCESS,
|
||||
'guest': gitlab.const.GUEST_ACCESS,
|
||||
'reporter': gitlab.const.REPORTER_ACCESS,
|
||||
'developer': gitlab.const.DEVELOPER_ACCESS,
|
||||
'maintainer': gitlab.const.MAINTAINER_ACCESS,
|
||||
'owner': gitlab.const.OWNER_ACCESS,
|
||||
}
|
||||
|
||||
gitlab_group = module.params['gitlab_group']
|
||||
|
||||
@@ -282,10 +282,10 @@ def main():
|
||||
ensure_gitlab_package(module)
|
||||
|
||||
access_level_int = {
|
||||
'guest': gitlab.GUEST_ACCESS,
|
||||
'reporter': gitlab.REPORTER_ACCESS,
|
||||
'developer': gitlab.DEVELOPER_ACCESS,
|
||||
'maintainer': gitlab.MAINTAINER_ACCESS,
|
||||
'guest': gitlab.const.GUEST_ACCESS,
|
||||
'reporter': gitlab.const.REPORTER_ACCESS,
|
||||
'developer': gitlab.const.DEVELOPER_ACCESS,
|
||||
'maintainer': gitlab.const.MAINTAINER_ACCESS,
|
||||
}
|
||||
|
||||
gitlab_project = module.params['project']
|
||||
|
||||
@@ -94,9 +94,9 @@ class GitlabProtectedBranch(object):
|
||||
self._module = module
|
||||
self.project = self.get_project(project)
|
||||
self.ACCESS_LEVEL = {
|
||||
'nobody': gitlab.NO_ACCESS,
|
||||
'developer': gitlab.DEVELOPER_ACCESS,
|
||||
'maintainer': gitlab.MAINTAINER_ACCESS
|
||||
'nobody': gitlab.const.NO_ACCESS,
|
||||
'developer': gitlab.const.DEVELOPER_ACCESS,
|
||||
'maintainer': gitlab.const.MAINTAINER_ACCESS
|
||||
}
|
||||
|
||||
def get_project(self, project_name):
|
||||
|
||||
@@ -244,12 +244,12 @@ class GitLabUser(object):
|
||||
self._gitlab = gitlab_instance
|
||||
self.user_object = None
|
||||
self.ACCESS_LEVEL = {
|
||||
'guest': gitlab.GUEST_ACCESS,
|
||||
'reporter': gitlab.REPORTER_ACCESS,
|
||||
'developer': gitlab.DEVELOPER_ACCESS,
|
||||
'master': gitlab.MAINTAINER_ACCESS,
|
||||
'maintainer': gitlab.MAINTAINER_ACCESS,
|
||||
'owner': gitlab.OWNER_ACCESS,
|
||||
'guest': gitlab.const.GUEST_ACCESS,
|
||||
'reporter': gitlab.const.REPORTER_ACCESS,
|
||||
'developer': gitlab.const.DEVELOPER_ACCESS,
|
||||
'master': gitlab.const.MAINTAINER_ACCESS,
|
||||
'maintainer': gitlab.const.MAINTAINER_ACCESS,
|
||||
'owner': gitlab.const.OWNER_ACCESS,
|
||||
}
|
||||
|
||||
'''
|
||||
|
||||
@@ -588,7 +588,34 @@ class Rhsm(RegistrationBase):
|
||||
|
||||
register_opts = {}
|
||||
if consumer_type:
|
||||
register_opts['consumer_type'] = consumer_type
|
||||
# The option for the consumer type used to be 'type' in versions
|
||||
# of RHEL before 9 & in RHEL 9 before 9.2, and then it changed to
|
||||
# 'consumer_type'; since the Register*() D-Bus functions reject
|
||||
# unknown options, we have to pass the right option depending on
|
||||
# the version -- funky.
|
||||
def supports_option_consumer_type():
|
||||
# subscription-manager in any supported Fedora version
|
||||
# has the new option.
|
||||
if distro_id == 'fedora':
|
||||
return True
|
||||
# Check for RHEL 9 >= 9.2, or RHEL >= 10.
|
||||
if distro_id == 'rhel' and \
|
||||
((distro_version[0] == 9 and distro_version[1] >= 2) or
|
||||
distro_version[0] >= 10):
|
||||
return True
|
||||
# CentOS: since the change was only done in EL 9, then there is
|
||||
# only CentOS Stream for 9, and thus we can assume it has the
|
||||
# latest version of subscription-manager.
|
||||
if distro_id == 'centos' and distro_version[0] >= 9:
|
||||
return True
|
||||
# Unknown or old distro: assume it does not support
|
||||
# the new option.
|
||||
return False
|
||||
|
||||
consumer_type_key = 'type'
|
||||
if supports_option_consumer_type():
|
||||
consumer_type_key = 'consumer_type'
|
||||
register_opts[consumer_type_key] = consumer_type
|
||||
if consumer_name:
|
||||
register_opts['name'] = consumer_name
|
||||
if consumer_id:
|
||||
|
||||
@@ -11,3 +11,4 @@ skip/rhel9.0
|
||||
skip/rhel9.1
|
||||
skip/rhel9.2
|
||||
skip/freebsd
|
||||
skip/python2.6
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
- when:
|
||||
- ansible_os_family != 'Archlinux' # TODO install driver from AUR: https://aur.archlinux.org/packages/psqlodbc
|
||||
- ansible_os_family != 'RedHat' or ansible_distribution_major_version != '7' # CentOS 7 stopped working
|
||||
block:
|
||||
|
||||
#
|
||||
|
||||
@@ -6,20 +6,81 @@
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
from io import StringIO
|
||||
|
||||
from ansible_collections.community.general.tests.unit.compat import unittest
|
||||
from ansible_collections.community.general.plugins.connection import lxc
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.playbook.play_context import PlayContext
|
||||
from ansible.plugins.loader import connection_loader
|
||||
from ansible_collections.community.general.tests.unit.compat import mock
|
||||
|
||||
|
||||
class TestLXCConnectionClass(unittest.TestCase):
|
||||
@pytest.fixture(autouse=True)
|
||||
def lxc(request):
|
||||
"""Fixture to import/load the lxc plugin module.
|
||||
|
||||
def test_lxc_connection_module(self):
|
||||
The fixture parameter is used to determine the presence of liblxc.
|
||||
When true (default), a mocked liblxc module is injected. If False,
|
||||
no liblxc will be present.
|
||||
"""
|
||||
liblxc_present = getattr(request, 'param', True)
|
||||
|
||||
class ContainerMock(mock.MagicMock):
|
||||
def __init__(self, name):
|
||||
super(ContainerMock, self).__init__()
|
||||
self.name = name
|
||||
self.state = 'STARTED'
|
||||
|
||||
liblxc_module_mock = mock.MagicMock()
|
||||
liblxc_module_mock.Container = ContainerMock
|
||||
|
||||
with mock.patch.dict('sys.modules'):
|
||||
if liblxc_present:
|
||||
sys.modules['lxc'] = liblxc_module_mock
|
||||
elif 'lxc' in sys.modules:
|
||||
del sys.modules['lxc']
|
||||
|
||||
from ansible_collections.community.general.plugins.connection import lxc as lxc_plugin_module
|
||||
|
||||
assert lxc_plugin_module.HAS_LIBLXC == liblxc_present
|
||||
assert bool(getattr(lxc_plugin_module, '_lxc', None)) == liblxc_present
|
||||
|
||||
yield lxc_plugin_module
|
||||
|
||||
|
||||
class TestLXCConnectionClass():
|
||||
|
||||
@pytest.mark.parametrize('lxc', [True, False], indirect=True)
|
||||
def test_lxc_connection_module(self, lxc):
|
||||
"""Test that a connection can be created with the plugin."""
|
||||
play_context = PlayContext()
|
||||
play_context.prompt = (
|
||||
'[sudo via ansible, key=ouzmdnewuhucvuaabtjmweasarviygqq] password: '
|
||||
)
|
||||
in_stream = StringIO()
|
||||
|
||||
self.assertIsInstance(lxc.Connection(play_context, in_stream), lxc.Connection)
|
||||
conn = connection_loader.get('lxc', play_context, in_stream)
|
||||
assert conn
|
||||
assert isinstance(conn, lxc.Connection)
|
||||
|
||||
@pytest.mark.parametrize('lxc', [False], indirect=True)
|
||||
def test_lxc_connection_liblxc_error(self, lxc):
|
||||
"""Test that on connect an error is thrown if liblxc is not present."""
|
||||
play_context = PlayContext()
|
||||
in_stream = StringIO()
|
||||
conn = connection_loader.get('lxc', play_context, in_stream)
|
||||
|
||||
with pytest.raises(AnsibleError, match='lxc python bindings are not installed'):
|
||||
conn._connect()
|
||||
|
||||
def test_remote_addr_option(self):
|
||||
"""Test that the remote_addr option is used"""
|
||||
play_context = PlayContext()
|
||||
in_stream = StringIO()
|
||||
conn = connection_loader.get('lxc', play_context, in_stream)
|
||||
|
||||
container_name = 'my-container'
|
||||
conn.set_option('remote_addr', container_name)
|
||||
assert conn.get_option('remote_addr') == container_name
|
||||
|
||||
conn._connect()
|
||||
assert conn.container_name == container_name
|
||||
|
||||
Reference in New Issue
Block a user