mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-29 01:46:53 +00:00
Compare commits
60 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7dbefcaf1 | ||
|
|
9d5490e510 | ||
|
|
2245742255 | ||
|
|
6058a5e5b1 | ||
|
|
224567e604 | ||
|
|
1eb872ccea | ||
|
|
ba18d6232a | ||
|
|
6115f18837 | ||
|
|
3f4e3dd2b6 | ||
|
|
a573661458 | ||
|
|
0977152b39 | ||
|
|
91fe881226 | ||
|
|
b78c0cf64f | ||
|
|
c79ccbbf7e | ||
|
|
a80761a8a4 | ||
|
|
213419fb0c | ||
|
|
39a1f280e3 | ||
|
|
a13d407247 | ||
|
|
ba3903e6e0 | ||
|
|
4b6b00d249 | ||
|
|
0a0b0cb42d | ||
|
|
d0b39271b3 | ||
|
|
f07cb76b09 | ||
|
|
09031fc9e6 | ||
|
|
4481d0a4a9 | ||
|
|
5861388f11 | ||
|
|
c581daa48a | ||
|
|
75e2de3581 | ||
|
|
6c7bee1225 | ||
|
|
eafcdfbceb | ||
|
|
82a764446b | ||
|
|
a0032f3513 | ||
|
|
8444367cd0 | ||
|
|
de5fbe457f | ||
|
|
40b35acee2 | ||
|
|
9835deb17f | ||
|
|
6fe9cf11f1 | ||
|
|
d3ebdd2874 | ||
|
|
4275bfe87b | ||
|
|
2f87b8c63f | ||
|
|
100fffb4c1 | ||
|
|
1206900488 | ||
|
|
c28ae26636 | ||
|
|
e1e626cdcb | ||
|
|
f8d35eeb14 | ||
|
|
c44298c437 | ||
|
|
1b580476a8 | ||
|
|
44d2d62d38 | ||
|
|
82b2d294b7 | ||
|
|
812fbef786 | ||
|
|
9d795c334b | ||
|
|
512d412eb4 | ||
|
|
8f0ee6966f | ||
|
|
3af9e39043 | ||
|
|
7b78512c59 | ||
|
|
9f0913bf73 | ||
|
|
aea851018b | ||
|
|
69c79f618e | ||
|
|
6a51ba5169 | ||
|
|
52e8e7e928 |
@@ -48,7 +48,7 @@ variables:
|
||||
resources:
|
||||
containers:
|
||||
- container: default
|
||||
image: quay.io/ansible/azure-pipelines-test-container:1.9.0
|
||||
image: quay.io/ansible/azure-pipelines-test-container:3.0.0
|
||||
|
||||
pool: Standard
|
||||
|
||||
|
||||
23
.github/BOTMETA.yml
vendored
23
.github/BOTMETA.yml
vendored
@@ -214,7 +214,7 @@ files:
|
||||
$lookups/dnstxt.py:
|
||||
maintainers: jpmens
|
||||
$lookups/dsv.py:
|
||||
maintainers: amigus endlesstrax
|
||||
maintainers: amigus endlesstrax delineaKrehl tylerezimmerman
|
||||
$lookups/etcd3.py:
|
||||
maintainers: eric-belhomme
|
||||
$lookups/etcd.py:
|
||||
@@ -251,9 +251,12 @@ files:
|
||||
maintainers: RevBits
|
||||
$lookups/shelvefile.py: {}
|
||||
$lookups/tss.py:
|
||||
maintainers: amigus endlesstrax
|
||||
maintainers: amigus endlesstrax delineaKrehl tylerezimmerman
|
||||
$module_utils/:
|
||||
labels: module_utils
|
||||
$module_utils/gconftool2.py:
|
||||
maintainers: russoz
|
||||
labels: gconftool2
|
||||
$module_utils/gitlab.py:
|
||||
notify: jlozadad
|
||||
maintainers: $team_gitlab
|
||||
@@ -304,6 +307,9 @@ files:
|
||||
$module_utils/xenserver.py:
|
||||
maintainers: bvitnik
|
||||
labels: xenserver
|
||||
$module_utils/xfconf.py:
|
||||
maintainers: russoz
|
||||
labels: xfconf
|
||||
$modules/cloud/alicloud/:
|
||||
maintainers: xiaozhu36
|
||||
$modules/cloud/atomic/atomic_container.py:
|
||||
@@ -434,6 +440,8 @@ files:
|
||||
maintainers: claco
|
||||
$modules/cloud/scaleway/:
|
||||
maintainers: $team_scaleway
|
||||
$modules/cloud/scaleway/scaleway_compute_private_network.py:
|
||||
maintainers: pastral
|
||||
$modules/cloud/scaleway/scaleway_database_backup.py:
|
||||
maintainers: guillaume_ro_fr
|
||||
$modules/cloud/scaleway/scaleway_image_info.py:
|
||||
@@ -1024,7 +1032,7 @@ files:
|
||||
$modules/system/alternatives.py:
|
||||
maintainers: mulby
|
||||
labels: alternatives
|
||||
ignore: DavidWittman
|
||||
ignore: DavidWittman jiuka
|
||||
$modules/system/aix_lvol.py:
|
||||
maintainers: adejoux
|
||||
$modules/system/awall.py:
|
||||
@@ -1052,6 +1060,9 @@ files:
|
||||
$modules/system/gconftool2.py:
|
||||
maintainers: Akasurde kevensen
|
||||
labels: gconftool2
|
||||
$modules/system/gconftool2_info.py:
|
||||
maintainers: russoz
|
||||
labels: gconftool2
|
||||
$modules/system/homectl.py:
|
||||
maintainers: jameslivulpi
|
||||
$modules/system/interfaces_file.py:
|
||||
@@ -1059,6 +1070,10 @@ files:
|
||||
labels: interfaces_file
|
||||
$modules/system/iptables_state.py:
|
||||
maintainers: quidame
|
||||
$modules/system/keyring.py:
|
||||
maintainers: ahussey-redhat
|
||||
$modules/system/keyring_info.py:
|
||||
maintainers: ahussey-redhat
|
||||
$modules/system/shutdown.py:
|
||||
maintainers: nitzmahone samdoran aminvakil
|
||||
$modules/system/java_cert.py:
|
||||
@@ -1281,5 +1296,5 @@ macros:
|
||||
team_rhn: FlossWare alikins barnabycourt vritant
|
||||
team_scaleway: remyleone abarbare
|
||||
team_solaris: bcoca fishman jasperla jpdasma mator scathatheworm troy2914 xen0l
|
||||
team_suse: commel dcermak evrardjp lrupp toabctl AnderEnder alxgu andytom sealor
|
||||
team_suse: commel evrardjp lrupp toabctl AnderEnder alxgu andytom sealor
|
||||
team_virt: joshainglis karmab tleguern Thulium-Drake Ajpantuso
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -105,7 +105,7 @@ body:
|
||||
attributes:
|
||||
label: Steps to Reproduce
|
||||
description: |
|
||||
Describe exactly how to reproduce the problem, using a minimal test-case. It would *really* help us understand your problem if you could also pased any playbooks, configs and commands you used.
|
||||
Describe exactly how to reproduce the problem, using a minimal test-case. It would *really* help us understand your problem if you could also passed any playbooks, configs and commands you used.
|
||||
|
||||
**HINT:** You can paste https://gist.github.com links for larger files.
|
||||
value: |
|
||||
|
||||
120
CHANGELOG.rst
120
CHANGELOG.rst
@@ -6,6 +6,126 @@ Community General Release Notes
|
||||
|
||||
This changelog describes changes after version 4.0.0.
|
||||
|
||||
v5.3.0
|
||||
======
|
||||
|
||||
Release Summary
|
||||
---------------
|
||||
|
||||
Regular bugfix and feature release.
|
||||
|
||||
Minor Changes
|
||||
-------------
|
||||
|
||||
- machinectl become plugin - can now be used with a password from another user than root, if a polkit rule is present (https://github.com/ansible-collections/community.general/pull/4849).
|
||||
- opentelemetry callback plugin - allow configuring opentelementry callback via config file (https://github.com/ansible-collections/community.general/pull/4916).
|
||||
- redfish_info - add ``GetManagerInventory`` to report list of Manager inventory information (https://github.com/ansible-collections/community.general/issues/4899).
|
||||
|
||||
Bugfixes
|
||||
--------
|
||||
|
||||
- cmd_runner module utils - fix bug caused by using the ``command`` variable instead of ``self.command`` when looking for binary path (https://github.com/ansible-collections/community.general/pull/4903).
|
||||
- dsv lookup plugin - do not ignore the ``tld`` parameter (https://github.com/ansible-collections/community.general/pull/4911).
|
||||
- lxd connection plugin - fix incorrect ``inventory_hostname`` in ``remote_addr``. This is needed for compatibility with ansible-core 2.13 (https://github.com/ansible-collections/community.general/issues/4886).
|
||||
- proxmox inventory plugin - fix crash when ``enabled=1`` is used in agent config string (https://github.com/ansible-collections/community.general/pull/4910).
|
||||
- rax_clb_nodes - fix code to be compatible with Python 3 (https://github.com/ansible-collections/community.general/pull/4933).
|
||||
- redfish_info - fix to ``GetChassisPower`` to correctly report power information when multiple chassis exist, but not all chassis report power information (https://github.com/ansible-collections/community.general/issues/4901).
|
||||
|
||||
v5.2.0
|
||||
======
|
||||
|
||||
Release Summary
|
||||
---------------
|
||||
|
||||
Regular bugfix and feature release.
|
||||
|
||||
Minor Changes
|
||||
-------------
|
||||
|
||||
- cmd_runner module utils - add ``__call__`` method to invoke context (https://github.com/ansible-collections/community.general/pull/4791).
|
||||
- passwordstore lookup plugin - allow using alternative password managers by detecting wrapper scripts, allow explicit configuration of pass and gopass backends (https://github.com/ansible-collections/community.general/issues/4766).
|
||||
- sudoers - will attempt to validate the proposed sudoers rule using visudo if available, optionally skipped, or required (https://github.com/ansible-collections/community.general/pull/4794, https://github.com/ansible-collections/community.general/issues/4745).
|
||||
|
||||
Bugfixes
|
||||
--------
|
||||
|
||||
- Include ``PSF-license.txt`` file for ``plugins/module_utils/_mount.py``.
|
||||
- redfish_command - fix the check if a virtual media is unmounted to just check for ``instered= false`` caused by Supermicro hardware that does not clear the ``ImageName`` (https://github.com/ansible-collections/community.general/pull/4839).
|
||||
- redfish_command - the Supermicro Redfish implementation only supports the ``image_url`` parameter in the underlying API calls to ``VirtualMediaInsert`` and ``VirtualMediaEject``. Any values set (or the defaults) for ``write_protected`` or ``inserted`` will be ignored (https://github.com/ansible-collections/community.general/pull/4839).
|
||||
- sudoers - fix incorrect handling of ``state: absent`` (https://github.com/ansible-collections/community.general/issues/4852).
|
||||
|
||||
New Modules
|
||||
-----------
|
||||
|
||||
Cloud
|
||||
~~~~~
|
||||
|
||||
scaleway
|
||||
^^^^^^^^
|
||||
|
||||
- scaleway_compute_private_network - Scaleway compute - private network management
|
||||
|
||||
System
|
||||
~~~~~~
|
||||
|
||||
- keyring - Set or delete a passphrase using the Operating System's native keyring
|
||||
- keyring_info - Get a passphrase using the Operating System's native keyring
|
||||
|
||||
v5.1.1
|
||||
======
|
||||
|
||||
Release Summary
|
||||
---------------
|
||||
|
||||
Bugfix release.
|
||||
|
||||
Bugfixes
|
||||
--------
|
||||
|
||||
- alternatives - do not set the priority if the priority was not set by the user (https://github.com/ansible-collections/community.general/pull/4810).
|
||||
- alternatives - only pass subcommands when they are specified as module arguments (https://github.com/ansible-collections/community.general/issues/4803, https://github.com/ansible-collections/community.general/issues/4804, https://github.com/ansible-collections/community.general/pull/4836).
|
||||
- alternatives - when ``subcommands`` is specified, ``link`` must be given for every subcommand. This was already mentioned in the documentation, but not enforced by the code (https://github.com/ansible-collections/community.general/pull/4836).
|
||||
- nmcli - fix error caused by adding undefined module arguments for list options (https://github.com/ansible-collections/community.general/issues/4373, https://github.com/ansible-collections/community.general/pull/4813).
|
||||
- proxmox inventory plugin - fixed extended status detection for qemu (https://github.com/ansible-collections/community.general/pull/4816).
|
||||
- redhat_subscription - fix unsubscribing on RHEL 9 (https://github.com/ansible-collections/community.general/issues/4741).
|
||||
- sudoers - ensure sudoers config files are created with the permissions requested by sudoers (0440) (https://github.com/ansible-collections/community.general/pull/4814).
|
||||
|
||||
v5.1.0
|
||||
======
|
||||
|
||||
Release Summary
|
||||
---------------
|
||||
|
||||
Regular bugfix and feature release.
|
||||
|
||||
Minor Changes
|
||||
-------------
|
||||
|
||||
- ModuleHelper module utils - improved ``ModuleHelperException``, using ``to_native()`` for the exception message (https://github.com/ansible-collections/community.general/pull/4755).
|
||||
- alternatives - add ``state=absent`` to be able to remove an alternative (https://github.com/ansible-collections/community.general/pull/4654).
|
||||
- alternatives - add ``subcommands`` parameter (https://github.com/ansible-collections/community.general/pull/4654).
|
||||
- ansible_galaxy_install - minor refactoring using latest ``ModuleHelper`` updates (https://github.com/ansible-collections/community.general/pull/4752).
|
||||
- cmd_runner module util - added parameters ``check_mode_skip`` and ``check_mode_return`` to ``CmdRunner.context()``, so that the command is not executed when ``check_mode=True`` (https://github.com/ansible-collections/community.general/pull/4736).
|
||||
- nmcli - adds ``vpn`` type and parameter for supporting VPN with service type L2TP and PPTP (https://github.com/ansible-collections/community.general/pull/4746).
|
||||
- proxmox inventory plugin - added new flag ``qemu_extended_statuses`` and new groups ``<group_prefix>prelaunch``, ``<group_prefix>paused``. They will be populated only when ``want_facts=true``, ``qemu_extended_statuses=true`` and only for ``QEMU`` machines (https://github.com/ansible-collections/community.general/pull/4723).
|
||||
- puppet - adds ``confdir`` parameter to configure a custom confir location (https://github.com/ansible-collections/community.general/pull/4740).
|
||||
- xfconf - changed implementation to use ``cmd_runner`` (https://github.com/ansible-collections/community.general/pull/4776).
|
||||
- xfconf module utils - created new module util ``xfconf`` providing a ``cmd_runner`` specific for ``xfconf`` modules (https://github.com/ansible-collections/community.general/pull/4776).
|
||||
- xfconf_info - changed implementation to use ``cmd_runner`` (https://github.com/ansible-collections/community.general/pull/4776).
|
||||
|
||||
Deprecated Features
|
||||
-------------------
|
||||
|
||||
- cmd_runner module utils - deprecated ``fmt`` in favour of ``cmd_runner_fmt`` as the parameter format object (https://github.com/ansible-collections/community.general/pull/4777).
|
||||
|
||||
New Modules
|
||||
-----------
|
||||
|
||||
System
|
||||
~~~~~~
|
||||
|
||||
- gconftool2_info - Retrieve GConf configurations
|
||||
|
||||
v5.0.2
|
||||
======
|
||||
|
||||
|
||||
48
PSF-license.txt
Normal file
48
PSF-license.txt
Normal file
@@ -0,0 +1,48 @@
|
||||
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
|
||||
--------------------------------------------
|
||||
|
||||
1. This LICENSE AGREEMENT is between the Python Software Foundation
|
||||
("PSF"), and the Individual or Organization ("Licensee") accessing and
|
||||
otherwise using this software ("Python") in source or binary form and
|
||||
its associated documentation.
|
||||
|
||||
2. Subject to the terms and conditions of this License Agreement, PSF hereby
|
||||
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
|
||||
analyze, test, perform and/or display publicly, prepare derivative works,
|
||||
distribute, and otherwise use Python alone or in any derivative version,
|
||||
provided, however, that PSF's License Agreement and PSF's notice of copyright,
|
||||
i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Python Software Foundation;
|
||||
All Rights Reserved" are retained in Python alone or in any derivative version
|
||||
prepared by Licensee.
|
||||
|
||||
3. In the event Licensee prepares a derivative work that is based on
|
||||
or incorporates Python or any part thereof, and wants to make
|
||||
the derivative work available to others as provided herein, then
|
||||
Licensee hereby agrees to include in any such work a brief summary of
|
||||
the changes made to Python.
|
||||
|
||||
4. PSF is making Python available to Licensee on an "AS IS"
|
||||
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
||||
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
|
||||
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
|
||||
INFRINGE ANY THIRD PARTY RIGHTS.
|
||||
|
||||
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
||||
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
||||
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
|
||||
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
||||
|
||||
6. This License Agreement will automatically terminate upon a material
|
||||
breach of its terms and conditions.
|
||||
|
||||
7. Nothing in this License Agreement shall be deemed to create any
|
||||
relationship of agency, partnership, or joint venture between PSF and
|
||||
Licensee. This License Agreement does not grant permission to use PSF
|
||||
trademarks or trade name in a trademark sense to endorse or promote
|
||||
products or services of Licensee, or any third party.
|
||||
|
||||
8. By copying, installing or otherwise using Python, Licensee
|
||||
agrees to be bound by the terms and conditions of this License
|
||||
Agreement.
|
||||
@@ -801,3 +801,149 @@ releases:
|
||||
- 5.0.2.yml
|
||||
- simplified-bsd-license.yml
|
||||
release_date: '2022-06-06'
|
||||
5.1.0:
|
||||
changes:
|
||||
deprecated_features:
|
||||
- cmd_runner module utils - deprecated ``fmt`` in favour of ``cmd_runner_fmt``
|
||||
as the parameter format object (https://github.com/ansible-collections/community.general/pull/4777).
|
||||
minor_changes:
|
||||
- ModuleHelper module utils - improved ``ModuleHelperException``, using ``to_native()``
|
||||
for the exception message (https://github.com/ansible-collections/community.general/pull/4755).
|
||||
- alternatives - add ``state=absent`` to be able to remove an alternative (https://github.com/ansible-collections/community.general/pull/4654).
|
||||
- alternatives - add ``subcommands`` parameter (https://github.com/ansible-collections/community.general/pull/4654).
|
||||
- ansible_galaxy_install - minor refactoring using latest ``ModuleHelper`` updates
|
||||
(https://github.com/ansible-collections/community.general/pull/4752).
|
||||
- cmd_runner module util - added parameters ``check_mode_skip`` and ``check_mode_return``
|
||||
to ``CmdRunner.context()``, so that the command is not executed when ``check_mode=True``
|
||||
(https://github.com/ansible-collections/community.general/pull/4736).
|
||||
- nmcli - adds ``vpn`` type and parameter for supporting VPN with service type
|
||||
L2TP and PPTP (https://github.com/ansible-collections/community.general/pull/4746).
|
||||
- proxmox inventory plugin - added new flag ``qemu_extended_statuses`` and new
|
||||
groups ``<group_prefix>prelaunch``, ``<group_prefix>paused``. They will be
|
||||
populated only when ``want_facts=true``, ``qemu_extended_statuses=true`` and
|
||||
only for ``QEMU`` machines (https://github.com/ansible-collections/community.general/pull/4723).
|
||||
- puppet - adds ``confdir`` parameter to configure a custom confir location
|
||||
(https://github.com/ansible-collections/community.general/pull/4740).
|
||||
- xfconf - changed implementation to use ``cmd_runner`` (https://github.com/ansible-collections/community.general/pull/4776).
|
||||
- xfconf module utils - created new module util ``xfconf`` providing a ``cmd_runner``
|
||||
specific for ``xfconf`` modules (https://github.com/ansible-collections/community.general/pull/4776).
|
||||
- xfconf_info - changed implementation to use ``cmd_runner`` (https://github.com/ansible-collections/community.general/pull/4776).
|
||||
release_summary: Regular bugfix and feature release.
|
||||
fragments:
|
||||
- 4654-alternatives-add-subcommands.yml
|
||||
- 4724-proxmox-qemu-extend.yaml
|
||||
- 4736-cmd-runner-skip-if-check.yml
|
||||
- 4740-puppet-feature.yaml
|
||||
- 4746-add-vpn-support-nmcli.yaml
|
||||
- 4752-ansible-galaxy-install-mh-updates.yml
|
||||
- 4755-mhexception-improvement.yml
|
||||
- 4776-xfconf-cmd-runner.yaml
|
||||
- 4777-cmd-runner-deprecate-fmt.yaml
|
||||
- 5.1.0.yml
|
||||
modules:
|
||||
- description: Retrieve GConf configurations
|
||||
name: gconftool2_info
|
||||
namespace: system
|
||||
release_date: '2022-06-07'
|
||||
5.1.1:
|
||||
changes:
|
||||
bugfixes:
|
||||
- alternatives - do not set the priority if the priority was not set by the
|
||||
user (https://github.com/ansible-collections/community.general/pull/4810).
|
||||
- alternatives - only pass subcommands when they are specified as module arguments
|
||||
(https://github.com/ansible-collections/community.general/issues/4803, https://github.com/ansible-collections/community.general/issues/4804,
|
||||
https://github.com/ansible-collections/community.general/pull/4836).
|
||||
- alternatives - when ``subcommands`` is specified, ``link`` must be given for
|
||||
every subcommand. This was already mentioned in the documentation, but not
|
||||
enforced by the code (https://github.com/ansible-collections/community.general/pull/4836).
|
||||
- nmcli - fix error caused by adding undefined module arguments for list options
|
||||
(https://github.com/ansible-collections/community.general/issues/4373, https://github.com/ansible-collections/community.general/pull/4813).
|
||||
- proxmox inventory plugin - fixed extended status detection for qemu (https://github.com/ansible-collections/community.general/pull/4816).
|
||||
- redhat_subscription - fix unsubscribing on RHEL 9 (https://github.com/ansible-collections/community.general/issues/4741).
|
||||
- sudoers - ensure sudoers config files are created with the permissions requested
|
||||
by sudoers (0440) (https://github.com/ansible-collections/community.general/pull/4814).
|
||||
release_summary: Bugfix release.
|
||||
fragments:
|
||||
- 4809-redhat_subscription-unsubscribe.yaml
|
||||
- 4810-alternatives-bug.yml
|
||||
- 4813-fix-nmcli-convert-list.yaml
|
||||
- 4814-sudoers-file-permissions.yml
|
||||
- 4816-proxmox-fix-extended-status.yaml
|
||||
- 4836-alternatives.yml
|
||||
- 5.1.1.yml
|
||||
release_date: '2022-06-14'
|
||||
5.2.0:
|
||||
changes:
|
||||
bugfixes:
|
||||
- Include ``PSF-license.txt`` file for ``plugins/module_utils/_mount.py``.
|
||||
- redfish_command - fix the check if a virtual media is unmounted to just check
|
||||
for ``instered= false`` caused by Supermicro hardware that does not clear
|
||||
the ``ImageName`` (https://github.com/ansible-collections/community.general/pull/4839).
|
||||
- redfish_command - the Supermicro Redfish implementation only supports the
|
||||
``image_url`` parameter in the underlying API calls to ``VirtualMediaInsert``
|
||||
and ``VirtualMediaEject``. Any values set (or the defaults) for ``write_protected``
|
||||
or ``inserted`` will be ignored (https://github.com/ansible-collections/community.general/pull/4839).
|
||||
- 'sudoers - fix incorrect handling of ``state: absent`` (https://github.com/ansible-collections/community.general/issues/4852).'
|
||||
minor_changes:
|
||||
- cmd_runner module utils - add ``__call__`` method to invoke context (https://github.com/ansible-collections/community.general/pull/4791).
|
||||
- passwordstore lookup plugin - allow using alternative password managers by
|
||||
detecting wrapper scripts, allow explicit configuration of pass and gopass
|
||||
backends (https://github.com/ansible-collections/community.general/issues/4766).
|
||||
- sudoers - will attempt to validate the proposed sudoers rule using visudo
|
||||
if available, optionally skipped, or required (https://github.com/ansible-collections/community.general/pull/4794,
|
||||
https://github.com/ansible-collections/community.general/issues/4745).
|
||||
release_summary: Regular bugfix and feature release.
|
||||
fragments:
|
||||
- 4780-passwordstore-wrapper-compat.yml
|
||||
- 4791-cmd-runner-callable.yaml
|
||||
- 4794-sudoers-validation.yml
|
||||
- 4839-fix-VirtualMediaInsert-Supermicro.yml
|
||||
- 4852-sudoers-state-absent.yml
|
||||
- 5.2.0.yml
|
||||
- psf-license.yml
|
||||
modules:
|
||||
- description: Set or delete a passphrase using the Operating System's native
|
||||
keyring
|
||||
name: keyring
|
||||
namespace: system
|
||||
- description: Get a passphrase using the Operating System's native keyring
|
||||
name: keyring_info
|
||||
namespace: system
|
||||
- description: Scaleway compute - private network management
|
||||
name: scaleway_compute_private_network
|
||||
namespace: cloud.scaleway
|
||||
release_date: '2022-06-21'
|
||||
5.3.0:
|
||||
changes:
|
||||
bugfixes:
|
||||
- cmd_runner module utils - fix bug caused by using the ``command`` variable
|
||||
instead of ``self.command`` when looking for binary path (https://github.com/ansible-collections/community.general/pull/4903).
|
||||
- dsv lookup plugin - do not ignore the ``tld`` parameter (https://github.com/ansible-collections/community.general/pull/4911).
|
||||
- lxd connection plugin - fix incorrect ``inventory_hostname`` in ``remote_addr``.
|
||||
This is needed for compatibility with ansible-core 2.13 (https://github.com/ansible-collections/community.general/issues/4886).
|
||||
- proxmox inventory plugin - fix crash when ``enabled=1`` is used in agent config
|
||||
string (https://github.com/ansible-collections/community.general/pull/4910).
|
||||
- rax_clb_nodes - fix code to be compatible with Python 3 (https://github.com/ansible-collections/community.general/pull/4933).
|
||||
- redfish_info - fix to ``GetChassisPower`` to correctly report power information
|
||||
when multiple chassis exist, but not all chassis report power information
|
||||
(https://github.com/ansible-collections/community.general/issues/4901).
|
||||
minor_changes:
|
||||
- machinectl become plugin - can now be used with a password from another user
|
||||
than root, if a polkit rule is present (https://github.com/ansible-collections/community.general/pull/4849).
|
||||
- opentelemetry callback plugin - allow configuring opentelementry callback
|
||||
via config file (https://github.com/ansible-collections/community.general/pull/4916).
|
||||
- redfish_info - add ``GetManagerInventory`` to report list of Manager inventory
|
||||
information (https://github.com/ansible-collections/community.general/issues/4899).
|
||||
release_summary: Regular bugfix and feature release.
|
||||
fragments:
|
||||
- 4849-add-password-prompt-support-for-machinectl.yml
|
||||
- 4886-fix-lxd-inventory-hostname.yml
|
||||
- 4899-add-GetManagerInventory-for-redfish_info.yml
|
||||
- 4901-fix-redfish-chassispower.yml
|
||||
- 4903-cmdrunner-bugfix.yaml
|
||||
- 4910-fix-for-agent-enabled.yml
|
||||
- 4911-dsv-honor-tld-option.yml
|
||||
- 4916-opentelemetry-ini-options.yaml
|
||||
- 4933-fix-rax-clb-nodes.yaml
|
||||
- 5.3.0.yml
|
||||
release_date: '2022-07-12'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace: community
|
||||
name: general
|
||||
version: 5.0.2
|
||||
version: 5.3.0
|
||||
readme: README.md
|
||||
authors:
|
||||
- Ansible (https://github.com/ansible)
|
||||
|
||||
@@ -292,6 +292,8 @@ plugin_routing:
|
||||
redirect: community.google.gce_tag
|
||||
gconftool2:
|
||||
redirect: community.general.system.gconftool2
|
||||
gconftool2_info:
|
||||
redirect: community.general.system.gconftool2_info
|
||||
gcp_backend_service:
|
||||
tombstone:
|
||||
removal_version: 2.0.0
|
||||
@@ -606,6 +608,10 @@ plugin_routing:
|
||||
redirect: community.general.identity.keycloak.keycloak_role
|
||||
keycloak_user_federation:
|
||||
redirect: community.general.identity.keycloak.keycloak_user_federation
|
||||
keyring:
|
||||
redirect: community.general.system.keyring
|
||||
keyring_info:
|
||||
redirect: community.general.system.keyring_info
|
||||
kibana_plugin:
|
||||
redirect: community.general.database.misc.kibana_plugin
|
||||
kubevirt_cdi_upload:
|
||||
@@ -1355,6 +1361,8 @@ plugin_routing:
|
||||
redirect: community.general.notification.say
|
||||
scaleway_compute:
|
||||
redirect: community.general.cloud.scaleway.scaleway_compute
|
||||
scaleway_compute_private_network:
|
||||
redirect: community.general.cloud.scaleway.scaleway_compute_private_network
|
||||
scaleway_database_backup:
|
||||
redirect: community.general.cloud.scaleway.scaleway_database_backup
|
||||
scaleway_image_facts:
|
||||
|
||||
@@ -66,15 +66,46 @@ DOCUMENTATION = '''
|
||||
ini:
|
||||
- section: machinectl_become_plugin
|
||||
key: password
|
||||
notes:
|
||||
- When not using this plugin with user C(root), it only works correctly with a polkit rule which will alter
|
||||
the behaviour of machinectl. This rule must alter the prompt behaviour to ask directly for the user credentials,
|
||||
if the user is allowed to perform the action (take a look at the examples section).
|
||||
If such a rule is not present the plugin only work if it is used in context with the root user,
|
||||
because then no further prompt will be shown by machinectl.
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
# A polkit rule needed to use the module with a non-root user.
|
||||
# See the Notes section for details.
|
||||
60-machinectl-fast-user-auth.rules: |
|
||||
polkit.addRule(function(action, subject) {
|
||||
if(action.id == "org.freedesktop.machine1.host-shell" && subject.isInGroup("wheel")) {
|
||||
return polkit.Result.AUTH_SELF_KEEP;
|
||||
}
|
||||
});
|
||||
'''
|
||||
|
||||
from re import compile as re_compile
|
||||
|
||||
from ansible.plugins.become import BecomeBase
|
||||
from ansible.module_utils._text import to_bytes
|
||||
|
||||
|
||||
ansi_color_codes = re_compile(to_bytes(r'\x1B\[[0-9;]+m'))
|
||||
|
||||
|
||||
class BecomeModule(BecomeBase):
|
||||
|
||||
name = 'community.general.machinectl'
|
||||
|
||||
prompt = 'Password: '
|
||||
fail = ('==== AUTHENTICATION FAILED ====',)
|
||||
success = ('==== AUTHENTICATION COMPLETE ====',)
|
||||
|
||||
@staticmethod
|
||||
def remove_ansi_codes(line):
|
||||
return ansi_color_codes.sub(b"", line)
|
||||
|
||||
def build_become_command(self, cmd, shell):
|
||||
super(BecomeModule, self).build_become_command(cmd, shell)
|
||||
|
||||
@@ -86,3 +117,15 @@ class BecomeModule(BecomeBase):
|
||||
flags = self.get_option('become_flags')
|
||||
user = self.get_option('become_user')
|
||||
return '%s -q shell %s %s@ %s' % (become, flags, user, cmd)
|
||||
|
||||
def check_success(self, b_output):
|
||||
b_output = self.remove_ansi_codes(b_output)
|
||||
return super().check_success(b_output)
|
||||
|
||||
def check_incorrect_password(self, b_output):
|
||||
b_output = self.remove_ansi_codes(b_output)
|
||||
return super().check_incorrect_password(b_output)
|
||||
|
||||
def check_missing_password(self, b_output):
|
||||
b_output = self.remove_ansi_codes(b_output)
|
||||
return super().check_missing_password(b_output)
|
||||
|
||||
@@ -12,7 +12,7 @@ DOCUMENTATION = '''
|
||||
type: notification
|
||||
short_description: write playbook output to log file
|
||||
description:
|
||||
- This callback writes playbook output to a file per host in the `/var/log/ansible/hosts` directory
|
||||
- This callback writes playbook output to a file per host in the C(/var/log/ansible/hosts) directory
|
||||
requirements:
|
||||
- Whitelist in configuration
|
||||
- A writeable /var/log/ansible/hosts directory by the user executing Ansible on the controller
|
||||
|
||||
@@ -24,6 +24,10 @@ DOCUMENTATION = '''
|
||||
- Hide the arguments for a task.
|
||||
env:
|
||||
- name: ANSIBLE_OPENTELEMETRY_HIDE_TASK_ARGUMENTS
|
||||
ini:
|
||||
- section: callback_opentelemetry
|
||||
key: hide_task_arguments
|
||||
version_added: 5.3.0
|
||||
enable_from_environment:
|
||||
type: str
|
||||
description:
|
||||
@@ -34,6 +38,10 @@ DOCUMENTATION = '''
|
||||
and if set to true this plugin will be enabled.
|
||||
env:
|
||||
- name: ANSIBLE_OPENTELEMETRY_ENABLE_FROM_ENVIRONMENT
|
||||
ini:
|
||||
- section: callback_opentelemetry
|
||||
key: enable_from_environment
|
||||
version_added: 5.3.0
|
||||
version_added: 3.8.0
|
||||
otel_service_name:
|
||||
default: ansible
|
||||
@@ -42,6 +50,10 @@ DOCUMENTATION = '''
|
||||
- The service name resource attribute.
|
||||
env:
|
||||
- name: OTEL_SERVICE_NAME
|
||||
ini:
|
||||
- section: callback_opentelemetry
|
||||
key: otel_service_name
|
||||
version_added: 5.3.0
|
||||
traceparent:
|
||||
default: None
|
||||
type: str
|
||||
@@ -61,11 +73,14 @@ examples: |
|
||||
Enable the plugin in ansible.cfg:
|
||||
[defaults]
|
||||
callbacks_enabled = community.general.opentelemetry
|
||||
[callback_opentelemetry]
|
||||
enable_from_environment = ANSIBLE_OPENTELEMETRY_ENABLED
|
||||
|
||||
Set the environment variable:
|
||||
export OTEL_EXPORTER_OTLP_ENDPOINT=<your endpoint (OTLP/HTTP)>
|
||||
export OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer your_otel_token"
|
||||
export OTEL_SERVICE_NAME=your_service_name
|
||||
export ANSIBLE_OPENTELEMETRY_ENABLED=true
|
||||
'''
|
||||
|
||||
import getpass
|
||||
|
||||
@@ -14,9 +14,9 @@ DOCUMENTATION = '''
|
||||
- set as main display callback
|
||||
short_description: only print certain tasks
|
||||
description:
|
||||
- This callback only prints tasks that have been tagged with `print_action` or that have failed.
|
||||
- This callback only prints tasks that have been tagged with C(print_action) or that have failed.
|
||||
This allows operators to focus on the tasks that provide value only.
|
||||
- Tasks that are not printed are placed with a '.'.
|
||||
- Tasks that are not printed are placed with a C(.).
|
||||
- If you increase verbosity all tasks are printed.
|
||||
options:
|
||||
nocolor:
|
||||
|
||||
@@ -18,6 +18,7 @@ DOCUMENTATION = '''
|
||||
- Container identifier.
|
||||
default: inventory_hostname
|
||||
vars:
|
||||
- name: inventory_hostname
|
||||
- name: ansible_host
|
||||
- name: ansible_lxd_host
|
||||
executable:
|
||||
@@ -61,7 +62,6 @@ class Connection(ConnectionBase):
|
||||
def __init__(self, play_context, new_stdin, *args, **kwargs):
|
||||
super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
|
||||
|
||||
self._host = self._play_context.remote_addr
|
||||
try:
|
||||
self._lxc_cmd = get_bin_path("lxc")
|
||||
except ValueError:
|
||||
@@ -75,14 +75,14 @@ class Connection(ConnectionBase):
|
||||
super(Connection, self)._connect()
|
||||
|
||||
if not self._connected:
|
||||
self._display.vvv(u"ESTABLISH LXD CONNECTION FOR USER: root", host=self._host)
|
||||
self._display.vvv(u"ESTABLISH LXD CONNECTION FOR USER: root", host=self.get_option('remote_addr'))
|
||||
self._connected = True
|
||||
|
||||
def exec_command(self, cmd, in_data=None, sudoable=True):
|
||||
""" execute a command on the lxd host """
|
||||
super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
|
||||
|
||||
self._display.vvv(u"EXEC {0}".format(cmd), host=self._host)
|
||||
self._display.vvv(u"EXEC {0}".format(cmd), host=self.get_option('remote_addr'))
|
||||
|
||||
local_cmd = [self._lxc_cmd]
|
||||
if self.get_option("project"):
|
||||
@@ -104,10 +104,10 @@ class Connection(ConnectionBase):
|
||||
stderr = to_text(stderr)
|
||||
|
||||
if stderr == "error: Container is not running.\n":
|
||||
raise AnsibleConnectionFailure("container not running: %s" % self._host)
|
||||
raise AnsibleConnectionFailure("container not running: %s" % self.get_option('remote_addr'))
|
||||
|
||||
if stderr == "error: not found\n":
|
||||
raise AnsibleConnectionFailure("container not found: %s" % self._host)
|
||||
raise AnsibleConnectionFailure("container not found: %s" % self.get_option('remote_addr'))
|
||||
|
||||
return process.returncode, stdout, stderr
|
||||
|
||||
@@ -115,7 +115,7 @@ class Connection(ConnectionBase):
|
||||
""" put a file from local to lxd """
|
||||
super(Connection, self).put_file(in_path, out_path)
|
||||
|
||||
self._display.vvv(u"PUT {0} TO {1}".format(in_path, out_path), host=self._host)
|
||||
self._display.vvv(u"PUT {0} TO {1}".format(in_path, out_path), host=self.get_option('remote_addr'))
|
||||
|
||||
if not os.path.isfile(to_bytes(in_path, errors='surrogate_or_strict')):
|
||||
raise AnsibleFileNotFound("input path is not a file: %s" % in_path)
|
||||
@@ -138,7 +138,7 @@ class Connection(ConnectionBase):
|
||||
""" fetch a file from lxd to local """
|
||||
super(Connection, self).fetch_file(in_path, out_path)
|
||||
|
||||
self._display.vvv(u"FETCH {0} TO {1}".format(in_path, out_path), host=self._host)
|
||||
self._display.vvv(u"FETCH {0} TO {1}".format(in_path, out_path), host=self.get_option('remote_addr'))
|
||||
|
||||
local_cmd = [self._lxc_cmd]
|
||||
if self.get_option("project"):
|
||||
|
||||
@@ -21,7 +21,7 @@ DOCUMENTATION = '''
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
- name: Count occurences
|
||||
- name: Count occurrences
|
||||
ansible.builtin.debug:
|
||||
msg: >-
|
||||
{{ [1, 'a', 2, 2, 'a', 'b', 'a'] | community.general.counter }}
|
||||
@@ -30,7 +30,7 @@ EXAMPLES = '''
|
||||
|
||||
RETURN = '''
|
||||
_value:
|
||||
description: A dictionary with the elements of the sequence as keys, and their number of occurance in the sequence as values.
|
||||
description: A dictionary with the elements of the sequence as keys, and their number of occurrences in the sequence as values.
|
||||
type: dictionary
|
||||
'''
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ DOCUMENTATION = '''
|
||||
parser:
|
||||
description:
|
||||
- The correct parser for the input data.
|
||||
- For exmaple C(ifconfig).
|
||||
- For example C(ifconfig).
|
||||
- See U(https://github.com/kellyjonbrazil/jc#parsers) for the latest list of parsers.
|
||||
type: string
|
||||
required: true
|
||||
|
||||
@@ -213,7 +213,7 @@ class InventoryModule(BaseInventoryPlugin, Cacheable):
|
||||
self.inventory.add_child(parent_group_name, group_name)
|
||||
else:
|
||||
self.display.vvvv('Processing profile %s without parent\n' % profile['name'])
|
||||
# Create a heirarchy of profile names
|
||||
# Create a hierarchy of profile names
|
||||
profile_elements = profile['name'].split('-')
|
||||
i = 0
|
||||
while i < len(profile_elements) - 1:
|
||||
|
||||
@@ -522,7 +522,7 @@ class InventoryModule(BaseInventoryPlugin):
|
||||
"""Helper to save data
|
||||
|
||||
Helper to save the data in self.data
|
||||
Detect if data is allready in branch and use dict_merge() to prevent that branch is overwritten.
|
||||
Detect if data is already in branch and use dict_merge() to prevent that branch is overwritten.
|
||||
|
||||
Args:
|
||||
str(instance_name): name of instance
|
||||
|
||||
@@ -92,9 +92,21 @@ DOCUMENTATION = '''
|
||||
default: proxmox_
|
||||
type: str
|
||||
want_facts:
|
||||
description: Gather LXC/QEMU configuration facts.
|
||||
description:
|
||||
- Gather LXC/QEMU configuration facts.
|
||||
- When I(want_facts) is set to C(true) more details about QEMU VM status are possible, besides the running and stopped states.
|
||||
Currently if the VM is running and it is suspended, the status will be running and the machine will be in C(running) group,
|
||||
but its actual state will be paused. See I(qemu_extended_statuses) for how to retrieve the real status.
|
||||
default: no
|
||||
type: bool
|
||||
qemu_extended_statuses:
|
||||
description:
|
||||
- Requires I(want_facts) to be set to C(true) to function. This will allow you to differentiate betweend C(paused) and C(prelaunch)
|
||||
statuses of the QEMU VMs.
|
||||
- This introduces multiple groups [prefixed with I(group_prefix)] C(prelaunch) and C(paused).
|
||||
default: no
|
||||
type: bool
|
||||
version_added: 5.1.0
|
||||
want_proxmox_nodes_ansible_host:
|
||||
version_added: 3.0.0
|
||||
description:
|
||||
@@ -400,12 +412,20 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
||||
properties[parsed_key] = [tag.strip() for tag in stripped_value.split(",")]
|
||||
|
||||
# The first field in the agent string tells you whether the agent is enabled
|
||||
# the rest of the comma separated string is extra config for the agent
|
||||
if config == 'agent' and int(value.split(',')[0]):
|
||||
agent_iface_value = self._get_agent_network_interfaces(node, vmid, vmtype)
|
||||
if agent_iface_value:
|
||||
agent_iface_key = self.to_safe('%s%s' % (key, "_interfaces"))
|
||||
properties[agent_iface_key] = agent_iface_value
|
||||
# the rest of the comma separated string is extra config for the agent.
|
||||
# In some (newer versions of proxmox) instances it can be 'enabled=1'.
|
||||
if config == 'agent':
|
||||
agent_enabled = 0
|
||||
try:
|
||||
agent_enabled = int(value.split(',')[0])
|
||||
except ValueError:
|
||||
if value.split(',')[0] == "enabled=1":
|
||||
agent_enabled = 1
|
||||
if agent_enabled:
|
||||
agent_iface_value = self._get_agent_network_interfaces(node, vmid, vmtype)
|
||||
if agent_iface_value:
|
||||
agent_iface_key = self.to_safe('%s%s' % (key, "_interfaces"))
|
||||
properties[agent_iface_key] = agent_iface_value
|
||||
|
||||
if config == 'lxc':
|
||||
out_val = {}
|
||||
@@ -431,6 +451,8 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
||||
def _get_vm_status(self, properties, node, vmid, vmtype, name):
|
||||
ret = self._get_json("%s/api2/json/nodes/%s/%s/%s/status/current" % (self.proxmox_url, node, vmtype, vmid))
|
||||
properties[self._fact('status')] = ret['status']
|
||||
if vmtype == 'qemu':
|
||||
properties[self._fact('qmpstatus')] = ret['qmpstatus']
|
||||
|
||||
def _get_vm_snapshots(self, properties, node, vmid, vmtype, name):
|
||||
ret = self._get_json("%s/api2/json/nodes/%s/%s/%s/snapshot" % (self.proxmox_url, node, vmtype, vmid))
|
||||
@@ -489,7 +511,8 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
||||
name, vmid = item['name'], item['vmid']
|
||||
|
||||
# get status, config and snapshots if want_facts == True
|
||||
if self.get_option('want_facts'):
|
||||
want_facts = self.get_option('want_facts')
|
||||
if want_facts:
|
||||
self._get_vm_status(properties, node, vmid, ittype, name)
|
||||
self._get_vm_config(properties, node, vmid, ittype, name)
|
||||
self._get_vm_snapshots(properties, node, vmid, ittype, name)
|
||||
@@ -503,10 +526,13 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
||||
node_type_group = self._group('%s_%s' % (node, ittype))
|
||||
self.inventory.add_child(self._group('all_' + ittype), name)
|
||||
self.inventory.add_child(node_type_group, name)
|
||||
if item['status'] == 'stopped':
|
||||
self.inventory.add_child(self._group('all_stopped'), name)
|
||||
elif item['status'] == 'running':
|
||||
self.inventory.add_child(self._group('all_running'), name)
|
||||
|
||||
item_status = item['status']
|
||||
if item_status == 'running':
|
||||
if want_facts and ittype == 'qemu' and self.get_option('qemu_extended_statuses'):
|
||||
# get more details about the status of the qemu VM
|
||||
item_status = properties.get(self._fact('qmpstatus'), item_status)
|
||||
self.inventory.add_child(self._group('all_%s' % (item_status, )), name)
|
||||
|
||||
return name
|
||||
|
||||
@@ -528,10 +554,14 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
||||
def _populate(self):
|
||||
|
||||
# create common groups
|
||||
self.inventory.add_group(self._group('all_lxc'))
|
||||
self.inventory.add_group(self._group('all_qemu'))
|
||||
self.inventory.add_group(self._group('all_running'))
|
||||
self.inventory.add_group(self._group('all_stopped'))
|
||||
default_groups = ['lxc', 'qemu', 'running', 'stopped']
|
||||
|
||||
if self.get_option('qemu_extended_statuses'):
|
||||
default_groups.extend(['prelaunch', 'paused'])
|
||||
|
||||
for group in default_groups:
|
||||
self.inventory.add_group(self._group('all_%s' % (group)))
|
||||
|
||||
nodes_group = self._group('nodes')
|
||||
self.inventory.add_group(nodes_group)
|
||||
|
||||
@@ -621,6 +651,9 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
||||
if proxmox_password is None and (proxmox_token_id is None or proxmox_token_secret is None):
|
||||
raise AnsibleError('You must specify either a password or both token_id and token_secret.')
|
||||
|
||||
if self.get_option('qemu_extended_statuses') and not self.get_option('want_facts'):
|
||||
raise AnsibleError('You must set want_facts to True if you want to use qemu_extended_statuses.')
|
||||
|
||||
self.cache_key = self.get_cache_key(path)
|
||||
self.use_cache = cache and self.get_option('cache')
|
||||
self.host_filters = self.get_option('filters')
|
||||
|
||||
@@ -16,7 +16,7 @@ DOCUMENTATION = '''
|
||||
The lookup order mirrors the one from Chef, all folders in the base path are walked back looking for the following configuration
|
||||
file in order : .chef/knife.rb, ~/.chef/knife.rb, /etc/chef/client.rb"
|
||||
requirements:
|
||||
- "pychef (python library https://pychef.readthedocs.io `pip install pychef`)"
|
||||
- "pychef (L(Python library, https://pychef.readthedocs.io), C(pip install pychef))"
|
||||
options:
|
||||
name:
|
||||
description:
|
||||
|
||||
@@ -122,6 +122,7 @@ class LookupModule(LookupBase):
|
||||
"tenant": self.get_option("tenant"),
|
||||
"client_id": self.get_option("client_id"),
|
||||
"client_secret": self.get_option("client_secret"),
|
||||
"tld": self.get_option("tld"),
|
||||
"url_template": self.get_option("url_template"),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -106,6 +106,22 @@ DOCUMENTATION = '''
|
||||
type: str
|
||||
default: 15m
|
||||
version_added: 4.5.0
|
||||
backend:
|
||||
description:
|
||||
- Specify which backend to use.
|
||||
- Defaults to C(pass), passwordstore.org's original pass utility.
|
||||
- C(gopass) support is incomplete.
|
||||
ini:
|
||||
- section: passwordstore_lookup
|
||||
key: backend
|
||||
vars:
|
||||
- name: passwordstore_backend
|
||||
type: str
|
||||
default: pass
|
||||
choices:
|
||||
- pass
|
||||
- gopass
|
||||
version_added: 5.2.0
|
||||
'''
|
||||
EXAMPLES = """
|
||||
ansible.cfg: |
|
||||
@@ -231,6 +247,24 @@ def check_output2(*popenargs, **kwargs):
|
||||
|
||||
|
||||
class LookupModule(LookupBase):
|
||||
def __init__(self, loader=None, templar=None, **kwargs):
|
||||
|
||||
super(LookupModule, self).__init__(loader, templar, **kwargs)
|
||||
self.realpass = None
|
||||
|
||||
def is_real_pass(self):
|
||||
if self.realpass is None:
|
||||
try:
|
||||
self.passoutput = to_text(
|
||||
check_output2([self.pass_cmd, "--version"], env=self.env),
|
||||
errors='surrogate_or_strict'
|
||||
)
|
||||
self.realpass = 'pass: the standard unix password manager' in self.passoutput
|
||||
except (subprocess.CalledProcessError) as e:
|
||||
raise AnsibleError(e)
|
||||
|
||||
return self.realpass
|
||||
|
||||
def parse_params(self, term):
|
||||
# I went with the "traditional" param followed with space separated KV pairs.
|
||||
# Waiting for final implementation of lookup parameter parsing.
|
||||
@@ -270,10 +304,12 @@ class LookupModule(LookupBase):
|
||||
self.env = os.environ.copy()
|
||||
self.env['LANGUAGE'] = 'C' # make sure to get errors in English as required by check_output2
|
||||
|
||||
# Set PASSWORD_STORE_DIR
|
||||
if os.path.isdir(self.paramvals['directory']):
|
||||
if self.backend == 'gopass':
|
||||
self.env['GOPASS_NO_REMINDER'] = "YES"
|
||||
elif os.path.isdir(self.paramvals['directory']):
|
||||
# Set PASSWORD_STORE_DIR
|
||||
self.env['PASSWORD_STORE_DIR'] = self.paramvals['directory']
|
||||
else:
|
||||
elif self.is_real_pass():
|
||||
raise AnsibleError('Passwordstore directory \'{0}\' does not exist'.format(self.paramvals['directory']))
|
||||
|
||||
# Set PASSWORD_STORE_UMASK if umask is set
|
||||
@@ -288,7 +324,9 @@ class LookupModule(LookupBase):
|
||||
def check_pass(self):
|
||||
try:
|
||||
self.passoutput = to_text(
|
||||
check_output2(["pass", "show", self.passname], env=self.env),
|
||||
check_output2([self.pass_cmd, 'show'] +
|
||||
(['--password'] if self.backend == 'gopass' else []) +
|
||||
[self.passname], env=self.env),
|
||||
errors='surrogate_or_strict'
|
||||
).splitlines()
|
||||
self.password = self.passoutput[0]
|
||||
@@ -302,8 +340,10 @@ class LookupModule(LookupBase):
|
||||
if ':' in line:
|
||||
name, value = line.split(':', 1)
|
||||
self.passdict[name.strip()] = value.strip()
|
||||
if os.path.isfile(os.path.join(self.paramvals['directory'], self.passname + ".gpg")):
|
||||
# Only accept password as found, if there a .gpg file for it (might be a tree node otherwise)
|
||||
if (self.backend == 'gopass' or
|
||||
os.path.isfile(os.path.join(self.paramvals['directory'], self.passname + ".gpg"))
|
||||
or not self.is_real_pass()):
|
||||
# When using real pass, only accept password as found if there is a .gpg file for it (might be a tree node otherwise)
|
||||
return True
|
||||
except (subprocess.CalledProcessError) as e:
|
||||
# 'not in password store' is the expected error if a password wasn't found
|
||||
@@ -339,7 +379,7 @@ class LookupModule(LookupBase):
|
||||
if self.paramvals['backup']:
|
||||
msg += "lookup_pass: old password was {0} (Updated on {1})\n".format(self.password, datetime)
|
||||
try:
|
||||
check_output2(['pass', 'insert', '-f', '-m', self.passname], input=msg, env=self.env)
|
||||
check_output2([self.pass_cmd, 'insert', '-f', '-m', self.passname], input=msg, env=self.env)
|
||||
except (subprocess.CalledProcessError) as e:
|
||||
raise AnsibleError(e)
|
||||
return newpass
|
||||
@@ -351,7 +391,7 @@ class LookupModule(LookupBase):
|
||||
datetime = time.strftime("%d/%m/%Y %H:%M:%S")
|
||||
msg = newpass + '\n' + "lookup_pass: First generated by ansible on {0}\n".format(datetime)
|
||||
try:
|
||||
check_output2(['pass', 'insert', '-f', '-m', self.passname], input=msg, env=self.env)
|
||||
check_output2([self.pass_cmd, 'insert', '-f', '-m', self.passname], input=msg, env=self.env)
|
||||
except (subprocess.CalledProcessError) as e:
|
||||
raise AnsibleError(e)
|
||||
return newpass
|
||||
@@ -380,6 +420,8 @@ class LookupModule(LookupBase):
|
||||
yield
|
||||
|
||||
def setup(self, variables):
|
||||
self.backend = self.get_option('backend')
|
||||
self.pass_cmd = self.backend # pass and gopass are commands as well
|
||||
self.locked = None
|
||||
timeout = self.get_option('locktimeout')
|
||||
if not re.match('^[0-9]+[smh]$', timeout):
|
||||
@@ -402,6 +444,7 @@ class LookupModule(LookupBase):
|
||||
}
|
||||
|
||||
def run(self, terms, variables, **kwargs):
|
||||
self.set_options(var_options=variables, direct=kwargs)
|
||||
self.setup(variables)
|
||||
result = []
|
||||
|
||||
|
||||
@@ -3,51 +3,7 @@
|
||||
# This particular file snippet, and this file snippet only, is based on
|
||||
# Lib/posixpath.py of cpython
|
||||
# It is licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
|
||||
#
|
||||
# 1. This LICENSE AGREEMENT is between the Python Software Foundation
|
||||
# ("PSF"), and the Individual or Organization ("Licensee") accessing and
|
||||
# otherwise using this software ("Python") in source or binary form and
|
||||
# its associated documentation.
|
||||
#
|
||||
# 2. Subject to the terms and conditions of this License Agreement, PSF hereby
|
||||
# grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
|
||||
# analyze, test, perform and/or display publicly, prepare derivative works,
|
||||
# distribute, and otherwise use Python alone or in any derivative version,
|
||||
# provided, however, that PSF's License Agreement and PSF's notice of copyright,
|
||||
# i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
# 2011, 2012, 2013, 2014, 2015 Python Software Foundation; All Rights Reserved"
|
||||
# are retained in Python alone or in any derivative version prepared by Licensee.
|
||||
#
|
||||
# 3. In the event Licensee prepares a derivative work that is based on
|
||||
# or incorporates Python or any part thereof, and wants to make
|
||||
# the derivative work available to others as provided herein, then
|
||||
# Licensee hereby agrees to include in any such work a brief summary of
|
||||
# the changes made to Python.
|
||||
#
|
||||
# 4. PSF is making Python available to Licensee on an "AS IS"
|
||||
# basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
||||
# IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
|
||||
# DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||
# FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
|
||||
# INFRINGE ANY THIRD PARTY RIGHTS.
|
||||
#
|
||||
# 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
||||
# FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
||||
# A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
|
||||
# OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
||||
#
|
||||
# 6. This License Agreement will automatically terminate upon a material
|
||||
# breach of its terms and conditions.
|
||||
#
|
||||
# 7. Nothing in this License Agreement shall be deemed to create any
|
||||
# relationship of agency, partnership, or joint venture between PSF and
|
||||
# Licensee. This License Agreement does not grant permission to use PSF
|
||||
# trademarks or trade name in a trademark sense to endorse or promote
|
||||
# products or services of Licensee, or any third party.
|
||||
#
|
||||
# 8. By copying, installing or otherwise using Python, Licensee
|
||||
# agrees to be bound by the terms and conditions of this License
|
||||
# Agreement.
|
||||
# (See PSF-license.txt in this collection)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
|
||||
@@ -191,13 +191,13 @@ class CmdRunner(object):
|
||||
environ_update = {}
|
||||
self.environ_update = environ_update
|
||||
|
||||
self.command[0] = module.get_bin_path(command[0], opt_dirs=path_prefix, required=True)
|
||||
self.command[0] = module.get_bin_path(self.command[0], opt_dirs=path_prefix, required=True)
|
||||
|
||||
for mod_param_name, spec in iteritems(module.argument_spec):
|
||||
if mod_param_name not in self.arg_formats:
|
||||
self.arg_formats[mod_param_name] = _Format.as_default_type(spec['type'], mod_param_name)
|
||||
|
||||
def context(self, args_order=None, output_process=None, ignore_value_none=True, **kwargs):
|
||||
def __call__(self, args_order=None, output_process=None, ignore_value_none=True, check_mode_skip=False, check_mode_return=None, **kwargs):
|
||||
if output_process is None:
|
||||
output_process = _process_as_is
|
||||
if args_order is None:
|
||||
@@ -209,18 +209,25 @@ class CmdRunner(object):
|
||||
return _CmdRunnerContext(runner=self,
|
||||
args_order=args_order,
|
||||
output_process=output_process,
|
||||
ignore_value_none=ignore_value_none, **kwargs)
|
||||
ignore_value_none=ignore_value_none,
|
||||
check_mode_skip=check_mode_skip,
|
||||
check_mode_return=check_mode_return, **kwargs)
|
||||
|
||||
def has_arg_format(self, arg):
|
||||
return arg in self.arg_formats
|
||||
|
||||
# not decided whether to keep it or not, but if deprecating it will happen in a farther future.
|
||||
context = __call__
|
||||
|
||||
|
||||
class _CmdRunnerContext(object):
|
||||
def __init__(self, runner, args_order, output_process, ignore_value_none, **kwargs):
|
||||
def __init__(self, runner, args_order, output_process, ignore_value_none, check_mode_skip, check_mode_return, **kwargs):
|
||||
self.runner = runner
|
||||
self.args_order = tuple(args_order)
|
||||
self.output_process = output_process
|
||||
self.ignore_value_none = ignore_value_none
|
||||
self.check_mode_skip = check_mode_skip
|
||||
self.check_mode_return = check_mode_return
|
||||
self.run_command_args = dict(kwargs)
|
||||
|
||||
self.environ_update = runner.environ_update
|
||||
@@ -260,6 +267,8 @@ class _CmdRunnerContext(object):
|
||||
except Exception as e:
|
||||
raise FormatError(arg_name, value, runner.arg_formats[arg_name], e)
|
||||
|
||||
if self.check_mode_skip and module.check_mode:
|
||||
return self.check_mode_return
|
||||
results = module.run_command(self.cmd, **self.run_command_args)
|
||||
self.results_rc, self.results_out, self.results_err = results
|
||||
self.results_processed = self.output_process(*results)
|
||||
@@ -288,4 +297,12 @@ class _CmdRunnerContext(object):
|
||||
return False
|
||||
|
||||
|
||||
fmt = _Format()
|
||||
cmd_runner_fmt = _Format()
|
||||
|
||||
#
|
||||
# The fmt form is deprecated and will be removed in community.general 7.0.0
|
||||
# Please use:
|
||||
# cmd_runner_fmt
|
||||
# Or, to retain the same effect, use:
|
||||
# from ansible_collections.community.general.plugins.module_utils.cmd_runner import cmd_runner_fmt as fmt
|
||||
fmt = cmd_runner_fmt
|
||||
|
||||
26
plugins/module_utils/gconftool2.py
Normal file
26
plugins/module_utils/gconftool2.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# (c) 2022, Alexei Znamensky <russoz@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt as fmt
|
||||
|
||||
|
||||
def gconftool2_runner(module, **kwargs):
|
||||
return CmdRunner(
|
||||
module,
|
||||
command='gconftool-2',
|
||||
arg_formats=dict(
|
||||
key=fmt.as_list(),
|
||||
value_type=fmt.as_opt_val("--type"),
|
||||
value=fmt.as_list(),
|
||||
direct=fmt.as_bool("--direct"),
|
||||
config_source=fmt.as_opt_val("--config-source"),
|
||||
get=fmt.as_bool("--get"),
|
||||
set_arg=fmt.as_bool("--set"),
|
||||
unset=fmt.as_bool("--unset"),
|
||||
),
|
||||
**kwargs
|
||||
)
|
||||
@@ -351,7 +351,7 @@ def wait_to_finish(target, pending, refresh, timeout, min_interval=1, delay=3):
|
||||
|
||||
if pending and status not in pending:
|
||||
raise HwcModuleException(
|
||||
"unexpect status(%s) occured" % status)
|
||||
"unexpect status(%s) occurred" % status)
|
||||
|
||||
if not is_last_time:
|
||||
wait *= 2
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2021-2022 Hewlett Packard Enterprise, Inc. All rights reserved.
|
||||
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
@@ -6,17 +6,13 @@
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
|
||||
|
||||
class ModuleHelperException(Exception):
|
||||
@staticmethod
|
||||
def _get_remove(key, kwargs):
|
||||
if key in kwargs:
|
||||
result = kwargs[key]
|
||||
del kwargs[key]
|
||||
return result
|
||||
return None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.msg = self._get_remove('msg', kwargs) or "Module failed with exception: {0}".format(self)
|
||||
self.update_output = self._get_remove('update_output', kwargs) or {}
|
||||
def __init__(self, msg, update_output=None, *args, **kwargs):
|
||||
self.msg = to_native(msg or "Module failed with exception: {0}".format(self))
|
||||
if update_output is None:
|
||||
update_output = {}
|
||||
self.update_output = update_output
|
||||
super(ModuleHelperException, self).__init__(*args)
|
||||
|
||||
@@ -83,12 +83,12 @@ class OpenNebulaModule:
|
||||
if self.module.params.get("api_username"):
|
||||
username = self.module.params.get("api_username")
|
||||
else:
|
||||
self.fail("Either api_username or the environment vairable ONE_USERNAME must be provided")
|
||||
self.fail("Either api_username or the environment variable ONE_USERNAME must be provided")
|
||||
|
||||
if self.module.params.get("api_password"):
|
||||
password = self.module.params.get("api_password")
|
||||
else:
|
||||
self.fail("Either api_password or the environment vairable ONE_PASSWORD must be provided")
|
||||
self.fail("Either api_password or the environment variable ONE_PASSWORD must be provided")
|
||||
|
||||
session = "%s:%s" % (username, password)
|
||||
|
||||
|
||||
@@ -691,7 +691,7 @@ def check_and_create_resource(
|
||||
:param model: Model used to create a resource.
|
||||
:param exclude_attributes: The attributes which should not be used to distinguish the resource. e.g. display_name,
|
||||
dns_label.
|
||||
:param dead_states: List of states which can't transition to any of the usable states of the resource. This deafults
|
||||
:param dead_states: List of states which can't transition to any of the usable states of the resource. This defaults
|
||||
to ["TERMINATING", "TERMINATED", "FAULTY", "FAILED", "DELETING", "DELETED", "UNKNOWN_ENUM_VALUE"]
|
||||
:param default_attribute_values: A dictionary containing default values for attributes.
|
||||
:return: A dictionary containing the resource & the "changed" status. e.g. {"vcn":{x:y}, "changed":True}
|
||||
@@ -1189,7 +1189,7 @@ def are_dicts_equal(
|
||||
|
||||
|
||||
def should_dict_attr_be_excluded(map_option_name, option_key, exclude_list):
|
||||
"""An entry for the Exclude list for excluding a map's key is specifed as a dict with the map option name as the
|
||||
"""An entry for the Exclude list for excluding a map's key is specified as a dict with the map option name as the
|
||||
key, and the value as a list of keys to be excluded within that map. For example, if the keys "k1" and "k2" of a map
|
||||
option named "m1" needs to be excluded, the exclude list must have an entry {'m1': ['k1','k2']} """
|
||||
for exclude_item in exclude_list:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2017-2018 Dell EMC Inc.
|
||||
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
@@ -1888,14 +1888,13 @@ class RedfishUtils(object):
|
||||
for property in properties:
|
||||
if property in data:
|
||||
chassis_power_result[property] = data[property]
|
||||
else:
|
||||
return {'ret': False, 'msg': 'Key PowerControl not found.'}
|
||||
chassis_power_results.append(chassis_power_result)
|
||||
else:
|
||||
return {'ret': False, 'msg': 'Key Power not found.'}
|
||||
|
||||
result['entries'] = chassis_power_results
|
||||
return result
|
||||
if len(chassis_power_results) > 0:
|
||||
result['entries'] = chassis_power_results
|
||||
return result
|
||||
else:
|
||||
return {'ret': False, 'msg': 'Power information not found.'}
|
||||
|
||||
def get_chassis_thermals(self):
|
||||
result = {}
|
||||
@@ -2187,9 +2186,8 @@ class RedfishUtils(object):
|
||||
else:
|
||||
if media_match_strict:
|
||||
continue
|
||||
# if ejected, 'Inserted' should be False and 'ImageName' cleared
|
||||
if (not data.get('Inserted', False) and
|
||||
not data.get('ImageName')):
|
||||
# if ejected, 'Inserted' should be False
|
||||
if (not data.get('Inserted', False)):
|
||||
return uri, data
|
||||
return None, None
|
||||
|
||||
@@ -2225,7 +2223,7 @@ class RedfishUtils(object):
|
||||
return resources, headers
|
||||
|
||||
@staticmethod
|
||||
def _insert_virt_media_payload(options, param_map, data, ai):
|
||||
def _insert_virt_media_payload(options, param_map, data, ai, image_only=False):
|
||||
payload = {
|
||||
'Image': options.get('image_url')
|
||||
}
|
||||
@@ -2239,6 +2237,12 @@ class RedfishUtils(object):
|
||||
options.get(option), option,
|
||||
allowable)}
|
||||
payload[param] = options.get(option)
|
||||
|
||||
# Some hardware (such as iLO 4 or Supermicro) only supports the Image property
|
||||
# Inserted and WriteProtected are not writable
|
||||
if image_only:
|
||||
del payload['Inserted']
|
||||
del payload['WriteProtected']
|
||||
return payload
|
||||
|
||||
def virtual_media_insert_via_patch(self, options, param_map, uri, data, image_only=False):
|
||||
@@ -2247,16 +2251,10 @@ class RedfishUtils(object):
|
||||
{'AllowableValues': v}) for k, v in data.items()
|
||||
if k.endswith('@Redfish.AllowableValues'))
|
||||
# construct payload
|
||||
payload = self._insert_virt_media_payload(options, param_map, data, ai)
|
||||
if 'Inserted' not in payload:
|
||||
payload = self._insert_virt_media_payload(options, param_map, data, ai, image_only)
|
||||
if 'Inserted' not in payload and not image_only:
|
||||
payload['Inserted'] = True
|
||||
|
||||
# Some hardware (such as iLO 4) only supports the Image property on the PATCH operation
|
||||
# Inserted and WriteProtected are not writable
|
||||
if image_only:
|
||||
del payload['Inserted']
|
||||
del payload['WriteProtected']
|
||||
|
||||
# PATCH the resource
|
||||
response = self.patch_request(self.root_uri + uri, payload)
|
||||
if response['ret'] is False:
|
||||
@@ -2292,6 +2290,13 @@ class RedfishUtils(object):
|
||||
if data["FirmwareVersion"].startswith("iLO 4"):
|
||||
image_only = True
|
||||
|
||||
# Supermicro does also not support Inserted and WriteProtected
|
||||
# Supermicro uses as firmware version only a number so we can't check for it because we
|
||||
# can't be sure that this firmware version is nut used by another vendor
|
||||
# Tested with Supermicro Firmware 01.74.02
|
||||
if 'Supermicro' in data['Oem']:
|
||||
image_only = True
|
||||
|
||||
virt_media_uri = data["VirtualMedia"]["@odata.id"]
|
||||
response = self.get_request(self.root_uri + virt_media_uri)
|
||||
if response['ret'] is False:
|
||||
@@ -2346,7 +2351,7 @@ class RedfishUtils(object):
|
||||
# get ActionInfo or AllowableValues
|
||||
ai = self._get_all_action_info_values(action)
|
||||
# construct payload
|
||||
payload = self._insert_virt_media_payload(options, param_map, data, ai)
|
||||
payload = self._insert_virt_media_payload(options, param_map, data, ai, image_only)
|
||||
# POST to action
|
||||
response = self.post_request(self.root_uri + action_uri, payload)
|
||||
if response['ret'] is False:
|
||||
@@ -2392,6 +2397,9 @@ class RedfishUtils(object):
|
||||
if data["FirmwareVersion"].startswith("iLO 4"):
|
||||
image_only = True
|
||||
|
||||
if 'Supermicro' in data['Oem']:
|
||||
image_only = True
|
||||
|
||||
virt_media_uri = data["VirtualMedia"]["@odata.id"]
|
||||
response = self.get_request(self.root_uri + virt_media_uri)
|
||||
if response['ret'] is False:
|
||||
@@ -3020,3 +3028,26 @@ class RedfishUtils(object):
|
||||
if not result["entries"]:
|
||||
return {'ret': False, 'msg': "No HostInterface objects found"}
|
||||
return result
|
||||
|
||||
def get_manager_inventory(self, manager_uri):
|
||||
result = {}
|
||||
inventory = {}
|
||||
# Get these entries, but does not fail if not found
|
||||
properties = ['FirmwareVersion', 'ManagerType', 'Manufacturer', 'Model',
|
||||
'PartNumber', 'PowerState', 'SerialNumber', 'Status', 'UUID']
|
||||
|
||||
response = self.get_request(self.root_uri + manager_uri)
|
||||
if response['ret'] is False:
|
||||
return response
|
||||
result['ret'] = True
|
||||
data = response['data']
|
||||
|
||||
for property in properties:
|
||||
if property in data:
|
||||
inventory[property] = data[property]
|
||||
|
||||
result["entries"] = inventory
|
||||
return result
|
||||
|
||||
def get_multi_manager_inventory(self):
|
||||
return self.aggregate_managers(self.get_manager_inventory)
|
||||
|
||||
37
plugins/module_utils/xfconf.py
Normal file
37
plugins/module_utils/xfconf.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# (c) 2022, Alexei Znamensky <russoz@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.module_utils.parsing.convert_bool import boolean
|
||||
from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt as fmt
|
||||
|
||||
|
||||
@fmt.unpack_args
|
||||
def _values_fmt(values, value_types):
|
||||
result = []
|
||||
for value, value_type in zip(values, value_types):
|
||||
if value_type == 'bool':
|
||||
value = boolean(value)
|
||||
result.extend(['--type', '{0}'.format(value_type), '--set', '{0}'.format(value)])
|
||||
return result
|
||||
|
||||
|
||||
def xfconf_runner(module, **kwargs):
|
||||
runner = CmdRunner(
|
||||
module,
|
||||
command='xfconf-query',
|
||||
arg_formats=dict(
|
||||
channel=fmt.as_opt_val("--channel"),
|
||||
property=fmt.as_opt_val("--property"),
|
||||
force_array=fmt.as_bool("--force-array"),
|
||||
reset=fmt.as_bool("--reset"),
|
||||
create=fmt.as_bool("--create"),
|
||||
list_arg=fmt.as_bool("--list"),
|
||||
values_and_types=fmt.as_func(_values_fmt),
|
||||
),
|
||||
**kwargs
|
||||
)
|
||||
return runner
|
||||
@@ -191,10 +191,10 @@ notes:
|
||||
2.1, the later requires python to be installed in the instance which can
|
||||
be done with the command module.
|
||||
- You can copy a file from the host to the instance
|
||||
with the Ansible M(ansible.builtin.copy) and M(ansible.builtin.template) module and the `lxd` connection plugin.
|
||||
with the Ansible M(ansible.builtin.copy) and M(ansible.builtin.template) module and the C(community.general.lxd) connection plugin.
|
||||
See the example below.
|
||||
- You can copy a file in the created instance to the localhost
|
||||
with `command=lxc file pull instance_name/dir/filename filename`.
|
||||
with C(command=lxc file pull instance_name/dir/filename filename).
|
||||
See the first example below.
|
||||
'''
|
||||
|
||||
|
||||
@@ -360,7 +360,7 @@ class LXDProfileManagement(object):
|
||||
)
|
||||
|
||||
def _merge_dicts(self, source, destination):
|
||||
"""Merge Dictionarys
|
||||
"""Merge Dictionaries
|
||||
|
||||
Get a list of filehandle numbers from logger to be handed to
|
||||
DaemonContext.files_preserve
|
||||
|
||||
@@ -303,7 +303,7 @@ class LXDProjectManagement(object):
|
||||
)
|
||||
|
||||
def _merge_dicts(self, source, destination):
|
||||
""" Return a new dict taht merge two dict,
|
||||
""" Return a new dict that merge two dict,
|
||||
with values in source dict overwrite destination dict
|
||||
|
||||
Args:
|
||||
|
||||
@@ -83,7 +83,7 @@ options:
|
||||
version_added: 1.3.0
|
||||
clone:
|
||||
description:
|
||||
- Name of VM to be cloned. If C(vmid) is setted, C(clone) can take arbitrary value but required for initiating the clone.
|
||||
- Name of VM to be cloned. If I(vmid) is set, I(clone) can take an arbitrary value but is required for initiating the clone.
|
||||
type: str
|
||||
cores:
|
||||
description:
|
||||
@@ -1204,12 +1204,12 @@ def main():
|
||||
# Ensure source VM id exists when cloning
|
||||
proxmox.get_vm(vmid)
|
||||
|
||||
# Ensure the choosen VM name doesn't already exist when cloning
|
||||
# Ensure the chosen VM name doesn't already exist when cloning
|
||||
existing_vmid = proxmox.get_vmid(name, ignore_missing=True)
|
||||
if existing_vmid:
|
||||
module.exit_json(changed=False, vmid=existing_vmid, msg="VM with name <%s> already exists" % name)
|
||||
|
||||
# Ensure the choosen VM id doesn't already exist when cloning
|
||||
# Ensure the chosen VM id doesn't already exist when cloning
|
||||
if proxmox.get_vm(newid, ignore_missing=True):
|
||||
module.exit_json(changed=False, vmid=vmid, msg="vmid %s with VM name %s already exists" % (newid, name))
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ state:
|
||||
returned: always
|
||||
command:
|
||||
type: str
|
||||
description: Full `serverless` command run by this module, in case you want to re-run the command outside the module.
|
||||
description: Full C(serverless) command run by this module, in case you want to re-run the command outside the module.
|
||||
returned: always
|
||||
sample: serverless deploy --stage production
|
||||
'''
|
||||
|
||||
@@ -67,7 +67,7 @@ options:
|
||||
state_file:
|
||||
description:
|
||||
- The path to an existing Terraform state file to use when building plan.
|
||||
If this is not specified, the default `terraform.tfstate` will be used.
|
||||
If this is not specified, the default C(terraform.tfstate) will be used.
|
||||
- This option is ignored when plan is specified.
|
||||
type: path
|
||||
variables_files:
|
||||
@@ -103,7 +103,7 @@ options:
|
||||
force_init:
|
||||
description:
|
||||
- To avoid duplicating infra, if a state file can't be found this will
|
||||
force a `terraform init`. Generally, this should be turned off unless
|
||||
force a C(terraform init). Generally, this should be turned off unless
|
||||
you intend to provision an entirely new Terraform deployment.
|
||||
default: false
|
||||
type: bool
|
||||
@@ -149,7 +149,7 @@ options:
|
||||
type: int
|
||||
version_added: '3.8.0'
|
||||
notes:
|
||||
- To just run a `terraform plan`, use check mode.
|
||||
- To just run a C(terraform plan), use check mode.
|
||||
requirements: [ "terraform" ]
|
||||
author: "Ryan Scott Brown (@ryansb)"
|
||||
'''
|
||||
@@ -205,7 +205,7 @@ EXAMPLES = """
|
||||
RETURN = """
|
||||
outputs:
|
||||
type: complex
|
||||
description: A dictionary of all the TF outputs by their assigned name. Use `.outputs.MyOutputName.value` to access the value.
|
||||
description: A dictionary of all the TF outputs by their assigned name. Use C(.outputs.MyOutputName.value) to access the value.
|
||||
returned: on success
|
||||
sample: '{"bukkit_arn": {"sensitive": false, "type": "string", "value": "arn:aws:s3:::tf-test-bukkit"}'
|
||||
contains:
|
||||
@@ -223,12 +223,12 @@ outputs:
|
||||
description: The value of the output as interpolated by Terraform
|
||||
stdout:
|
||||
type: str
|
||||
description: Full `terraform` command stdout, in case you want to display it or examine the event log
|
||||
description: Full C(terraform) command stdout, in case you want to display it or examine the event log
|
||||
returned: always
|
||||
sample: ''
|
||||
command:
|
||||
type: str
|
||||
description: Full `terraform` command built by this module, in case you want to re-run the command outside the module or debug a problem.
|
||||
description: Full C(terraform) command built by this module, in case you want to re-run the command outside the module or debug a problem.
|
||||
returned: always
|
||||
sample: terraform apply ...
|
||||
"""
|
||||
|
||||
@@ -252,7 +252,8 @@ def main():
|
||||
'weight': weight,
|
||||
}
|
||||
|
||||
for name, value in mutable.items():
|
||||
for name in list(mutable):
|
||||
value = mutable[name]
|
||||
if value is None or value == getattr(node, name):
|
||||
mutable.pop(name)
|
||||
|
||||
|
||||
@@ -75,15 +75,15 @@ options:
|
||||
target_hostname:
|
||||
type: str
|
||||
description:
|
||||
- One of `target_hostname` and `target_alias` is required for remote.* checks,
|
||||
- One of I(target_hostname) and I(target_alias) is required for remote.* checks,
|
||||
but prohibited for agent.* checks. The hostname this check should target.
|
||||
Must be a valid IPv4, IPv6, or FQDN.
|
||||
target_alias:
|
||||
type: str
|
||||
description:
|
||||
- One of `target_alias` and `target_hostname` is required for remote.* checks,
|
||||
- One of I(target_alias) and I(target_hostname) is required for remote.* checks,
|
||||
but prohibited for agent.* checks. Use the corresponding key in the entity's
|
||||
`ip_addresses` hash to resolve an IP address to target.
|
||||
I(ip_addresses) hash to resolve an IP address to target.
|
||||
details:
|
||||
type: dict
|
||||
description:
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Scaleway VPC management module
|
||||
#
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: scaleway_compute_private_network
|
||||
short_description: Scaleway compute - private network management
|
||||
version_added: 5.2.0
|
||||
author: Pascal MANGIN (@pastral)
|
||||
description:
|
||||
- This module add or remove a private network to a compute instance
|
||||
(U(https://developer.scaleway.com)).
|
||||
extends_documentation_fragment:
|
||||
- community.general.scaleway
|
||||
|
||||
|
||||
options:
|
||||
state:
|
||||
type: str
|
||||
description:
|
||||
- Indicate desired state of the VPC.
|
||||
default: present
|
||||
choices:
|
||||
- present
|
||||
- absent
|
||||
|
||||
project:
|
||||
type: str
|
||||
description:
|
||||
- Project identifier.
|
||||
required: true
|
||||
|
||||
region:
|
||||
type: str
|
||||
description:
|
||||
- Scaleway region to use (for example C(par1)).
|
||||
required: true
|
||||
choices:
|
||||
- ams1
|
||||
- EMEA-NL-EVS
|
||||
- par1
|
||||
- EMEA-FR-PAR1
|
||||
- par2
|
||||
- EMEA-FR-PAR2
|
||||
- waw1
|
||||
- EMEA-PL-WAW1
|
||||
|
||||
compute_id:
|
||||
type: str
|
||||
description:
|
||||
- ID of the compute instance (see M(community.general.scaleway_compute)).
|
||||
required: true
|
||||
|
||||
private_network_id:
|
||||
type: str
|
||||
description:
|
||||
- ID of the private network (see M(community.general.scaleway_private_network)).
|
||||
required: true
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
- name: Plug a VM to a private network
|
||||
community.general.scaleway_compute_private_network:
|
||||
project: '{{ scw_project }}'
|
||||
state: present
|
||||
region: par1
|
||||
compute_id: "12345678-f1e6-40ec-83e5-12345d67ed89"
|
||||
private_network_id: "22345678-f1e6-40ec-83e5-12345d67ed89"
|
||||
register: nicsvpc_creation_task
|
||||
|
||||
- name: Unplug a VM from a private network
|
||||
community.general.scaleway_compute_private_network:
|
||||
project: '{{ scw_project }}'
|
||||
state: absent
|
||||
region: par1
|
||||
compute_id: "12345678-f1e6-40ec-83e5-12345d67ed89"
|
||||
private_network_id: "22345678-f1e6-40ec-83e5-12345d67ed89"
|
||||
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
scaleway_compute_private_network:
|
||||
description: Information on the VPC.
|
||||
returned: success when C(state=present)
|
||||
type: dict
|
||||
sample:
|
||||
{
|
||||
"created_at": "2022-01-15T11:11:12.676445Z",
|
||||
"id": "12345678-f1e6-40ec-83e5-12345d67ed89",
|
||||
"name": "network",
|
||||
"organization_id": "a123b4cd-ef5g-678h-90i1-jk2345678l90",
|
||||
"project_id": "a123b4cd-ef5g-678h-90i1-jk2345678l90",
|
||||
"tags": [
|
||||
"tag1",
|
||||
"tag2",
|
||||
"tag3",
|
||||
"tag4",
|
||||
"tag5"
|
||||
],
|
||||
"updated_at": "2022-01-15T11:12:04.624837Z",
|
||||
"zone": "fr-par-2"
|
||||
}
|
||||
'''
|
||||
from ansible_collections.community.general.plugins.module_utils.scaleway import SCALEWAY_LOCATION, scaleway_argument_spec, Scaleway
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
def get_nics_info(api, compute_id, private_network_id):
|
||||
|
||||
response = api.get('servers/' + compute_id + '/private_nics')
|
||||
if not response.ok:
|
||||
msg = "Error during get servers information: %s: '%s' (%s)" % (response.info['msg'], response.json['message'], response.json)
|
||||
api.module.fail_json(msg=msg)
|
||||
|
||||
i = 0
|
||||
list_nics = response.json['private_nics']
|
||||
|
||||
while i < len(list_nics):
|
||||
if list_nics[i]['private_network_id'] == private_network_id:
|
||||
return list_nics[i]
|
||||
i += 1
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def present_strategy(api, compute_id, private_network_id):
|
||||
|
||||
changed = False
|
||||
nic = get_nics_info(api, compute_id, private_network_id)
|
||||
if nic is not None:
|
||||
return changed, nic
|
||||
|
||||
data = {"private_network_id": private_network_id}
|
||||
changed = True
|
||||
if api.module.check_mode:
|
||||
return changed, {"status": "a private network would be add to a server"}
|
||||
|
||||
response = api.post(path='servers/' + compute_id + '/private_nics', data=data)
|
||||
|
||||
if not response.ok:
|
||||
api.module.fail_json(msg='Error when adding a private network to a server [{0}: {1}]'.format(response.status_code, response.json))
|
||||
|
||||
return changed, response.json
|
||||
|
||||
|
||||
def absent_strategy(api, compute_id, private_network_id):
|
||||
|
||||
changed = False
|
||||
nic = get_nics_info(api, compute_id, private_network_id)
|
||||
if nic is None:
|
||||
return changed, {}
|
||||
|
||||
changed = True
|
||||
if api.module.check_mode:
|
||||
return changed, {"status": "private network would be destroyed"}
|
||||
|
||||
response = api.delete('servers/' + compute_id + '/private_nics/' + nic['id'])
|
||||
|
||||
if not response.ok:
|
||||
api.module.fail_json(msg='Error deleting private network from server [{0}: {1}]'.format(
|
||||
response.status_code, response.json))
|
||||
|
||||
return changed, response.json
|
||||
|
||||
|
||||
def core(module):
|
||||
|
||||
compute_id = module.params['compute_id']
|
||||
pn_id = module.params['private_network_id']
|
||||
|
||||
region = module.params["region"]
|
||||
module.params['api_url'] = SCALEWAY_LOCATION[region]["api_endpoint"]
|
||||
|
||||
api = Scaleway(module=module)
|
||||
if module.params["state"] == "absent":
|
||||
changed, summary = absent_strategy(api=api, compute_id=compute_id, private_network_id=pn_id)
|
||||
else:
|
||||
changed, summary = present_strategy(api=api, compute_id=compute_id, private_network_id=pn_id)
|
||||
module.exit_json(changed=changed, scaleway_compute_private_network=summary)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = scaleway_argument_spec()
|
||||
argument_spec.update(dict(
|
||||
state=dict(default='present', choices=['absent', 'present']),
|
||||
project=dict(required=True),
|
||||
region=dict(required=True, choices=list(SCALEWAY_LOCATION.keys())),
|
||||
compute_id=dict(required=True),
|
||||
private_network_id=dict(required=True)
|
||||
))
|
||||
module = AnsibleModule(
|
||||
argument_spec=argument_spec,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
core(module)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -35,7 +35,7 @@ options:
|
||||
user_data:
|
||||
type: dict
|
||||
description:
|
||||
- User defined data. Typically used with `cloud-init`.
|
||||
- User defined data. Typically used with C(cloud-init).
|
||||
- Pass your cloud-init script here as a string
|
||||
required: false
|
||||
|
||||
|
||||
@@ -1207,7 +1207,7 @@ class XenServerVM(XenServerObject):
|
||||
if (self.module.params['home_server'] and
|
||||
(not self.vm_params['affinity'] or self.module.params['home_server'] != self.vm_params['affinity']['name_label'])):
|
||||
|
||||
# Check existance only. Ignore return value.
|
||||
# Check existence only. Ignore return value.
|
||||
get_object_ref(self.module, self.module.params['home_server'], uuid=None, obj_type="home server", fail=True,
|
||||
msg_prefix="VM check home_server: ")
|
||||
|
||||
@@ -1371,7 +1371,7 @@ class XenServerVM(XenServerObject):
|
||||
disk_sr = disk_params.get('sr')
|
||||
|
||||
if disk_sr_uuid is not None or disk_sr is not None:
|
||||
# Check existance only. Ignore return value.
|
||||
# Check existence only. Ignore return value.
|
||||
get_object_ref(self.module, disk_sr, disk_sr_uuid, obj_type="SR", fail=True,
|
||||
msg_prefix="VM check disks[%s]: " % position)
|
||||
elif self.default_sr_ref == 'OpaqueRef:NULL':
|
||||
@@ -1448,7 +1448,7 @@ class XenServerVM(XenServerObject):
|
||||
|
||||
if cdrom_type == "iso":
|
||||
# Check if ISO exists.
|
||||
# Check existance only. Ignore return value.
|
||||
# Check existence only. Ignore return value.
|
||||
get_object_ref(self.module, cdrom_iso_name, uuid=None, obj_type="ISO image", fail=True,
|
||||
msg_prefix="VM check cdrom.iso_name: ")
|
||||
|
||||
@@ -1496,7 +1496,7 @@ class XenServerVM(XenServerObject):
|
||||
self.module.fail_json(msg="VM check networks[%s]: network name cannot be an empty string!" % position)
|
||||
|
||||
if network_name:
|
||||
# Check existance only. Ignore return value.
|
||||
# Check existence only. Ignore return value.
|
||||
get_object_ref(self.module, network_name, uuid=None, obj_type="network", fail=True,
|
||||
msg_prefix="VM check networks[%s]: " % position)
|
||||
|
||||
|
||||
@@ -28,14 +28,14 @@ author:
|
||||
options:
|
||||
state:
|
||||
description:
|
||||
- The action to take with the supplied key and value. If the state is 'present' and `value` is set, the key
|
||||
contents will be set to the value supplied and `changed` will be set to `true` only if the value was
|
||||
different to the current contents. If the state is 'present' and `value` is not set, the existing value
|
||||
associated to the key will be returned. The state 'absent' will remove the key/value pair,
|
||||
again 'changed' will be set to true only if the key actually existed
|
||||
- The action to take with the supplied key and value. If the state is C(present) and I(value) is set, the key
|
||||
contents will be set to the value supplied and C(changed) will be set to C(true) only if the value was
|
||||
different to the current contents. If the state is C(present) and I(value) is not set, the existing value
|
||||
associated to the key will be returned. The state C(absent) will remove the key/value pair,
|
||||
again C(changed) will be set to true only if the key actually existed
|
||||
prior to the removal. An attempt can be made to obtain or free the
|
||||
lock associated with a key/value pair with the states 'acquire' or
|
||||
'release' respectively. a valid session must be supplied to make the
|
||||
lock associated with a key/value pair with the states C(acquire) or
|
||||
C(release) respectively. a valid session must be supplied to make the
|
||||
attempt changed will be true if the attempt is successful, false
|
||||
otherwise.
|
||||
type: str
|
||||
|
||||
@@ -279,7 +279,7 @@ def do_ini(module, filename, section=None, option=None, values=None,
|
||||
# handling multiple instances of option=value when state is 'present' with/without exclusive is a bit complex
|
||||
#
|
||||
# 1. edit all lines where we have a option=value pair with a matching value in values[]
|
||||
# 2. edit all the remaing lines where we have a matching option
|
||||
# 2. edit all the remaining lines where we have a matching option
|
||||
# 3. delete remaining lines where we have a matching option
|
||||
# 4. insert missing option line(s) at the end of the section
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ def main():
|
||||
changed = True
|
||||
else:
|
||||
changed = False
|
||||
out = "allready unpacked"
|
||||
out = "already unpacked"
|
||||
|
||||
if remove:
|
||||
os.remove(path)
|
||||
|
||||
@@ -45,7 +45,7 @@ EXAMPLES = r'''
|
||||
ipa_user: admin
|
||||
ipa_pass: supersecret
|
||||
|
||||
- name: Ensure the TOTP syncronization window is set to 86400 seconds
|
||||
- name: Ensure the TOTP synchronization window is set to 86400 seconds
|
||||
community.general.ipa_otpconfig:
|
||||
ipatokentotpsyncwindow: '86400'
|
||||
ipa_host: localhost
|
||||
@@ -59,7 +59,7 @@ EXAMPLES = r'''
|
||||
ipa_user: admin
|
||||
ipa_pass: supersecret
|
||||
|
||||
- name: Ensure the HOTP syncronization window is set to 100 hops
|
||||
- name: Ensure the HOTP synchronization window is set to 100 hops
|
||||
community.general.ipa_otpconfig:
|
||||
ipatokenhotpsyncwindow: '100'
|
||||
ipa_host: localhost
|
||||
|
||||
@@ -63,7 +63,7 @@ options:
|
||||
type: str
|
||||
replace:
|
||||
description:
|
||||
- Force replace the existant vault on IPA server.
|
||||
- Force replace the existent vault on IPA server.
|
||||
type: bool
|
||||
default: False
|
||||
choices: ["True", "False"]
|
||||
|
||||
@@ -64,7 +64,7 @@ msg:
|
||||
|
||||
realm_info:
|
||||
description:
|
||||
- Representation of the realm public infomation.
|
||||
- Representation of the realm public information.
|
||||
returned: always
|
||||
type: dict
|
||||
contains:
|
||||
|
||||
@@ -20,7 +20,7 @@ description:
|
||||
- "Allows to post events to Datadog (www.datadoghq.com) service."
|
||||
- "Uses http://docs.datadoghq.com/api/#events API."
|
||||
author:
|
||||
- "Artūras `arturaz` Šlajus (@arturaz)"
|
||||
- "Artūras 'arturaz' Šlajus (@arturaz)"
|
||||
- "Naoya Nakazawa (@n0ts)"
|
||||
options:
|
||||
api_key:
|
||||
|
||||
@@ -99,7 +99,7 @@ options:
|
||||
weight:
|
||||
description:
|
||||
- The value passed in argument.
|
||||
- If the value ends with the `%` sign, then the new weight will be
|
||||
- If the value ends with the C(%) sign, then the new weight will be
|
||||
relative to the initially configured weight.
|
||||
- Relative weights are only permitted between 0 and 100% and absolute
|
||||
weights are permitted between 0 and 256.
|
||||
|
||||
@@ -45,8 +45,8 @@ options:
|
||||
- The interface to bind the connection to.
|
||||
- The connection will only be applicable to this interface name.
|
||||
- A special value of C('*') can be used for interface-independent connections.
|
||||
- The ifname argument is mandatory for all connection types except bond, team, bridge and vlan.
|
||||
- This parameter defaults to C(conn_name) when left unset.
|
||||
- The ifname argument is mandatory for all connection types except bond, team, bridge, vlan and vpn.
|
||||
- This parameter defaults to C(conn_name) when left unset for all connection types except vpn that removes it.
|
||||
type: str
|
||||
type:
|
||||
description:
|
||||
@@ -55,10 +55,11 @@ options:
|
||||
- Type C(generic) is added in Ansible 2.5.
|
||||
- Type C(infiniband) is added in community.general 2.0.0.
|
||||
- Type C(gsm) is added in community.general 3.7.0.
|
||||
- Type C(wireguard) is added in community.general 4.3.0
|
||||
- Type C(wireguard) is added in community.general 4.3.0.
|
||||
- Type C(vpn) is added in community.general 5.1.0.
|
||||
type: str
|
||||
choices: [ bond, bond-slave, bridge, bridge-slave, dummy, ethernet, generic, gre, infiniband, ipip, sit, team, team-slave, vlan, vxlan, wifi, gsm,
|
||||
wireguard ]
|
||||
wireguard, vpn ]
|
||||
mode:
|
||||
description:
|
||||
- This is the type of device or network connection that you wish to create for a bond or bridge.
|
||||
@@ -905,6 +906,58 @@ options:
|
||||
description: C(NMSettingSecretFlags) indicating how to handle the I(wireguard.private-key) property.
|
||||
type: int
|
||||
choices: [ 0, 1, 2 ]
|
||||
vpn:
|
||||
description:
|
||||
- Configuration of a VPN connection (PPTP and L2TP).
|
||||
- In order to use L2TP you need to be sure that C(network-manager-l2tp) - and C(network-manager-l2tp-gnome)
|
||||
if host has UI - are installed on the host.
|
||||
type: dict
|
||||
version_added: 5.1.0
|
||||
suboptions:
|
||||
permissions:
|
||||
description: User that will have permission to use the connection.
|
||||
type: str
|
||||
required: true
|
||||
service-type:
|
||||
description: This defines the service type of connection.
|
||||
type: str
|
||||
required: true
|
||||
choices: [ pptp, l2tp ]
|
||||
gateway:
|
||||
description: The gateway to connection. It can be an IP address (for example C(192.0.2.1))
|
||||
or a FQDN address (for example C(vpn.example.com)).
|
||||
type: str
|
||||
required: true
|
||||
password-flags:
|
||||
description:
|
||||
- NMSettingSecretFlags indicating how to handle the I(password) property.
|
||||
- 'Following choices are allowed:
|
||||
C(0) B(NONE): The system is responsible for providing and storing this secret (default);
|
||||
C(1) B(AGENT_OWNED): A user secret agent is responsible for providing and storing this secret; when it is required agents will be
|
||||
asked to retrieve it;
|
||||
C(2) B(NOT_SAVED): This secret should not be saved, but should be requested from the user each time it is needed;
|
||||
C(4) B(NOT_REQUIRED): In situations where it cannot be automatically determined that the secret is required
|
||||
(some VPNs and PPP providers do not require all secrets) this flag indicates that the specific secret is not required.'
|
||||
type: int
|
||||
choices: [ 0, 1, 2 , 4 ]
|
||||
default: 0
|
||||
user:
|
||||
description: Username provided by VPN administrator.
|
||||
type: str
|
||||
required: true
|
||||
ipsec-enabled:
|
||||
description:
|
||||
- Enable or disable IPSec tunnel to L2TP host.
|
||||
- This option is need when C(service-type) is C(l2tp).
|
||||
type: bool
|
||||
choices: [ yes, no ]
|
||||
ipsec-psk:
|
||||
description:
|
||||
- The pre-shared key in base64 encoding.
|
||||
- >
|
||||
You can encode using this Ansible jinja2 expression: C("0s{{ '[YOUR PRE-SHARED KEY]' | ansible.builtin.b64encode }}").
|
||||
- This is only used when I(ipsec-enabled=true).
|
||||
type: str
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
@@ -1288,6 +1341,23 @@ EXAMPLES = r'''
|
||||
autoconnect: true
|
||||
state: present
|
||||
|
||||
- name: >-
|
||||
Create a VPN L2TP connection for ansible_user to connect on vpn.example.com
|
||||
authenticating with user 'brittany' and pre-shared key as 'Brittany123'
|
||||
community.general.nmcli:
|
||||
type: vpn
|
||||
conn_name: my-vpn-connection
|
||||
vpn:
|
||||
permissions: "{{ ansible_user }}"
|
||||
service-type: l2tp
|
||||
gateway: vpn.example.com
|
||||
password-flags: 2
|
||||
user: brittany
|
||||
ipsec-enabled: true
|
||||
ipsec-psk: "0s{{ 'Brittany123' | ansible.builtin.b64encode }}"
|
||||
autoconnect: false
|
||||
state: present
|
||||
|
||||
'''
|
||||
|
||||
RETURN = r"""#
|
||||
@@ -1404,6 +1474,7 @@ class Nmcli(object):
|
||||
self.wifi_sec = module.params['wifi_sec']
|
||||
self.gsm = module.params['gsm']
|
||||
self.wireguard = module.params['wireguard']
|
||||
self.vpn = module.params['vpn']
|
||||
|
||||
if self.method4:
|
||||
self.ipv4_method = self.method4
|
||||
@@ -1430,7 +1501,7 @@ class Nmcli(object):
|
||||
if self._hairpin is None:
|
||||
self.module.deprecate(
|
||||
"Parameter 'hairpin' default value will change from true to false in community.general 7.0.0. "
|
||||
"Set the value explicitly to supress this warning.",
|
||||
"Set the value explicitly to suppress this warning.",
|
||||
version='7.0.0', collection_name='community.general',
|
||||
)
|
||||
# Should be False in 7.0.0 but then that should be in argument_specs
|
||||
@@ -1592,6 +1663,29 @@ class Nmcli(object):
|
||||
options.update({
|
||||
'wireguard.%s' % name: value,
|
||||
})
|
||||
elif self.type == 'vpn':
|
||||
if self.vpn:
|
||||
vpn_data_values = ''
|
||||
for name, value in self.vpn.items():
|
||||
if name == 'service-type':
|
||||
options.update({
|
||||
'vpn-type': value,
|
||||
})
|
||||
elif name == 'permissions':
|
||||
options.update({
|
||||
'connection.permissions': value,
|
||||
})
|
||||
else:
|
||||
if vpn_data_values != '':
|
||||
vpn_data_values += ', '
|
||||
|
||||
if isinstance(value, bool):
|
||||
value = self.bool_to_string(value)
|
||||
|
||||
vpn_data_values += '%s=%s' % (name, value)
|
||||
options.update({
|
||||
'vpn.data': vpn_data_values,
|
||||
})
|
||||
# Convert settings values based on the situation.
|
||||
for setting, value in options.items():
|
||||
setting_type = self.settings_type(setting)
|
||||
@@ -1742,7 +1836,10 @@ class Nmcli(object):
|
||||
|
||||
@staticmethod
|
||||
def list_to_string(lst):
|
||||
return ",".join(lst or [""])
|
||||
if lst is None:
|
||||
return None
|
||||
else:
|
||||
return ",".join(lst)
|
||||
|
||||
@staticmethod
|
||||
def settings_type(setting):
|
||||
@@ -1832,6 +1929,10 @@ class Nmcli(object):
|
||||
'connection.interface-name': ifname,
|
||||
}
|
||||
|
||||
# VPN doesn't need an interface but if sended it must be a valid interface.
|
||||
if self.type == 'vpn' and self.ifname is None:
|
||||
del options['connection.interface-name']
|
||||
|
||||
options.update(self.connection_options())
|
||||
|
||||
# Constructing the command.
|
||||
@@ -1997,6 +2098,9 @@ class Nmcli(object):
|
||||
current_value = current_value.strip('"')
|
||||
if key == self.mtu_setting and self.mtu is None:
|
||||
self.mtu = 0
|
||||
if key == 'vpn.data':
|
||||
current_value = list(map(str.strip, current_value.split(',')))
|
||||
value = list(map(str.strip, value.split(',')))
|
||||
else:
|
||||
# parameter does not exist
|
||||
current_value = None
|
||||
@@ -2025,6 +2129,10 @@ class Nmcli(object):
|
||||
'connection.interface-name': self.ifname,
|
||||
}
|
||||
|
||||
# VPN doesn't need an interface but if sended it must be a valid interface.
|
||||
if self.type == 'vpn' and self.ifname is None:
|
||||
del options['connection.interface-name']
|
||||
|
||||
if not self.type:
|
||||
current_con_type = self.show_connection().get('connection.type')
|
||||
if current_con_type:
|
||||
@@ -2064,6 +2172,7 @@ def main():
|
||||
'wifi',
|
||||
'gsm',
|
||||
'wireguard',
|
||||
'vpn',
|
||||
]),
|
||||
ip4=dict(type='list', elements='str'),
|
||||
gw4=dict(type='str'),
|
||||
@@ -2163,6 +2272,7 @@ def main():
|
||||
wifi_sec=dict(type='dict', no_log=True),
|
||||
gsm=dict(type='dict'),
|
||||
wireguard=dict(type='dict'),
|
||||
vpn=dict(type='dict'),
|
||||
),
|
||||
mutually_exclusive=[['never_default4', 'gw4'],
|
||||
['routes4_extended', 'routes4'],
|
||||
|
||||
@@ -226,7 +226,7 @@ class AnsibleGalaxyInstall(CmdModuleHelper):
|
||||
check_rc = True
|
||||
|
||||
def _get_ansible_galaxy_version(self):
|
||||
ansible_galaxy = self.module.get_bin_path("ansible-galaxy", required=True)
|
||||
ansible_galaxy = self.get_bin_path("ansible-galaxy", required=True)
|
||||
dummy, out, dummy = self.module.run_command([ansible_galaxy, "--version"], check_rc=True)
|
||||
line = out.splitlines()[0]
|
||||
match = self._RE_GALAXY_VERSION.match(line)
|
||||
@@ -242,7 +242,7 @@ class AnsibleGalaxyInstall(CmdModuleHelper):
|
||||
self.module.deprecate(
|
||||
"Support for Ansible 2.9 and ansible-base 2.10 is being deprecated. "
|
||||
"At the same time support for them is ended, also the ack_ansible29 option will be removed. "
|
||||
"Upgrading is strongly recommended, or set 'ack_min_ansiblecore211' to supress this message.",
|
||||
"Upgrading is strongly recommended, or set 'ack_min_ansiblecore211' to suppress this message.",
|
||||
version="8.0.0",
|
||||
collection_name="community.general",
|
||||
)
|
||||
@@ -302,9 +302,9 @@ class AnsibleGalaxyInstall(CmdModuleHelper):
|
||||
self.vars.set("new_roles", {})
|
||||
self.vars.set("ansible29_change", False, change=True, output=False)
|
||||
if not (self.vars.ack_ansible29 or self.vars.ack_min_ansiblecore211):
|
||||
self.module.warn("Ansible 2.9 or older: unable to retrieve lists of roles and collections already installed")
|
||||
self.warn("Ansible 2.9 or older: unable to retrieve lists of roles and collections already installed")
|
||||
if self.vars.requirements_file is not None and self.vars.type == 'both':
|
||||
self.module.warn("Ansible 2.9 or older: will install only roles from requirement files")
|
||||
self.warn("Ansible 2.9 or older: will install only roles from requirement files")
|
||||
|
||||
def _setup210plus(self):
|
||||
self.vars.set("new_collections", {}, change=True)
|
||||
|
||||
@@ -81,7 +81,7 @@ options:
|
||||
classmap_authoritative:
|
||||
description:
|
||||
- Autoload classes from classmap only.
|
||||
- Implicitely enable optimize_autoloader.
|
||||
- Implicitly enable optimize_autoloader.
|
||||
- Recommended especially for production, but can take a bit of time to run.
|
||||
default: false
|
||||
type: bool
|
||||
|
||||
@@ -17,7 +17,7 @@ options:
|
||||
clients:
|
||||
description:
|
||||
- A list of the pip executables that will be used to get the packages.
|
||||
They can be supplied with the full path or just the executable name, i.e `pip3.7`.
|
||||
They can be supplied with the full path or just the executable name, for example C(pip3.7).
|
||||
default: ['pip']
|
||||
required: False
|
||||
type: list
|
||||
|
||||
@@ -62,8 +62,8 @@ options:
|
||||
type: bool
|
||||
default: no
|
||||
notes:
|
||||
- '"name" and "upgrade" are mutually exclusive.'
|
||||
- When used with a `loop:` each package will be processed individually, it is much more efficient to pass the list directly to the `name` option.
|
||||
- 'I(name) and I(upgrade) are mutually exclusive.'
|
||||
- When used with a C(loop:) each package will be processed individually, it is much more efficient to pass the list directly to the I(name) option.
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
|
||||
@@ -35,7 +35,7 @@ options:
|
||||
elements: str
|
||||
path:
|
||||
description:
|
||||
- "A ':' separated list of paths to search for 'brew' executable.
|
||||
- "A C(:) separated list of paths to search for C(brew) executable.
|
||||
Since a package (I(formula) in homebrew parlance) location is prefixed relative to the actual path of I(brew) command,
|
||||
providing an alternative I(brew) path enables managing different set of packages in an alternative location in the system."
|
||||
default: '/usr/local/bin:/opt/homebrew/bin'
|
||||
@@ -70,8 +70,8 @@ options:
|
||||
elements: str
|
||||
version_added: '0.2.0'
|
||||
notes:
|
||||
- When used with a `loop:` each package will be processed individually,
|
||||
it is much more efficient to pass the list directly to the `name` option.
|
||||
- When used with a C(loop:) each package will be processed individually,
|
||||
it is much more efficient to pass the list directly to the I(name) option.
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
|
||||
@@ -70,8 +70,8 @@ options:
|
||||
type: bool
|
||||
default: no
|
||||
notes:
|
||||
- When used with a `loop:` each package will be processed individually,
|
||||
it is much more efficient to pass the list directly to the `name` option.
|
||||
- When used with a C(loop:) each package will be processed individually,
|
||||
it is much more efficient to pass the list directly to the I(name) option.
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
|
||||
@@ -102,8 +102,8 @@ options:
|
||||
author: "bleader (@bleader)"
|
||||
notes:
|
||||
- When using pkgsite, be careful that already in cache packages won't be downloaded again.
|
||||
- When used with a `loop:` each package will be processed individually,
|
||||
it is much more efficient to pass the list directly to the `name` option.
|
||||
- When used with a C(loop:) each package will be processed individually,
|
||||
it is much more efficient to pass the list directly to the I(name) option.
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
|
||||
@@ -119,7 +119,7 @@ options:
|
||||
repoview:
|
||||
description:
|
||||
- Whether to generate repoview files for a published repository. Setting
|
||||
this to "yes" automatically activates `generate_sqlite`.
|
||||
this to "yes" automatically activates C(generate_sqlite).
|
||||
required: false
|
||||
type: bool
|
||||
default: no
|
||||
|
||||
@@ -468,7 +468,7 @@ class Rhsm(RegistrationBase):
|
||||
items = ["--all"]
|
||||
|
||||
if items:
|
||||
args = [SUBMAN_CMD, 'unsubscribe'] + items
|
||||
args = [SUBMAN_CMD, 'remove'] + items
|
||||
rc, stderr, stdout = self.module.run_command(args, check_rc=True)
|
||||
return serials
|
||||
|
||||
|
||||
@@ -136,8 +136,8 @@ options:
|
||||
- Adds C(--clean-deps) option to I(zypper) remove command.
|
||||
version_added: '4.6.0'
|
||||
notes:
|
||||
- When used with a `loop:` each package will be processed individually,
|
||||
it is much more efficient to pass the list directly to the `name` option.
|
||||
- When used with a C(loop:) each package will be processed individually,
|
||||
it is much more efficient to pass the list directly to the I(name) option.
|
||||
# informational: requirements for nodes
|
||||
requirements:
|
||||
- "zypper >= 1.0 # included in openSUSE >= 11.1 or SUSE Linux Enterprise Server/Desktop >= 11.0"
|
||||
|
||||
@@ -29,7 +29,7 @@ options:
|
||||
type: str
|
||||
executable:
|
||||
description:
|
||||
- Path to the hponcfg executable (`hponcfg` which uses $PATH).
|
||||
- Path to the hponcfg executable (C(hponcfg) which uses $PATH).
|
||||
default: hponcfg
|
||||
type: str
|
||||
verbose:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2018 Dell EMC Inc.
|
||||
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2019 Dell EMC Inc.
|
||||
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2019 Dell EMC Inc.
|
||||
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2021-2022 Hewlett Packard Enterprise, Inc. All rights reserved.
|
||||
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2021-2022 Hewlett Packard Enterprise, Inc. All rights reserved.
|
||||
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
@@ -74,7 +74,7 @@ ilo_redfish_info:
|
||||
type: dict
|
||||
contains:
|
||||
ret:
|
||||
description: Check variable to see if the information was succesfully retrived.
|
||||
description: Check variable to see if the information was successfully retrieved.
|
||||
type: bool
|
||||
msg:
|
||||
description: Information of all active iLO sessions.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2017-2018 Dell EMC Inc.
|
||||
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2017-2018 Dell EMC Inc.
|
||||
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2017-2018 Dell EMC Inc.
|
||||
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
@@ -277,6 +277,14 @@ EXAMPLES = '''
|
||||
baseuri: "{{ baseuri }}"
|
||||
username: "{{ username }}"
|
||||
password: "{{ password }}"
|
||||
|
||||
- name: Get Manager Inventory
|
||||
community.general.redfish_info:
|
||||
category: Manager
|
||||
command: GetManagerInventory
|
||||
baseuri: "{{ baseuri }}"
|
||||
username: "{{ username }}"
|
||||
password: "{{ password }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
@@ -301,7 +309,7 @@ CATEGORY_COMMANDS_ALL = {
|
||||
"Sessions": ["GetSessions"],
|
||||
"Update": ["GetFirmwareInventory", "GetFirmwareUpdateCapabilities", "GetSoftwareInventory"],
|
||||
"Manager": ["GetManagerNicInventory", "GetVirtualMedia", "GetLogs", "GetNetworkProtocols",
|
||||
"GetHealthReport", "GetHostInterfaces"],
|
||||
"GetHealthReport", "GetHostInterfaces", "GetManagerInventory"],
|
||||
}
|
||||
|
||||
CATEGORY_COMMANDS_DEFAULT = {
|
||||
@@ -485,6 +493,8 @@ def main():
|
||||
result["health_report"] = rf_utils.get_multi_manager_health_report()
|
||||
elif command == "GetHostInterfaces":
|
||||
result["host_interfaces"] = rf_utils.get_hostinterfaces()
|
||||
elif command == "GetManagerInventory":
|
||||
result["manager"] = rf_utils.get_multi_manager_inventory()
|
||||
|
||||
# Return data back
|
||||
module.exit_json(redfish_facts=result)
|
||||
|
||||
@@ -36,7 +36,7 @@ options:
|
||||
name:
|
||||
description:
|
||||
- The name of the branch that needs to be protected.
|
||||
- Can make use a wildcard charachter for like C(production/*) or just have C(main) or C(develop) as value.
|
||||
- Can make use a wildcard character for like C(production/*) or just have C(main) or C(develop) as value.
|
||||
required: true
|
||||
type: str
|
||||
merge_access_levels:
|
||||
|
||||
@@ -305,7 +305,7 @@ class GitLabUser(object):
|
||||
# note: as we unfortunately have some uncheckable parameters
|
||||
# where it is not possible to determine if the update
|
||||
# changed something or not, we must assume here that a
|
||||
# changed happend and that an user object update is needed
|
||||
# changed happened and that an user object update is needed
|
||||
potentionally_changed = True
|
||||
|
||||
# Assign ssh keys
|
||||
|
||||
@@ -36,7 +36,7 @@ options:
|
||||
force:
|
||||
description:
|
||||
- Discards uncommitted changes. Runs C(hg update -C). Prior to
|
||||
1.9, the default was `yes`.
|
||||
1.9, the default was C(yes).
|
||||
type: bool
|
||||
default: 'no'
|
||||
purge:
|
||||
|
||||
@@ -99,7 +99,7 @@ options:
|
||||
- The size of namespace. This option supports the suffixes C(k) or C(K) or C(KB) for KiB,
|
||||
C(m) or C(M) or C(MB) for MiB, C(g) or C(G) or C(GB) for GiB and C(t) or C(T) or C(TB) for TiB.
|
||||
- This option is required if multiple namespaces are configured.
|
||||
- If this option is not set, all of the avaiable space of a region is configured.
|
||||
- If this option is not set, all of the available space of a region is configured.
|
||||
type: str
|
||||
required: false
|
||||
namespace_append:
|
||||
|
||||
@@ -17,7 +17,7 @@ description:
|
||||
- See the C(zfs allow) section of C(zfs(1M)) for detailed explanations of options.
|
||||
- This module attempts to adhere to the behavior of the command line tool as much as possible.
|
||||
requirements:
|
||||
- "A ZFS/OpenZFS implementation that supports delegation with `zfs allow`, including: Solaris >= 10, illumos (all
|
||||
- "A ZFS/OpenZFS implementation that supports delegation with C(zfs allow), including: Solaris >= 10, illumos (all
|
||||
versions), FreeBSD >= 8.0R, ZFS on Linux >= 0.7.0."
|
||||
options:
|
||||
name:
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
# Copyright: (c) 2014, Gabe Mulley <gabe.mulley@gmail.com>
|
||||
# Copyright: (c) 2015, David Wittman <dwittman@gmail.com>
|
||||
# Copyright: (c) 2022, Marius Rieder <marius.rieder@scs.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
@@ -17,6 +18,7 @@ description:
|
||||
- Manages symbolic links using the 'update-alternatives' tool.
|
||||
- Useful when multiple programs are installed but provide similar functionality (e.g. different editors).
|
||||
author:
|
||||
- Marius Rieder (@jiuka)
|
||||
- David Wittman (@DavidWittman)
|
||||
- Gabe Mulley (@mulby)
|
||||
options:
|
||||
@@ -38,19 +40,45 @@ options:
|
||||
type: path
|
||||
priority:
|
||||
description:
|
||||
- The priority of the alternative.
|
||||
- The priority of the alternative. If no priority is given for creation C(50) is used as a fallback.
|
||||
type: int
|
||||
default: 50
|
||||
state:
|
||||
description:
|
||||
- C(present) - install the alternative (if not already installed), but do
|
||||
not set it as the currently selected alternative for the group.
|
||||
- C(selected) - install the alternative (if not already installed), and
|
||||
set it as the currently selected alternative for the group.
|
||||
choices: [ present, selected ]
|
||||
- C(auto) - install the alternative (if not already installed), and
|
||||
set the group to auto mode. Added in community.general 5.1.0.
|
||||
- C(absent) - removes the alternative. Added in community.general 5.1.0.
|
||||
choices: [ present, selected, auto, absent ]
|
||||
default: selected
|
||||
type: str
|
||||
version_added: 4.8.0
|
||||
subcommands:
|
||||
description:
|
||||
- A list of subcommands.
|
||||
- Each subcommand needs a name, a link and a path parameter.
|
||||
type: list
|
||||
elements: dict
|
||||
aliases: ['slaves']
|
||||
suboptions:
|
||||
name:
|
||||
description:
|
||||
- The generic name of the subcommand.
|
||||
type: str
|
||||
required: true
|
||||
path:
|
||||
description:
|
||||
- The path to the real executable that the subcommand should point to.
|
||||
type: path
|
||||
required: true
|
||||
link:
|
||||
description:
|
||||
- The path to the symbolic link that should point to the real subcommand executable.
|
||||
type: path
|
||||
required: true
|
||||
version_added: 5.1.0
|
||||
requirements: [ update-alternatives ]
|
||||
'''
|
||||
|
||||
@@ -78,6 +106,23 @@ EXAMPLES = r'''
|
||||
path: /usr/bin/python3.5
|
||||
link: /usr/bin/python
|
||||
state: present
|
||||
|
||||
- name: Install Python 3.5 and reset selection to auto
|
||||
community.general.alternatives:
|
||||
name: python
|
||||
path: /usr/bin/python3.5
|
||||
link: /usr/bin/python
|
||||
state: auto
|
||||
|
||||
- name: keytool is a subcommand of java
|
||||
community.general.alternatives:
|
||||
name: java
|
||||
link: /usr/bin/java
|
||||
path: /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
|
||||
subcommands:
|
||||
- name: keytool
|
||||
link: /usr/bin/keytool
|
||||
path: /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/keytool
|
||||
'''
|
||||
|
||||
import os
|
||||
@@ -90,10 +135,238 @@ from ansible.module_utils.basic import AnsibleModule
|
||||
class AlternativeState:
|
||||
PRESENT = "present"
|
||||
SELECTED = "selected"
|
||||
ABSENT = "absent"
|
||||
AUTO = "auto"
|
||||
|
||||
@classmethod
|
||||
def to_list(cls):
|
||||
return [cls.PRESENT, cls.SELECTED]
|
||||
return [cls.PRESENT, cls.SELECTED, cls.ABSENT, cls.AUTO]
|
||||
|
||||
|
||||
class AlternativesModule(object):
|
||||
_UPDATE_ALTERNATIVES = None
|
||||
|
||||
def __init__(self, module):
|
||||
self.module = module
|
||||
self.result = dict(changed=False, diff=dict(before=dict(), after=dict()))
|
||||
self.module.run_command_environ_update = {'LC_ALL': 'C'}
|
||||
self.messages = []
|
||||
self.run()
|
||||
|
||||
@property
|
||||
def mode_present(self):
|
||||
return self.module.params.get('state') in [AlternativeState.PRESENT, AlternativeState.SELECTED, AlternativeState.AUTO]
|
||||
|
||||
@property
|
||||
def mode_selected(self):
|
||||
return self.module.params.get('state') == AlternativeState.SELECTED
|
||||
|
||||
@property
|
||||
def mode_auto(self):
|
||||
return self.module.params.get('state') == AlternativeState.AUTO
|
||||
|
||||
def run(self):
|
||||
self.parse()
|
||||
|
||||
if self.mode_present:
|
||||
# Check if we need to (re)install
|
||||
subcommands_parameter = self.module.params['subcommands']
|
||||
priority_parameter = self.module.params['priority']
|
||||
if (
|
||||
self.path not in self.current_alternatives or
|
||||
(priority_parameter is not None and self.current_alternatives[self.path].get('priority') != priority_parameter) or
|
||||
(subcommands_parameter is not None and (
|
||||
not all(s in subcommands_parameter for s in self.current_alternatives[self.path].get('subcommands')) or
|
||||
not all(s in self.current_alternatives[self.path].get('subcommands') for s in subcommands_parameter)
|
||||
))
|
||||
):
|
||||
self.install()
|
||||
|
||||
# Check if we need to set the preference
|
||||
if self.mode_selected and self.current_path != self.path:
|
||||
self.set()
|
||||
|
||||
# Check if we need to reset to auto
|
||||
if self.mode_auto and self.current_mode == 'manual':
|
||||
self.auto()
|
||||
else:
|
||||
# Check if we need to uninstall
|
||||
if self.path in self.current_alternatives:
|
||||
self.remove()
|
||||
|
||||
self.result['msg'] = ' '.join(self.messages)
|
||||
self.module.exit_json(**self.result)
|
||||
|
||||
def install(self):
|
||||
if not os.path.exists(self.path):
|
||||
self.module.fail_json(msg="Specified path %s does not exist" % self.path)
|
||||
if not self.link:
|
||||
self.module.fail_json(msg='Needed to install the alternative, but unable to do so as we are missing the link')
|
||||
|
||||
cmd = [self.UPDATE_ALTERNATIVES, '--install', self.link, self.name, self.path, str(self.priority)]
|
||||
|
||||
if self.module.params['subcommands'] is not None:
|
||||
subcommands = [['--slave', subcmd['link'], subcmd['name'], subcmd['path']] for subcmd in self.subcommands]
|
||||
cmd += [item for sublist in subcommands for item in sublist]
|
||||
|
||||
self.result['changed'] = True
|
||||
self.messages.append("Install alternative '%s' for '%s'." % (self.path, self.name))
|
||||
|
||||
if not self.module.check_mode:
|
||||
self.module.run_command(cmd, check_rc=True)
|
||||
|
||||
if self.module._diff:
|
||||
self.result['diff']['after'] = dict(
|
||||
state=AlternativeState.PRESENT,
|
||||
path=self.path,
|
||||
priority=self.priority,
|
||||
link=self.link,
|
||||
)
|
||||
if self.subcommands:
|
||||
self.result['diff']['after'].update(dict(
|
||||
subcommands=self.subcommands
|
||||
))
|
||||
|
||||
def remove(self):
|
||||
cmd = [self.UPDATE_ALTERNATIVES, '--remove', self.name, self.path]
|
||||
self.result['changed'] = True
|
||||
self.messages.append("Remove alternative '%s' from '%s'." % (self.path, self.name))
|
||||
|
||||
if not self.module.check_mode:
|
||||
self.module.run_command(cmd, check_rc=True)
|
||||
|
||||
if self.module._diff:
|
||||
self.result['diff']['after'] = dict(state=AlternativeState.ABSENT)
|
||||
|
||||
def set(self):
|
||||
cmd = [self.UPDATE_ALTERNATIVES, '--set', self.name, self.path]
|
||||
self.result['changed'] = True
|
||||
self.messages.append("Set alternative '%s' for '%s'." % (self.path, self.name))
|
||||
|
||||
if not self.module.check_mode:
|
||||
self.module.run_command(cmd, check_rc=True)
|
||||
|
||||
if self.module._diff:
|
||||
self.result['diff']['after']['state'] = AlternativeState.SELECTED
|
||||
|
||||
def auto(self):
|
||||
cmd = [self.UPDATE_ALTERNATIVES, '--auto', self.name]
|
||||
self.messages.append("Set alternative to auto for '%s'." % (self.name))
|
||||
self.result['changed'] = True
|
||||
|
||||
if not self.module.check_mode:
|
||||
self.module.run_command(cmd, check_rc=True)
|
||||
|
||||
if self.module._diff:
|
||||
self.result['diff']['after']['state'] = AlternativeState.PRESENT
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self.module.params.get('name')
|
||||
|
||||
@property
|
||||
def path(self):
|
||||
return self.module.params.get('path')
|
||||
|
||||
@property
|
||||
def link(self):
|
||||
return self.module.params.get('link') or self.current_link
|
||||
|
||||
@property
|
||||
def priority(self):
|
||||
if self.module.params.get('priority') is not None:
|
||||
return self.module.params.get('priority')
|
||||
return self.current_alternatives.get(self.path, {}).get('priority', 50)
|
||||
|
||||
@property
|
||||
def subcommands(self):
|
||||
if self.module.params.get('subcommands') is not None:
|
||||
return self.module.params.get('subcommands')
|
||||
elif self.path in self.current_alternatives and self.current_alternatives[self.path].get('subcommands'):
|
||||
return self.current_alternatives[self.path].get('subcommands')
|
||||
return None
|
||||
|
||||
@property
|
||||
def UPDATE_ALTERNATIVES(self):
|
||||
if self._UPDATE_ALTERNATIVES is None:
|
||||
self._UPDATE_ALTERNATIVES = self.module.get_bin_path('update-alternatives', True)
|
||||
return self._UPDATE_ALTERNATIVES
|
||||
|
||||
def parse(self):
|
||||
self.current_mode = None
|
||||
self.current_path = None
|
||||
self.current_link = None
|
||||
self.current_alternatives = {}
|
||||
|
||||
# Run `update-alternatives --display <name>` to find existing alternatives
|
||||
(rc, display_output, dummy) = self.module.run_command(
|
||||
[self.UPDATE_ALTERNATIVES, '--display', self.name]
|
||||
)
|
||||
|
||||
if rc != 0:
|
||||
self.module.debug("No current alternative found. '%s' exited with %s" % (self.UPDATE_ALTERNATIVES, rc))
|
||||
return
|
||||
|
||||
current_mode_regex = re.compile(r'\s-\s(?:status\sis\s)?(\w*)(?:\smode|.)$', re.MULTILINE)
|
||||
current_path_regex = re.compile(r'^\s*link currently points to (.*)$', re.MULTILINE)
|
||||
current_link_regex = re.compile(r'^\s*link \w+ is (.*)$', re.MULTILINE)
|
||||
subcmd_path_link_regex = re.compile(r'^\s*slave (\S+) is (.*)$', re.MULTILINE)
|
||||
|
||||
alternative_regex = re.compile(r'^(\/.*)\s-\s(?:family\s\S+\s)?priority\s(\d+)((?:\s+slave.*)*)', re.MULTILINE)
|
||||
subcmd_regex = re.compile(r'^\s+slave (.*): (.*)$', re.MULTILINE)
|
||||
|
||||
match = current_mode_regex.search(display_output)
|
||||
if not match:
|
||||
self.module.debug("No current mode found in output")
|
||||
return
|
||||
self.current_mode = match.group(1)
|
||||
|
||||
match = current_path_regex.search(display_output)
|
||||
if not match:
|
||||
self.module.debug("No current path found in output")
|
||||
else:
|
||||
self.current_path = match.group(1)
|
||||
|
||||
match = current_link_regex.search(display_output)
|
||||
if not match:
|
||||
self.module.debug("No current link found in output")
|
||||
else:
|
||||
self.current_link = match.group(1)
|
||||
|
||||
subcmd_path_map = dict(subcmd_path_link_regex.findall(display_output))
|
||||
if not subcmd_path_map and self.subcommands:
|
||||
subcmd_path_map = dict((s['name'], s['link']) for s in self.subcommands)
|
||||
|
||||
for path, prio, subcmd in alternative_regex.findall(display_output):
|
||||
self.current_alternatives[path] = dict(
|
||||
priority=int(prio),
|
||||
subcommands=[dict(
|
||||
name=name,
|
||||
path=spath,
|
||||
link=subcmd_path_map.get(name)
|
||||
) for name, spath in subcmd_regex.findall(subcmd) if spath != '(null)']
|
||||
)
|
||||
|
||||
if self.module._diff:
|
||||
if self.path in self.current_alternatives:
|
||||
self.result['diff']['before'].update(dict(
|
||||
state=AlternativeState.PRESENT,
|
||||
path=self.path,
|
||||
priority=self.current_alternatives[self.path].get('priority'),
|
||||
link=self.current_link,
|
||||
))
|
||||
if self.current_alternatives[self.path].get('subcommands'):
|
||||
self.result['diff']['before'].update(dict(
|
||||
subcommands=self.current_alternatives[self.path].get('subcommands')
|
||||
))
|
||||
if self.current_mode == 'manual' and self.current_path != self.path:
|
||||
self.result['diff']['before'].update(dict(
|
||||
state=AlternativeState.SELECTED
|
||||
))
|
||||
else:
|
||||
self.result['diff']['before'].update(dict(
|
||||
state=AlternativeState.ABSENT
|
||||
))
|
||||
|
||||
|
||||
def main():
|
||||
@@ -103,115 +376,22 @@ def main():
|
||||
name=dict(type='str', required=True),
|
||||
path=dict(type='path', required=True),
|
||||
link=dict(type='path'),
|
||||
priority=dict(type='int', default=50),
|
||||
priority=dict(type='int'),
|
||||
state=dict(
|
||||
type='str',
|
||||
choices=AlternativeState.to_list(),
|
||||
default=AlternativeState.SELECTED,
|
||||
),
|
||||
subcommands=dict(type='list', elements='dict', aliases=['slaves'], options=dict(
|
||||
name=dict(type='str', required=True),
|
||||
path=dict(type='path', required=True),
|
||||
link=dict(type='path', required=True),
|
||||
)),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
params = module.params
|
||||
name = params['name']
|
||||
path = params['path']
|
||||
link = params['link']
|
||||
priority = params['priority']
|
||||
state = params['state']
|
||||
|
||||
UPDATE_ALTERNATIVES = module.get_bin_path('update-alternatives', True)
|
||||
|
||||
current_path = None
|
||||
all_alternatives = []
|
||||
|
||||
# Run `update-alternatives --display <name>` to find existing alternatives
|
||||
(rc, display_output, dummy) = module.run_command(
|
||||
['env', 'LC_ALL=C', UPDATE_ALTERNATIVES, '--display', name]
|
||||
)
|
||||
|
||||
if rc == 0:
|
||||
# Alternatives already exist for this link group
|
||||
# Parse the output to determine the current path of the symlink and
|
||||
# available alternatives
|
||||
current_path_regex = re.compile(r'^\s*link currently points to (.*)$',
|
||||
re.MULTILINE)
|
||||
alternative_regex = re.compile(r'^(\/.*)\s-\s(?:family\s\S+\s)?priority', re.MULTILINE)
|
||||
|
||||
match = current_path_regex.search(display_output)
|
||||
if match:
|
||||
current_path = match.group(1)
|
||||
all_alternatives = alternative_regex.findall(display_output)
|
||||
|
||||
if not link:
|
||||
# Read the current symlink target from `update-alternatives --query`
|
||||
# in case we need to install the new alternative before setting it.
|
||||
#
|
||||
# This is only compatible on Debian-based systems, as the other
|
||||
# alternatives don't have --query available
|
||||
rc, query_output, dummy = module.run_command(
|
||||
['env', 'LC_ALL=C', UPDATE_ALTERNATIVES, '--query', name]
|
||||
)
|
||||
if rc == 0:
|
||||
for line in query_output.splitlines():
|
||||
if line.startswith('Link:'):
|
||||
link = line.split()[1]
|
||||
break
|
||||
|
||||
changed = False
|
||||
if current_path != path:
|
||||
|
||||
# Check mode: expect a change if this alternative is not already
|
||||
# installed, or if it is to be set as the current selection.
|
||||
if module.check_mode:
|
||||
module.exit_json(
|
||||
changed=(
|
||||
path not in all_alternatives or
|
||||
state == AlternativeState.SELECTED
|
||||
),
|
||||
current_path=current_path,
|
||||
)
|
||||
|
||||
try:
|
||||
# install the requested path if necessary
|
||||
if path not in all_alternatives:
|
||||
if not os.path.exists(path):
|
||||
module.fail_json(msg="Specified path %s does not exist" % path)
|
||||
if not link:
|
||||
module.fail_json(msg="Needed to install the alternative, but unable to do so as we are missing the link")
|
||||
|
||||
module.run_command(
|
||||
[UPDATE_ALTERNATIVES, '--install', link, name, path, str(priority)],
|
||||
check_rc=True
|
||||
)
|
||||
changed = True
|
||||
|
||||
# set the current selection to this path (if requested)
|
||||
if state == AlternativeState.SELECTED:
|
||||
module.run_command(
|
||||
[UPDATE_ALTERNATIVES, '--set', name, path],
|
||||
check_rc=True
|
||||
)
|
||||
changed = True
|
||||
|
||||
except subprocess.CalledProcessError as cpe:
|
||||
module.fail_json(msg=str(dir(cpe)))
|
||||
elif current_path == path and state == AlternativeState.PRESENT:
|
||||
# Case where alternative is currently selected, but state is set
|
||||
# to 'present'. In this case, we set to auto mode.
|
||||
if module.check_mode:
|
||||
module.exit_json(changed=True, current_path=current_path)
|
||||
|
||||
changed = True
|
||||
try:
|
||||
module.run_command(
|
||||
[UPDATE_ALTERNATIVES, '--auto', name],
|
||||
check_rc=True,
|
||||
)
|
||||
except subprocess.CalledProcessError as cpe:
|
||||
module.fail_json(msg=str(dir(cpe)))
|
||||
|
||||
module.exit_json(changed=changed)
|
||||
AlternativesModule(module)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
74
plugins/modules/system/gconftool2_info.py
Normal file
74
plugins/modules/system/gconftool2_info.py
Normal file
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# (c) 2022, Alexei Znamensky <russoz@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
module: gconftool2_info
|
||||
author:
|
||||
- "Alexei Znamensky (@russoz)"
|
||||
short_description: Retrieve GConf configurations
|
||||
version_added: 5.1.0
|
||||
description:
|
||||
- This module allows retrieving application preferences from the GConf database, with the help of C(gconftool-2).
|
||||
options:
|
||||
key:
|
||||
description:
|
||||
- The key name for an element in the GConf database.
|
||||
type: str
|
||||
required: true
|
||||
notes:
|
||||
- See man gconftool-2(1) for more details.
|
||||
seealso:
|
||||
- name: gconf repository (archived)
|
||||
description: Git repository for the project. It is an archived project, so the repository is read-only.
|
||||
link: https://gitlab.gnome.org/Archive/gconf
|
||||
'''
|
||||
|
||||
EXAMPLES = """
|
||||
- name: Get value for a certain key in the database.
|
||||
community.general.gconftool2_info:
|
||||
key: /desktop/gnome/background/picture_filename
|
||||
register: result
|
||||
"""
|
||||
|
||||
RETURN = '''
|
||||
value:
|
||||
description:
|
||||
- The value of the property.
|
||||
returned: success
|
||||
type: str
|
||||
sample: Monospace 10
|
||||
'''
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper
|
||||
from ansible_collections.community.general.plugins.module_utils.gconftool2 import gconftool2_runner
|
||||
|
||||
|
||||
class GConftoolInfo(ModuleHelper):
|
||||
output_params = ['key']
|
||||
module = dict(
|
||||
argument_spec=dict(
|
||||
key=dict(type='str', required=True, no_log=False),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
def __init_module__(self):
|
||||
self.runner = gconftool2_runner(self.module, check_rc=True)
|
||||
|
||||
def __run__(self):
|
||||
with self.runner.context(args_order=["get", "key"]) as ctx:
|
||||
rc, out, err = ctx.run(get=True)
|
||||
self.vars.value = None if err and not out else out.rstrip()
|
||||
|
||||
|
||||
def main():
|
||||
GConftoolInfo.execute()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -57,7 +57,7 @@ options:
|
||||
realname:
|
||||
description:
|
||||
- The user's real ('human') name.
|
||||
- This can also be used to add a comment to maintain compatability with C(useradd).
|
||||
- This can also be used to add a comment to maintain compatibility with C(useradd).
|
||||
aliases: [ 'comment' ]
|
||||
type: str
|
||||
realm:
|
||||
|
||||
270
plugins/modules/system/keyring.py
Normal file
270
plugins/modules/system/keyring.py
Normal file
@@ -0,0 +1,270 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright: (c) 2022, Alexander Hussey <ahussey@redhat.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
"""
|
||||
Ansible Module - community.general.keyring
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = r"""
|
||||
---
|
||||
module: keyring
|
||||
version_added: 5.2.0
|
||||
author:
|
||||
- Alexander Hussey (@ahussey-redhat)
|
||||
short_description: Set or delete a passphrase using the Operating System's native keyring
|
||||
description: >-
|
||||
This module uses the L(keyring Python library, https://pypi.org/project/keyring/)
|
||||
to set or delete passphrases for a given service and username from the OS' native keyring.
|
||||
requirements:
|
||||
- keyring (Python library)
|
||||
- gnome-keyring (application - required for headless Gnome keyring access)
|
||||
- dbus-run-session (application - required for headless Gnome keyring access)
|
||||
options:
|
||||
service:
|
||||
description: The name of the service.
|
||||
required: true
|
||||
type: str
|
||||
username:
|
||||
description: The user belonging to the service.
|
||||
required: true
|
||||
type: str
|
||||
user_password:
|
||||
description: The password to set.
|
||||
required: false
|
||||
type: str
|
||||
aliases:
|
||||
- password
|
||||
keyring_password:
|
||||
description: Password to unlock keyring.
|
||||
required: true
|
||||
type: str
|
||||
state:
|
||||
description: Whether the password should exist.
|
||||
required: false
|
||||
default: present
|
||||
type: str
|
||||
choices:
|
||||
- present
|
||||
- absent
|
||||
"""
|
||||
|
||||
EXAMPLES = r"""
|
||||
- name: Set a password for test/test1
|
||||
community.general.keyring:
|
||||
service: test
|
||||
username: test1
|
||||
user_password: "{{ user_password }}"
|
||||
keyring_password: "{{ keyring_password }}"
|
||||
|
||||
- name: Delete the password for test/test1
|
||||
community.general.keyring:
|
||||
service: test
|
||||
username: test1
|
||||
user_password: "{{ user_password }}"
|
||||
keyring_password: "{{ keyring_password }}"
|
||||
state: absent
|
||||
"""
|
||||
|
||||
try:
|
||||
from shlex import quote
|
||||
except ImportError:
|
||||
from pipes import quote
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
|
||||
try:
|
||||
import keyring
|
||||
|
||||
HAS_KEYRING = True
|
||||
except ImportError:
|
||||
HAS_KEYRING = False
|
||||
KEYRING_IMP_ERR = traceback.format_exc()
|
||||
|
||||
|
||||
def del_passphrase(module):
|
||||
"""
|
||||
Attempt to delete a passphrase in the keyring using the Python API and fallback to using a shell.
|
||||
"""
|
||||
if module.check_mode:
|
||||
return None
|
||||
try:
|
||||
keyring.delete_password(module.params["service"], module.params["username"])
|
||||
return None
|
||||
except keyring.errors.KeyringLocked as keyring_locked_err: # pylint: disable=unused-variable
|
||||
delete_argument = (
|
||||
'echo "%s" | gnome-keyring-daemon --unlock\nkeyring del %s %s\n'
|
||||
% (
|
||||
quote(module.params["keyring_password"]),
|
||||
quote(module.params["service"]),
|
||||
quote(module.params["username"]),
|
||||
)
|
||||
)
|
||||
dummy, dummy, stderr = module.run_command(
|
||||
"dbus-run-session -- /bin/bash",
|
||||
use_unsafe_shell=True,
|
||||
data=delete_argument,
|
||||
encoding=None,
|
||||
)
|
||||
|
||||
if not stderr.decode("UTF-8"):
|
||||
return None
|
||||
return stderr.decode("UTF-8")
|
||||
|
||||
|
||||
def set_passphrase(module):
|
||||
"""
|
||||
Attempt to set passphrase in the keyring using the Python API and fallback to using a shell.
|
||||
"""
|
||||
if module.check_mode:
|
||||
return None
|
||||
try:
|
||||
keyring.set_password(
|
||||
module.params["service"],
|
||||
module.params["username"],
|
||||
module.params["user_password"],
|
||||
)
|
||||
return None
|
||||
except keyring.errors.KeyringLocked as keyring_locked_err: # pylint: disable=unused-variable
|
||||
set_argument = (
|
||||
'echo "%s" | gnome-keyring-daemon --unlock\nkeyring set %s %s\n%s\n'
|
||||
% (
|
||||
quote(module.params["keyring_password"]),
|
||||
quote(module.params["service"]),
|
||||
quote(module.params["username"]),
|
||||
quote(module.params["user_password"]),
|
||||
)
|
||||
)
|
||||
dummy, dummy, stderr = module.run_command(
|
||||
"dbus-run-session -- /bin/bash",
|
||||
use_unsafe_shell=True,
|
||||
data=set_argument,
|
||||
encoding=None,
|
||||
)
|
||||
if not stderr.decode("UTF-8"):
|
||||
return None
|
||||
return stderr.decode("UTF-8")
|
||||
|
||||
|
||||
def get_passphrase(module):
|
||||
"""
|
||||
Attempt to retrieve passphrase from keyring using the Python API and fallback to using a shell.
|
||||
"""
|
||||
try:
|
||||
passphrase = keyring.get_password(
|
||||
module.params["service"], module.params["username"]
|
||||
)
|
||||
return passphrase
|
||||
except keyring.errors.KeyringLocked:
|
||||
pass
|
||||
except keyring.errors.InitError:
|
||||
pass
|
||||
except AttributeError:
|
||||
pass
|
||||
get_argument = 'echo "%s" | gnome-keyring-daemon --unlock\nkeyring get %s %s\n' % (
|
||||
quote(module.params["keyring_password"]),
|
||||
quote(module.params["service"]),
|
||||
quote(module.params["username"]),
|
||||
)
|
||||
dummy, stdout, dummy = module.run_command(
|
||||
"dbus-run-session -- /bin/bash",
|
||||
use_unsafe_shell=True,
|
||||
data=get_argument,
|
||||
encoding=None,
|
||||
)
|
||||
try:
|
||||
return stdout.decode("UTF-8").splitlines()[1] # Only return the line containing the password
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
|
||||
def run_module():
|
||||
"""
|
||||
Attempts to retrieve a passphrase from a keyring.
|
||||
"""
|
||||
result = dict(
|
||||
changed=False,
|
||||
msg="",
|
||||
)
|
||||
|
||||
module_args = dict(
|
||||
service=dict(type="str", required=True),
|
||||
username=dict(type="str", required=True),
|
||||
keyring_password=dict(type="str", required=True, no_log=True),
|
||||
user_password=dict(
|
||||
type="str", required=False, no_log=True, aliases=["password"]
|
||||
),
|
||||
state=dict(
|
||||
type="str", required=False, default="present", choices=["absent", "present"]
|
||||
),
|
||||
)
|
||||
|
||||
module = AnsibleModule(argument_spec=module_args, supports_check_mode=True)
|
||||
|
||||
if not HAS_KEYRING:
|
||||
module.fail_json(msg=missing_required_lib("keyring"), exception=KEYRING_IMP_ERR)
|
||||
|
||||
passphrase = get_passphrase(module)
|
||||
if module.params["state"] == "present":
|
||||
if passphrase is not None:
|
||||
if passphrase == module.params["user_password"]:
|
||||
result["msg"] = "Passphrase already set for %s@%s" % (
|
||||
module.params["service"],
|
||||
module.params["username"],
|
||||
)
|
||||
if passphrase != module.params["user_password"]:
|
||||
set_result = set_passphrase(module)
|
||||
if set_result is None:
|
||||
result["changed"] = True
|
||||
result["msg"] = "Passphrase has been updated for %s@%s" % (
|
||||
module.params["service"],
|
||||
module.params["username"],
|
||||
)
|
||||
if set_result is not None:
|
||||
module.fail_json(msg=set_result)
|
||||
if passphrase is None:
|
||||
set_result = set_passphrase(module)
|
||||
if set_result is None:
|
||||
result["changed"] = True
|
||||
result["msg"] = "Passphrase has been updated for %s@%s" % (
|
||||
module.params["service"],
|
||||
module.params["username"],
|
||||
)
|
||||
if set_result is not None:
|
||||
module.fail_json(msg=set_result)
|
||||
|
||||
if module.params["state"] == "absent":
|
||||
if not passphrase:
|
||||
result["result"] = "Passphrase already absent for %s@%s" % (
|
||||
module.params["service"],
|
||||
module.params["username"],
|
||||
)
|
||||
if passphrase:
|
||||
del_result = del_passphrase(module)
|
||||
if del_result is None:
|
||||
result["changed"] = True
|
||||
result["msg"] = "Passphrase has been removed for %s@%s" % (
|
||||
module.params["service"],
|
||||
module.params["username"],
|
||||
)
|
||||
if del_result is not None:
|
||||
module.fail_json(msg=del_result)
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
||||
def main():
|
||||
"""
|
||||
main module loop
|
||||
"""
|
||||
run_module()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
149
plugins/modules/system/keyring_info.py
Normal file
149
plugins/modules/system/keyring_info.py
Normal file
@@ -0,0 +1,149 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright: (c) 2022, Alexander Hussey <ahussey@redhat.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
"""
|
||||
Ansible Module - community.general.keyring_info
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = r"""
|
||||
---
|
||||
module: keyring_info
|
||||
version_added: 5.2.0
|
||||
author:
|
||||
- Alexander Hussey (@ahussey-redhat)
|
||||
short_description: Get a passphrase using the Operating System's native keyring
|
||||
description: >-
|
||||
This module uses the L(keyring Python library, https://pypi.org/project/keyring/)
|
||||
to retrieve passphrases for a given service and username from the OS' native keyring.
|
||||
requirements:
|
||||
- keyring (Python library)
|
||||
- gnome-keyring (application - required for headless Linux keyring access)
|
||||
- dbus-run-session (application - required for headless Linux keyring access)
|
||||
options:
|
||||
service:
|
||||
description: The name of the service.
|
||||
required: true
|
||||
type: str
|
||||
username:
|
||||
description: The user belonging to the service.
|
||||
required: true
|
||||
type: str
|
||||
keyring_password:
|
||||
description: Password to unlock keyring.
|
||||
required: true
|
||||
type: str
|
||||
"""
|
||||
|
||||
EXAMPLES = r"""
|
||||
- name: Retrieve password for service_name/user_name
|
||||
community.general.keyring_info:
|
||||
service: test
|
||||
username: test1
|
||||
keyring_password: "{{ keyring_password }}"
|
||||
register: test_password
|
||||
|
||||
- name: Display password
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ test_password.passphrase }}"
|
||||
"""
|
||||
|
||||
RETURN = r"""
|
||||
passphrase:
|
||||
description: A string containing the password.
|
||||
returned: success and the password exists
|
||||
type: str
|
||||
sample: Password123
|
||||
"""
|
||||
|
||||
try:
|
||||
from shlex import quote
|
||||
except ImportError:
|
||||
from pipes import quote
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
|
||||
try:
|
||||
import keyring
|
||||
|
||||
HAS_KEYRING = True
|
||||
except ImportError:
|
||||
HAS_KEYRING = False
|
||||
KEYRING_IMP_ERR = traceback.format_exc()
|
||||
|
||||
|
||||
def _alternate_retrieval_method(module):
|
||||
get_argument = 'echo "%s" | gnome-keyring-daemon --unlock\nkeyring get %s %s\n' % (
|
||||
quote(module.params["keyring_password"]),
|
||||
quote(module.params["service"]),
|
||||
quote(module.params["username"]),
|
||||
)
|
||||
dummy, stdout, dummy = module.run_command(
|
||||
"dbus-run-session -- /bin/bash",
|
||||
use_unsafe_shell=True,
|
||||
data=get_argument,
|
||||
encoding=None,
|
||||
)
|
||||
try:
|
||||
return stdout.decode("UTF-8").splitlines()[1]
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
|
||||
def run_module():
|
||||
"""
|
||||
Attempts to retrieve a passphrase from a keyring.
|
||||
"""
|
||||
result = dict(changed=False, msg="")
|
||||
|
||||
module_args = dict(
|
||||
service=dict(type="str", required=True),
|
||||
username=dict(type="str", required=True),
|
||||
keyring_password=dict(type="str", required=True, no_log=True),
|
||||
)
|
||||
|
||||
module = AnsibleModule(argument_spec=module_args, supports_check_mode=True)
|
||||
|
||||
if not HAS_KEYRING:
|
||||
module.fail_json(msg=missing_required_lib("keyring"), exception=KEYRING_IMP_ERR)
|
||||
try:
|
||||
passphrase = keyring.get_password(
|
||||
module.params["service"], module.params["username"]
|
||||
)
|
||||
except keyring.errors.KeyringLocked:
|
||||
pass
|
||||
except keyring.errors.InitError:
|
||||
pass
|
||||
except AttributeError:
|
||||
pass
|
||||
passphrase = _alternate_retrieval_method(module)
|
||||
|
||||
if passphrase is not None:
|
||||
result["msg"] = "Successfully retrieved password for %s@%s" % (
|
||||
module.params["service"],
|
||||
module.params["username"],
|
||||
)
|
||||
result["passphrase"] = passphrase
|
||||
if passphrase is None:
|
||||
result["msg"] = "Password for %s@%s does not exist." % (
|
||||
module.params["service"],
|
||||
module.params["username"],
|
||||
)
|
||||
module.exit_json(**result)
|
||||
|
||||
|
||||
def main():
|
||||
"""
|
||||
main module loop
|
||||
"""
|
||||
run_module()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -129,7 +129,7 @@ state:
|
||||
type: str
|
||||
sample: "reloaded"
|
||||
status:
|
||||
description: a dictionary with the key=value pairs returned by `system-control show-json` or C(None) if the service is not loaded
|
||||
description: A dictionary with the key=value pairs returned by C(system-control show-json) or C(None) if the service is not loaded
|
||||
returned: success
|
||||
type: complex
|
||||
contains:
|
||||
|
||||
@@ -51,6 +51,11 @@ options:
|
||||
description:
|
||||
- Puppet environment to be used.
|
||||
type: str
|
||||
confdir:
|
||||
description:
|
||||
- Path to the directory containing the puppet.conf file.
|
||||
type: str
|
||||
version_added: 5.1.0
|
||||
logdest:
|
||||
description:
|
||||
- Where the puppet logs should go, if puppet apply is being used.
|
||||
@@ -179,6 +184,7 @@ def main():
|
||||
puppetmaster=dict(type='str'),
|
||||
modulepath=dict(type='str'),
|
||||
manifest=dict(type='str'),
|
||||
confdir=dict(type='str'),
|
||||
noop=dict(type='bool'),
|
||||
logdest=dict(type='str', default='stdout', choices=['all', 'stdout', 'syslog']),
|
||||
# The following is not related to Ansible's diff; see https://github.com/ansible-collections/community.general/pull/3980#issuecomment-1005666154
|
||||
@@ -255,6 +261,8 @@ def main():
|
||||
cmd += " --server %s" % shlex_quote(p['puppetmaster'])
|
||||
if p['show_diff']:
|
||||
cmd += " --show_diff"
|
||||
if p['confdir']:
|
||||
cmd += " --confdir %s" % shlex_quote(p['confdir'])
|
||||
if p['environment']:
|
||||
cmd += " --environment '%s'" % p['environment']
|
||||
if p['tags']:
|
||||
|
||||
@@ -65,6 +65,15 @@ options:
|
||||
- The name of the user for the sudoers rule.
|
||||
- This option cannot be used in conjunction with I(group).
|
||||
type: str
|
||||
validation:
|
||||
description:
|
||||
- If C(absent), the sudoers rule will be added without validation.
|
||||
- If C(detect) and visudo is available, then the sudoers rule will be validated by visudo.
|
||||
- If C(required), visudo must be available to validate the sudoers rule.
|
||||
type: str
|
||||
default: detect
|
||||
choices: [ absent, detect, required ]
|
||||
version_added: 5.2.0
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
@@ -115,7 +124,11 @@ from ansible.module_utils.common.text.converters import to_native
|
||||
|
||||
class Sudoers(object):
|
||||
|
||||
FILE_MODE = 0o440
|
||||
|
||||
def __init__(self, module):
|
||||
self.module = module
|
||||
|
||||
self.check_mode = module.check_mode
|
||||
self.name = module.params['name']
|
||||
self.user = module.params['user']
|
||||
@@ -126,6 +139,7 @@ class Sudoers(object):
|
||||
self.sudoers_path = module.params['sudoers_path']
|
||||
self.file = os.path.join(self.sudoers_path, self.name)
|
||||
self.commands = module.params['commands']
|
||||
self.validation = module.params['validation']
|
||||
|
||||
def write(self):
|
||||
if self.check_mode:
|
||||
@@ -134,6 +148,8 @@ class Sudoers(object):
|
||||
with open(self.file, 'w') as f:
|
||||
f.write(self.content())
|
||||
|
||||
os.chmod(self.file, self.FILE_MODE)
|
||||
|
||||
def delete(self):
|
||||
if self.check_mode:
|
||||
return
|
||||
@@ -145,7 +161,12 @@ class Sudoers(object):
|
||||
|
||||
def matches(self):
|
||||
with open(self.file, 'r') as f:
|
||||
return f.read() == self.content()
|
||||
content_matches = f.read() == self.content()
|
||||
|
||||
current_mode = os.stat(self.file).st_mode & 0o777
|
||||
mode_matches = current_mode == self.FILE_MODE
|
||||
|
||||
return content_matches and mode_matches
|
||||
|
||||
def content(self):
|
||||
if self.user:
|
||||
@@ -158,10 +179,29 @@ class Sudoers(object):
|
||||
runas_str = '({runas})'.format(runas=self.runas) if self.runas is not None else ''
|
||||
return "{owner} ALL={runas}{nopasswd} {commands}\n".format(owner=owner, runas=runas_str, nopasswd=nopasswd_str, commands=commands_str)
|
||||
|
||||
def validate(self):
|
||||
if self.validation == 'absent':
|
||||
return
|
||||
|
||||
visudo_path = self.module.get_bin_path('visudo', required=self.validation == 'required')
|
||||
if visudo_path is None:
|
||||
return
|
||||
|
||||
check_command = [visudo_path, '-c', '-f', '-']
|
||||
rc, stdout, stderr = self.module.run_command(check_command, data=self.content())
|
||||
|
||||
if rc != 0:
|
||||
raise Exception('Failed to validate sudoers rule:\n{stdout}'.format(stdout=stdout))
|
||||
|
||||
def run(self):
|
||||
if self.state == 'absent' and self.exists():
|
||||
self.delete()
|
||||
return True
|
||||
if self.state == 'absent':
|
||||
if self.exists():
|
||||
self.delete()
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
self.validate()
|
||||
|
||||
if self.exists() and self.matches():
|
||||
return False
|
||||
@@ -197,6 +237,10 @@ def main():
|
||||
'choices': ['present', 'absent'],
|
||||
},
|
||||
'user': {},
|
||||
'validation': {
|
||||
'default': 'detect',
|
||||
'choices': ['absent', 'detect', 'required']
|
||||
},
|
||||
}
|
||||
|
||||
module = AnsibleModule(
|
||||
|
||||
@@ -790,7 +790,7 @@ class AIXTimezone(Timezone):
|
||||
inspects C(/etc/environment) to determine the current timezone.
|
||||
|
||||
While AIX time zones can be set using two formats (POSIX and
|
||||
Olson) the prefered method is Olson.
|
||||
Olson) the preferred method is Olson.
|
||||
See the following article for more information:
|
||||
https://developer.ibm.com/articles/au-aix-posix/
|
||||
|
||||
|
||||
@@ -145,31 +145,15 @@ RETURN = '''
|
||||
sample: '"96" or ["red", "blue", "green"]'
|
||||
'''
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.module_helper import (
|
||||
CmdStateModuleHelper, ArgFormat
|
||||
)
|
||||
|
||||
|
||||
def fix_bool(value):
|
||||
vl = value.lower()
|
||||
return vl if vl in ("true", "false") else value
|
||||
|
||||
|
||||
@ArgFormat.stars_deco(1)
|
||||
def values_fmt(values, value_types):
|
||||
result = []
|
||||
for value, value_type in zip(values, value_types):
|
||||
if value_type == 'bool':
|
||||
value = fix_bool(value)
|
||||
result.extend(['--type', '{0}'.format(value_type), '--set', '{0}'.format(value)])
|
||||
return result
|
||||
from ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper
|
||||
from ansible_collections.community.general.plugins.module_utils.xfconf import xfconf_runner
|
||||
|
||||
|
||||
class XFConfException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class XFConfProperty(CmdStateModuleHelper):
|
||||
class XFConfProperty(StateModuleHelper):
|
||||
change_params = 'value',
|
||||
diff_params = 'value',
|
||||
output_params = ('property', 'channel', 'value')
|
||||
@@ -191,27 +175,19 @@ class XFConfProperty(CmdStateModuleHelper):
|
||||
)
|
||||
|
||||
default_state = 'present'
|
||||
command = 'xfconf-query'
|
||||
command_args_formats = dict(
|
||||
channel=dict(fmt=('--channel', '{0}'),),
|
||||
property=dict(fmt=('--property', '{0}'),),
|
||||
is_array=dict(fmt="--force-array", style=ArgFormat.BOOLEAN),
|
||||
reset=dict(fmt="--reset", style=ArgFormat.BOOLEAN),
|
||||
create=dict(fmt="--create", style=ArgFormat.BOOLEAN),
|
||||
values_and_types=dict(fmt=values_fmt)
|
||||
)
|
||||
|
||||
def update_xfconf_output(self, **kwargs):
|
||||
self.update_vars(meta={"output": True, "fact": True}, **kwargs)
|
||||
|
||||
def __init_module__(self):
|
||||
self.does_not = 'Property "{0}" does not exist on channel "{1}".'.format(self.module.params['property'],
|
||||
self.module.params['channel'])
|
||||
self.runner = xfconf_runner(self.module)
|
||||
self.does_not = 'Property "{0}" does not exist on channel "{1}".'.format(self.vars.property,
|
||||
self.vars.channel)
|
||||
self.vars.set('previous_value', self._get(), fact=True)
|
||||
self.vars.set('type', self.vars.value_type, fact=True)
|
||||
self.vars.meta('value').set(initial_value=self.vars.previous_value)
|
||||
|
||||
if self.module.params['disable_facts'] is False:
|
||||
if self.vars.disable_facts is False:
|
||||
self.do_raise('Returning results as facts has been removed. Stop using disable_facts=false.')
|
||||
|
||||
def process_command_output(self, rc, out, err):
|
||||
@@ -229,11 +205,12 @@ class XFConfProperty(CmdStateModuleHelper):
|
||||
return result
|
||||
|
||||
def _get(self):
|
||||
return self.run_command(params=('channel', 'property'))
|
||||
with self.runner('channel property', output_process=self.process_command_output) as ctx:
|
||||
return ctx.run()
|
||||
|
||||
def state_absent(self):
|
||||
if not self.module.check_mode:
|
||||
self.run_command(params=('channel', 'property', {'reset': True}))
|
||||
with self.runner('channel property reset', check_mode_skip=True) as ctx:
|
||||
ctx.run(reset=True)
|
||||
self.vars.value = None
|
||||
|
||||
def state_present(self):
|
||||
@@ -252,22 +229,14 @@ class XFConfProperty(CmdStateModuleHelper):
|
||||
# or complain if lists' lengths are different
|
||||
raise XFConfException('Number of elements in "value" and "value_type" must be the same')
|
||||
|
||||
# fix boolean values
|
||||
self.vars.value = [fix_bool(v[0]) if v[1] == 'bool' else v[0] for v in zip(self.vars.value, value_type)]
|
||||
|
||||
# calculates if it is an array
|
||||
self.vars.is_array = \
|
||||
bool(self.vars.force_array) or \
|
||||
isinstance(self.vars.previous_value, list) or \
|
||||
values_len > 1
|
||||
|
||||
params = ['channel', 'property', {'create': True}]
|
||||
if self.vars.is_array:
|
||||
params.append('is_array')
|
||||
params.append({'values_and_types': (self.vars.value, value_type)})
|
||||
|
||||
if not self.module.check_mode:
|
||||
self.run_command(params=params)
|
||||
with self.runner('channel property create force_array values_and_types', check_mode_skip=True) as ctx:
|
||||
ctx.run(create=True, force_array=self.vars.is_array, values_and_types=(self.vars.value, value_type))
|
||||
|
||||
if not self.vars.is_array:
|
||||
self.vars.value = self.vars.value[0]
|
||||
|
||||
@@ -74,7 +74,7 @@ RETURN = '''
|
||||
properties:
|
||||
description:
|
||||
- List of available properties for a specific channel.
|
||||
- Returned by passed only the I(channel) parameter to the module.
|
||||
- Returned by passing only the I(channel) parameter to the module.
|
||||
returned: success
|
||||
type: list
|
||||
elements: str
|
||||
@@ -116,14 +116,15 @@ RETURN = '''
|
||||
- Tmp
|
||||
'''
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.module_helper import CmdModuleHelper, ArgFormat
|
||||
from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper
|
||||
from ansible_collections.community.general.plugins.module_utils.xfconf import xfconf_runner
|
||||
|
||||
|
||||
class XFConfException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class XFConfInfo(CmdModuleHelper):
|
||||
class XFConfInfo(ModuleHelper):
|
||||
module = dict(
|
||||
argument_spec=dict(
|
||||
channel=dict(type='str'),
|
||||
@@ -135,16 +136,9 @@ class XFConfInfo(CmdModuleHelper):
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
command = 'xfconf-query'
|
||||
command_args_formats = dict(
|
||||
channel=dict(fmt=['--channel', '{0}']),
|
||||
property=dict(fmt=['--property', '{0}']),
|
||||
_list_arg=dict(fmt="--list", style=ArgFormat.BOOLEAN),
|
||||
)
|
||||
check_rc = True
|
||||
|
||||
def __init_module__(self):
|
||||
self.vars.set("_list_arg", False, output=False)
|
||||
self.runner = xfconf_runner(self.module, check_rc=True)
|
||||
self.vars.set("list_arg", False, output=False)
|
||||
self.vars.set("is_array", False)
|
||||
|
||||
def process_command_output(self, rc, out, err):
|
||||
@@ -167,7 +161,7 @@ class XFConfInfo(CmdModuleHelper):
|
||||
return lines
|
||||
|
||||
def __run__(self):
|
||||
self.vars._list_arg = not (bool(self.vars.channel) and bool(self.vars.property))
|
||||
self.vars.list_arg = not (bool(self.vars.channel) and bool(self.vars.property))
|
||||
output = 'value'
|
||||
proc = self.process_command_output
|
||||
if self.vars.channel is None:
|
||||
@@ -176,15 +170,15 @@ class XFConfInfo(CmdModuleHelper):
|
||||
elif self.vars.property is None:
|
||||
output = 'properties'
|
||||
proc = self._process_list_properties
|
||||
result = self.run_command(params=('_list_arg', 'channel', 'property'), process_output=proc)
|
||||
if not self.vars._list_arg and self.vars.is_array:
|
||||
with self.runner.context('list_arg channel property', output_process=proc) as ctx:
|
||||
result = ctx.run(**self.vars)
|
||||
if not self.vars.list_arg and self.vars.is_array:
|
||||
output = "value_array"
|
||||
self.vars.set(output, result)
|
||||
|
||||
|
||||
def main():
|
||||
xfconf = XFConfInfo()
|
||||
xfconf.run()
|
||||
XFConfInfo.execute()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -186,7 +186,7 @@ options:
|
||||
validate_certs:
|
||||
required: false
|
||||
description:
|
||||
- Require valid SSL certificates (set to `false` if you'd like to use self-signed certificates)
|
||||
- Require valid SSL certificates (set to C(false) if you'd like to use self-signed certificates)
|
||||
default: true
|
||||
type: bool
|
||||
|
||||
|
||||
@@ -49,6 +49,9 @@
|
||||
# Test that path is checked: alternatives must fail when path is nonexistent
|
||||
- import_tasks: path_is_checked.yml
|
||||
|
||||
# Test that subcommands commands work
|
||||
- import_tasks: subcommands.yml
|
||||
|
||||
# Test operation of the 'state' parameter
|
||||
- block:
|
||||
- include_tasks: remove_links.yml
|
||||
@@ -63,6 +66,8 @@
|
||||
state: absent
|
||||
with_items:
|
||||
- '{{ alternatives_dir }}/dummy'
|
||||
- '{{ alternatives_dir }}/dummymain'
|
||||
- '{{ alternatives_dir }}/dummysubcmd'
|
||||
|
||||
- file:
|
||||
path: '/usr/bin/dummy{{ item }}'
|
||||
|
||||
217
tests/integration/targets/alternatives/tasks/subcommands.yml
Normal file
217
tests/integration/targets/alternatives/tasks/subcommands.yml
Normal file
@@ -0,0 +1,217 @@
|
||||
- name: Try with subcommands
|
||||
alternatives:
|
||||
name: dummymain
|
||||
path: '/usr/bin/dummy1'
|
||||
link: '/usr/bin/dummymain'
|
||||
subcommands:
|
||||
- name: dummysubcmd
|
||||
path: '/usr/bin/dummy2'
|
||||
link: '/usr/bin/dummysubcmd'
|
||||
register: alternative
|
||||
|
||||
- name: Check expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- 'alternative is changed'
|
||||
|
||||
- name: Execute the current dummymain command
|
||||
command: dummymain
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy1"
|
||||
|
||||
- name: Execute the current dummysubcmd command
|
||||
command: dummysubcmd
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy2"
|
||||
|
||||
- name: Get dummymain alternatives output
|
||||
command:
|
||||
cmd: '{{ alternatives_command }} --display dummymain'
|
||||
register: result
|
||||
|
||||
- name: Print result
|
||||
debug:
|
||||
var: result.stdout_lines
|
||||
|
||||
- name: Subcommands are not removed if not specified
|
||||
alternatives:
|
||||
name: dummymain
|
||||
path: '/usr/bin/dummy1'
|
||||
link: '/usr/bin/dummymain'
|
||||
register: alternative
|
||||
|
||||
- name: Check expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- 'alternative is not changed'
|
||||
|
||||
- name: Execute the current dummysubcmd command
|
||||
command: dummysubcmd
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy2"
|
||||
|
||||
- name: Subcommands are removed if set to an empty list
|
||||
alternatives:
|
||||
name: dummymain
|
||||
path: '/usr/bin/dummy1'
|
||||
link: '/usr/bin/dummymain'
|
||||
subcommands: []
|
||||
register: alternative
|
||||
|
||||
- name: Check expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- 'alternative is changed'
|
||||
|
||||
- name: Execute the current dummysubcmd command
|
||||
command: dummysubcmd
|
||||
register: cmd
|
||||
ignore_errors: True
|
||||
|
||||
- name: Ensure that the subcommand is gone
|
||||
assert:
|
||||
that:
|
||||
- cmd.rc == 2
|
||||
- '"No such file" in cmd.msg'
|
||||
|
||||
- name: Get dummymain alternatives output
|
||||
command:
|
||||
cmd: '{{ alternatives_command }} --display dummymain'
|
||||
register: result
|
||||
|
||||
- name: Print result
|
||||
debug:
|
||||
var: result.stdout_lines
|
||||
|
||||
- name: Install other alternative with subcommands
|
||||
alternatives:
|
||||
name: dummymain
|
||||
path: '/usr/bin/dummy3'
|
||||
link: '/usr/bin/dummymain'
|
||||
subcommands:
|
||||
- name: dummysubcmd
|
||||
path: '/usr/bin/dummy4'
|
||||
link: '/usr/bin/dummysubcmd'
|
||||
register: alternative
|
||||
|
||||
- name: Check expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- 'alternative is changed'
|
||||
|
||||
- name: Execute the current dummymain command
|
||||
command: dummymain
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy3"
|
||||
|
||||
- name: Execute the current dummysubcmd command
|
||||
command: dummysubcmd
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy4"
|
||||
|
||||
- name: Get dummymain alternatives output
|
||||
command:
|
||||
cmd: '{{ alternatives_command }} --display dummymain'
|
||||
register: result
|
||||
|
||||
- name: Print result
|
||||
debug:
|
||||
var: result.stdout_lines
|
||||
|
||||
- name: Switch to first alternative
|
||||
alternatives:
|
||||
name: dummymain
|
||||
path: '/usr/bin/dummy1'
|
||||
register: alternative
|
||||
|
||||
- name: Check expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- 'alternative is changed'
|
||||
|
||||
- name: Execute the current dummymain command
|
||||
command: dummymain
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy1"
|
||||
|
||||
- name: Execute the current dummysubcmd command
|
||||
command: dummysubcmd
|
||||
register: cmd
|
||||
ignore_errors: True
|
||||
|
||||
- name: Ensure that the subcommand is gone
|
||||
assert:
|
||||
that:
|
||||
- cmd.rc == 2
|
||||
- '"No such file" in cmd.msg'
|
||||
|
||||
- name: Get dummymain alternatives output
|
||||
command:
|
||||
cmd: '{{ alternatives_command }} --display dummymain'
|
||||
register: result
|
||||
|
||||
- name: Print result
|
||||
debug:
|
||||
var: result.stdout_lines
|
||||
|
||||
- name: Switch to second alternative
|
||||
alternatives:
|
||||
name: dummymain
|
||||
path: '/usr/bin/dummy3'
|
||||
register: alternative
|
||||
|
||||
- name: Check expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- 'alternative is changed'
|
||||
|
||||
- name: Execute the current dummymain command
|
||||
command: dummymain
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy3"
|
||||
|
||||
- name: Execute the current dummysubcmd command
|
||||
command: dummysubcmd
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy4"
|
||||
|
||||
- name: Get dummymain alternatives output
|
||||
command:
|
||||
cmd: '{{ alternatives_command }} --display dummymain'
|
||||
register: result
|
||||
|
||||
- name: Print result
|
||||
debug:
|
||||
var: result.stdout_lines
|
||||
@@ -49,5 +49,3 @@
|
||||
|
||||
- name: check that alternative has been updated
|
||||
command: "grep -Pzq '/bin/dummy{{ item }}\\n' '{{ alternatives_dir }}/dummy'"
|
||||
# priority doesn't seem updated
|
||||
#command: "grep -Pzq '/bin/dummy{{ item }}\\n50' '{{ alternatives_dir }}/dummy'"
|
||||
|
||||
@@ -21,3 +21,29 @@
|
||||
|
||||
- name: check that alternative has been updated
|
||||
command: "grep -Pzq '/bin/dummy{{ item }}\\n{{ 60 + item|int }}' '{{ alternatives_dir }}/dummy'"
|
||||
|
||||
- name: update dummy priority
|
||||
alternatives:
|
||||
name: dummy
|
||||
path: '/usr/bin/dummy{{ item }}'
|
||||
link: /usr/bin/dummy
|
||||
priority: '{{ 70 + item|int }}'
|
||||
register: alternative
|
||||
|
||||
- name: check that alternative priority has been updated
|
||||
command: "grep -Pzq '/bin/dummy{{ item }}\\n{{ 70 + item|int }}' '{{ alternatives_dir }}/dummy'"
|
||||
|
||||
- name: no change without priority
|
||||
alternatives:
|
||||
name: dummy
|
||||
path: '/usr/bin/dummy{{ item }}'
|
||||
link: /usr/bin/dummy
|
||||
register: alternative
|
||||
|
||||
- name: check no change was triggered without priority
|
||||
assert:
|
||||
that:
|
||||
- 'alternative is not changed'
|
||||
|
||||
- name: check that alternative priority has not been changed
|
||||
command: "grep -Pzq '/bin/dummy{{ item }}\\n{{ 70 + item|int }}' '{{ alternatives_dir }}/dummy'"
|
||||
|
||||
@@ -49,6 +49,28 @@
|
||||
- cmd.stdout == "dummy4"
|
||||
|
||||
# Set the currently selected alternative to state = 'present' (was previously
|
||||
# selected), and ensure that this results in the group not being set to 'auto'
|
||||
# mode, and the alternative is still selected.
|
||||
- name: Set current selected dummy to state = present
|
||||
alternatives:
|
||||
name: dummy
|
||||
path: /usr/bin/dummy4
|
||||
link: /usr/bin/dummy
|
||||
state: present
|
||||
|
||||
- name: Ensure that the link group is in auto mode
|
||||
shell: 'head -n1 {{ alternatives_dir }}/dummy | grep "^manual$"'
|
||||
|
||||
- name: Execute the current dummy command
|
||||
shell: dummy
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy4"
|
||||
|
||||
# Set the currently selected alternative to state = 'auto' (was previously
|
||||
# selected), and ensure that this results in the group being set to 'auto'
|
||||
# mode, and the highest priority alternative is selected.
|
||||
- name: Set current selected dummy to state = present
|
||||
@@ -56,7 +78,7 @@
|
||||
name: dummy
|
||||
path: /usr/bin/dummy4
|
||||
link: /usr/bin/dummy
|
||||
state: present
|
||||
state: auto
|
||||
|
||||
- name: Ensure that the link group is in auto mode
|
||||
shell: 'head -n1 {{ alternatives_dir }}/dummy | grep "^auto$"'
|
||||
@@ -69,3 +91,25 @@
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy2"
|
||||
|
||||
# Remove an alternative with state = 'absent' and make sure that
|
||||
# this change results in the alternative being removed.
|
||||
- name: Remove best dummy alternative with state = absent
|
||||
alternatives:
|
||||
name: dummy
|
||||
path: /usr/bin/dummy2
|
||||
state: absent
|
||||
|
||||
- name: Ensure that the link group is in auto mode
|
||||
shell: 'grep "/usr/bin/dummy2" {{ alternatives_dir }}/dummy'
|
||||
register: cmd
|
||||
failed_when: cmd.rc == 0
|
||||
|
||||
- name: Execute the current dummy command
|
||||
shell: dummy
|
||||
register: cmd
|
||||
|
||||
- name: Ensure that the expected command was executed
|
||||
assert:
|
||||
that:
|
||||
- cmd.stdout == "dummy1"
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
---
|
||||
alternatives_dir: /var/lib/dpkg/alternatives/
|
||||
alternatives_command: update-alternatives
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
---
|
||||
alternatives_dir: /var/lib/rpm/alternatives/
|
||||
alternatives_command: update-alternatives
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
---
|
||||
alternatives_dir: /var/lib/alternatives/
|
||||
alternatives_command: update-alternatives
|
||||
|
||||
@@ -6,43 +6,15 @@
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
import sys
|
||||
|
||||
DOCUMENTATION = '''
|
||||
module: cmd_echo
|
||||
author: "Alexei Znamensky (@russoz)"
|
||||
short_description: Simple module for testing
|
||||
description:
|
||||
- Simple module test description.
|
||||
options:
|
||||
command:
|
||||
description: aaa
|
||||
type: list
|
||||
elements: str
|
||||
required: true
|
||||
arg_formats:
|
||||
description: bbb
|
||||
type: dict
|
||||
required: true
|
||||
arg_order:
|
||||
description: ccc
|
||||
type: raw
|
||||
required: true
|
||||
arg_values:
|
||||
description: ddd
|
||||
type: list
|
||||
required: true
|
||||
aa:
|
||||
description: eee
|
||||
type: raw
|
||||
'''
|
||||
DOCUMENTATION = ""
|
||||
|
||||
EXAMPLES = ""
|
||||
|
||||
RETURN = ""
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, fmt
|
||||
from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt as fmt
|
||||
|
||||
|
||||
def main():
|
||||
@@ -51,11 +23,15 @@ def main():
|
||||
arg_formats=dict(type="dict", default={}),
|
||||
arg_order=dict(type="raw", required=True),
|
||||
arg_values=dict(type="dict", default={}),
|
||||
check_mode_skip=dict(type="bool", default=False),
|
||||
aa=dict(type="raw"),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
p = module.params
|
||||
|
||||
info = None
|
||||
|
||||
arg_formats = {}
|
||||
for arg, fmt_spec in p['arg_formats'].items():
|
||||
func = getattr(fmt, fmt_spec['func'])
|
||||
@@ -65,11 +41,11 @@ def main():
|
||||
|
||||
runner = CmdRunner(module, ['echo', '--'], arg_formats=arg_formats)
|
||||
|
||||
info = None
|
||||
with runner.context(p['arg_order']) as ctx:
|
||||
with runner.context(p['arg_order'], check_mode_skip=p['check_mode_skip']) as ctx:
|
||||
result = ctx.run(**p['arg_values'])
|
||||
info = ctx.run_info
|
||||
rc, out, err = result
|
||||
check = "check"
|
||||
rc, out, err = result if result is not None else (None, None, None)
|
||||
|
||||
module.exit_json(rc=rc, out=out, err=err, info=info)
|
||||
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
arg_formats: "{{ item.arg_formats|default(omit) }}"
|
||||
arg_order: "{{ item.arg_order }}"
|
||||
arg_values: "{{ item.arg_values|default(omit) }}"
|
||||
check_mode_skip: "{{ item.check_mode_skip|default(omit) }}"
|
||||
aa: "{{ item.aa|default(omit) }}"
|
||||
register: test_result
|
||||
check_mode: "{{ item.check_mode|default(omit) }}"
|
||||
ignore_errors: "{{ item.expect_error|default(omit) }}"
|
||||
|
||||
- name: check results [{{ item.name }}]
|
||||
|
||||
@@ -82,3 +82,41 @@ cmd_echo_tests:
|
||||
- >-
|
||||
"MissingArgumentValue: Cannot find value for parameter bb"
|
||||
in test_result.module_stderr
|
||||
|
||||
- name: set aa and bb value with check_mode on
|
||||
arg_formats:
|
||||
aa:
|
||||
func: as_opt_eq_val
|
||||
args: [--answer]
|
||||
bb:
|
||||
func: as_bool
|
||||
args: [--bb-here]
|
||||
arg_order: 'aa bb'
|
||||
arg_values:
|
||||
bb: true
|
||||
aa: 11
|
||||
check_mode: true
|
||||
assertions:
|
||||
- test_result.rc == 0
|
||||
- test_result.out == "-- --answer=11 --bb-here\n"
|
||||
- test_result.err == ""
|
||||
|
||||
- name: set aa and bb value with check_mode and check_mode_skip on
|
||||
arg_formats:
|
||||
aa:
|
||||
func: as_opt_eq_val
|
||||
args: [--answer]
|
||||
bb:
|
||||
func: as_bool
|
||||
args: [--bb-here]
|
||||
arg_order: 'aa bb'
|
||||
arg_values:
|
||||
bb: true
|
||||
check_mode_skip: true
|
||||
aa: 11
|
||||
check_mode: true
|
||||
expect_error: true # because if result contains rc != 0, ansible assumes error
|
||||
assertions:
|
||||
- test_result.rc == None
|
||||
- test_result.out == None
|
||||
- test_result.err == None
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
- "valid_comma_separated_spaces | community.general.from_csv(skipinitialspace=True) == expected_result"
|
||||
- "valid_comma_separated_spaces | community.general.from_csv != expected_result"
|
||||
|
||||
- name: Parse valid csv input with no headers with/without specifiying fieldnames
|
||||
- name: Parse valid csv input with no headers with/without specifying fieldnames
|
||||
assert:
|
||||
that:
|
||||
- "valid_comma_separated_no_headers | community.general.from_csv(fieldnames=['id','name','role']) == expected_result"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user