Skip to content

Commit

Permalink
Merge branch 'ansible-collections:main' into rhsm_fix_idempotency_wit…
Browse files Browse the repository at this point in the history
…h_pool_ids
  • Loading branch information
cfiehe authored Oct 2, 2022
2 parents 053b19e + 394647d commit e89e1e6
Show file tree
Hide file tree
Showing 23 changed files with 1,074 additions and 129 deletions.
2 changes: 2 additions & 0 deletions .github/BOTMETA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,8 @@ files:
maintainers: Gaetan2907
$modules/identity/keycloak/keycloak_client_rolemapping.py:
maintainers: Gaetan2907
$modules/identity/keycloak/keycloak_user_rolemapping.py:
maintainers: bratwurzt
$modules/identity/keycloak/keycloak_group.py:
maintainers: adamgoossens
$modules/identity/keycloak/keycloak_identity_provider.py:
Expand Down
2 changes: 2 additions & 0 deletions changelogs/fragments/5147-terraform-init-no-color.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- terraform - run ``terraform init`` with ``-no-color`` not to mess up the stdout of the task (https://github.com/ansible-collections/community.general/pull/5147).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
minor_changes:
- proxmox_snap - add ``unbind`` param to support snapshotting containers with configured mountpoints (https://github.com/ansible-collections/community.general/pull/5274).
- proxmox module utils, the proxmox* modules - add ``api_task_ok`` helper to standardize API task status checks across all proxmox modules (https://github.com/ansible-collections/community.general/pull/5274).
5 changes: 5 additions & 0 deletions changelogs/fragments/5280-lxc_container-py3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bugfixes:
- lxc_container - the module has been updated to support Python 3 (https://github.com/ansible-collections/community.general/pull/5304).

deprecated_features:
- lxc_container - the module will no longer make any effort to support Python 2 (https://github.com/ansible-collections/community.general/pull/5304).
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "nmcli - fix error when setting previously unset MAC address, ``gsm.apn`` or ``vpn.data``: current values were being normalized without checking if they might be ``None`` (https://github.com/ansible-collections/community.general/pull/5291)."
2 changes: 2 additions & 0 deletions changelogs/fragments/5297-bitwarden-add-search-field.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- bitwarden lookup plugin - add option ``search`` to search for other attributes than name (https://github.com/ansible-collections/community.general/pull/5297).
2 changes: 2 additions & 0 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,8 @@ plugin_routing:
redirect: community.general.identity.keycloak.keycloak_role
keycloak_user_federation:
redirect: community.general.identity.keycloak.keycloak_user_federation
keycloak_user_rolemapping:
redirect: community.general.identity.keycloak.keycloak_user_rolemapping
keyring:
redirect: community.general.system.keyring
keyring_info:
Expand Down
17 changes: 14 additions & 3 deletions plugins/lookup/bitwarden.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
required: true
type: list
elements: str
search:
description: Field to retrieve, for example C(name) or C(id).
type: str
default: name
version_added: 5.7.0
field:
description: Field to fetch; leave unset to fetch whole response.
type: str
Expand All @@ -33,6 +38,11 @@
msg: >-
{{ lookup('community.general.bitwarden', 'a_test', field='password') }}
- name: "Get 'password' from Bitwarden record with id 'bafba515-af11-47e6-abe3-af1200cd18b2'"
ansible.builtin.debug:
msg: >-
{{ lookup('community.general.bitwarden', 'bafba515-af11-47e6-abe3-af1200cd18b2', search='id', field='password') }}
- name: "Get full Bitwarden record named 'a_test'"
ansible.builtin.debug:
msg: >-
Expand Down Expand Up @@ -81,7 +91,7 @@ def _run(self, args, stdin=None, expected_rc=0):
raise BitwardenException(err)
return to_text(out, errors='surrogate_or_strict'), to_text(err, errors='surrogate_or_strict')

def _get_matches(self, search_value, search_field="name"):
def _get_matches(self, search_value, search_field):
"""Return matching records whose search_field is equal to key.
"""
out, err = self._run(['list', 'items', '--search', search_value])
Expand All @@ -97,7 +107,7 @@ def get_field(self, field, search_value, search_field="name"):
If field is None, return the whole record for each match.
"""
matches = self._get_matches(search_value)
matches = self._get_matches(search_value, search_field)

if field:
return [match['login'][field] for match in matches]
Expand All @@ -110,10 +120,11 @@ class LookupModule(LookupBase):
def run(self, terms, variables=None, **kwargs):
self.set_options(var_options=variables, direct=kwargs)
field = self.get_option('field')
search_field = self.get_option('search')
if not _bitwarden.logged_in:
raise AnsibleError("Not logged into Bitwarden. Run 'bw login'.")

return [_bitwarden.get_field(field, term) for term in terms]
return [_bitwarden.get_field(field, term, search_field) for term in terms]


_bitwarden = Bitwarden()
290 changes: 275 additions & 15 deletions plugins/module_utils/identity/keycloak/keycloak.py

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions plugins/module_utils/proxmox.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,7 @@ def get_vm(self, vmid, ignore_missing=False):
return None

self.module.fail_json(msg='VM with vmid %s does not exist in cluster' % vmid)

def api_task_ok(self, node, taskid):
status = self.proxmox_api.nodes(node).tasks(taskid).status.get()
return status['status'] == 'stopped' and status['exitstatus'] == 'OK'
19 changes: 9 additions & 10 deletions plugins/modules/cloud/lxc/lxc_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@
type: list
elements: str
requirements:
- 'lxc >= 1.0 # OS package'
- 'python >= 2.6 # OS Package'
- 'lxc-python2 >= 0.1 # PIP Package from https://github.com/lxc/python2-lxc'
- 'lxc >= 2.0 # OS package'
- 'python3 >= 3.5 # OS Package'
- 'python3-lxc # OS Package'
notes:
- Containers must have a unique name. If you attempt to create a container
with a name that already exists in the users namespace the module will
Expand All @@ -184,10 +184,10 @@
tarball of the running container. The "archive" option supports LVM backed
containers and will create a snapshot of the running container when
creating the archive.
- If your distro does not have a package for "python2-lxc", which is a
- If your distro does not have a package for C(python3-lxc), which is a
requirement for this module, it can be installed from source at
"https://github.com/lxc/python2-lxc" or installed via pip using the package
name lxc-python2.
U(https://github.com/lxc/python3-lxc) or installed via pip using the
package name C(lxc).
'''

EXAMPLES = r"""
Expand Down Expand Up @@ -434,7 +434,6 @@

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.parsing.convert_bool import BOOLEANS_FALSE, BOOLEANS_TRUE
from ansible.module_utils.six.moves import xrange
from ansible.module_utils.common.text.converters import to_text, to_bytes


Expand Down Expand Up @@ -559,7 +558,7 @@
def create_script(command):
"""Write out a script onto a target.
This method should be backward compatible with Python 2.4+ when executing
This method should be backward compatible with Python when executing
from within the container.
:param command: command to run, this can be a script and can use spacing
Expand Down Expand Up @@ -939,7 +938,7 @@ def _container_startup(self, timeout=60):
"""

self.container = self.get_container_bind()
for dummy in xrange(timeout):
for dummy in range(timeout):
if self._get_state() != 'running':
self.container.start()
self.state_change = True
Expand Down Expand Up @@ -992,7 +991,7 @@ def _destroyed(self, timeout=60):
:type timeout: ``int``
"""

for dummy in xrange(timeout):
for dummy in range(timeout):
if not self._container_exists(container_name=self.container_name, lxc_path=self.lxc_path):
break

Expand Down
15 changes: 5 additions & 10 deletions plugins/modules/cloud/misc/proxmox.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,7 @@ def create_instance(self, vmid, node, disk, storage, cpus, memory, swap, timeout
taskid = getattr(proxmox_node, VZ_TYPE).create(vmid=vmid, storage=storage, memory=memory, swap=swap, **kwargs)

while timeout:
if (proxmox_node.tasks(taskid).status.get()['status'] == 'stopped' and
proxmox_node.tasks(taskid).status.get()['exitstatus'] == 'OK'):
if self.api_task_ok(node, taskid):
return True
timeout -= 1
if timeout == 0:
Expand All @@ -496,8 +495,7 @@ def create_instance(self, vmid, node, disk, storage, cpus, memory, swap, timeout
def start_instance(self, vm, vmid, timeout):
taskid = getattr(self.proxmox_api.nodes(vm['node']), VZ_TYPE)(vmid).status.start.post()
while timeout:
if (self.proxmox_api.nodes(vm['node']).tasks(taskid).status.get()['status'] == 'stopped' and
self.proxmox_api.nodes(vm['node']).tasks(taskid).status.get()['exitstatus'] == 'OK'):
if self.api_task_ok(vm['node'], taskid):
return True
timeout -= 1
if timeout == 0:
Expand All @@ -513,8 +511,7 @@ def stop_instance(self, vm, vmid, timeout, force):
else:
taskid = getattr(self.proxmox_api.nodes(vm['node']), VZ_TYPE)(vmid).status.shutdown.post()
while timeout:
if (self.proxmox_api.nodes(vm['node']).tasks(taskid).status.get()['status'] == 'stopped' and
self.proxmox_api.nodes(vm['node']).tasks(taskid).status.get()['exitstatus'] == 'OK'):
if self.api_task_ok(vm['node'], taskid):
return True
timeout -= 1
if timeout == 0:
Expand All @@ -527,8 +524,7 @@ def stop_instance(self, vm, vmid, timeout, force):
def umount_instance(self, vm, vmid, timeout):
taskid = getattr(self.proxmox_api.nodes(vm['node']), VZ_TYPE)(vmid).status.umount.post()
while timeout:
if (self.proxmox_api.nodes(vm['node']).tasks(taskid).status.get()['status'] == 'stopped' and
self.proxmox_api.nodes(vm['node']).tasks(taskid).status.get()['exitstatus'] == 'OK'):
if self.api_task_ok(vm['node'], taskid):
return True
timeout -= 1
if timeout == 0:
Expand Down Expand Up @@ -775,8 +771,7 @@ def main():
taskid = getattr(proxmox.proxmox_api.nodes(vm['node']), VZ_TYPE).delete(vmid, **delete_params)

while timeout:
task_status = proxmox.proxmox_api.nodes(vm['node']).tasks(taskid).status.get()
if (task_status['status'] == 'stopped' and task_status['exitstatus'] == 'OK'):
if proxmox.api_task_ok(vm['node'], taskid):
module.exit_json(changed=True, msg="VM %s removed" % vmid)
timeout -= 1
if timeout == 0:
Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/cloud/misc/proxmox_kvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,8 +866,7 @@ def wait_for_task(self, node, taskid):
timeout = self.module.params['timeout']

while timeout:
task = self.proxmox_api.nodes(node).tasks(taskid).status.get()
if task['status'] == 'stopped' and task['exitstatus'] == 'OK':
if self.api_task_ok(node, taskid):
# Wait an extra second as the API can be a ahead of the hypervisor
time.sleep(1)
return True
Expand Down
Loading

0 comments on commit e89e1e6

Please sign in to comment.