1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/plugins/module_utils
Mike Hume 1a13287788
Add sops lookup plugin (#374)
* add sops lookup plugin

* fix pylint

* fix undefined encrypted_file variable

* decode sops output as text by default

* add variable to control decrypted content print in logs

* use Sops class decryption method

* lookup should return text, use appropriate ansible facility

* use ansible.module_utils._text.to_native

As required by Ansible documentation on [raising errors][raising-errors]
from plugins, use to_native to wrap errors to ensure string compatibility
between Python versions.

[raising-errors]: https://docs.ansible.com/ansible/latest/dev_guide/developing_plugins.html#id3

* use with_items instead of with_file in sops lookup documentation

[with_file][with-file], per Ansible documentation, returns the content of
the file. As sops is not able to decrypt a string by itself but requires
the file is passed as argument, passing the content breaks the lookup
plugin as reported by [here][bug-report].

[with_items][with-items] should be used instead.

[with-file]: https://docs.ansible.com/ansible/2.4/playbooks_loops.html#looping-over-files
[with-items]: https://docs.ansible.com/ansible/2.4/playbooks_loops.html#standard-loops
[bug-report]: https://github.com/ansible/ansible/pull/59639#issuecomment-540803722

* uniform sops exception handling between plugins

* Apply suggestions from code review

Co-Authored-By: Felix Fontein <felix@fontein.de>

* remove sops lookup plugin print option

Is no longer possible to print the decrypted secrets directly from this
plugin, but `debug` module can be used instead.

* add github handle to author

* add setup_sops integration target

* extract sops module

* add lookup_sops integration tests

* use sops module

* Update plugins/module_utils/sops.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/module_utils/sops.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/sops.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/module_utils/sops.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/module_utils/sops.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update test/integration/targets/lookup_sops/tasks/ubuntu.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/module_utils/sops.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update test/integration/targets/lookup_sops/files/simple.sops.yaml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Adding aliases file

* Emtpy spaces

* Update plugins/lookup/sops.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/sops.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/sops.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update test/integration/targets/lookup_sops/tasks/ubuntu.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/sops.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update test/integration/targets/lookup_sops/tasks/ubuntu.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update test/integration/targets/lookup_sops/tasks/ubuntu.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* gpg -> gnupg2

* with_items -> loop

* Move error logic to module_utils.

* Make Sops.decrypt() also handle errors and decode output.

* Improve error handling.

* Improve example formatting.

* Reorganize tests.

* Add test.

* Remove version_added.

Co-authored-by: Edoardo Tenani <edoardo.tenani@protonmail.com>
Co-authored-by: Edoardo Tenani <edoardo.tenani@gmail.com>
Co-authored-by: Edoardo T <endorama@users.noreply.github.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
2020-06-06 21:36:28 +02:00
..
compat Add copy of ipaddress.py from ansible.netcommon (#49) 2020-03-26 20:44:26 +00:00
docker Initial commit 2020-03-09 09:11:07 +00:00
identity Initial commit 2020-03-09 09:11:07 +00:00
net_tools Fix imports, part 2 (#42) 2020-03-25 11:43:51 +00:00
oracle Initial commit 2020-03-09 09:11:07 +00:00
remote_management Initial commit 2020-03-09 09:11:07 +00:00
source_control Initial commit 2020-03-09 09:11:07 +00:00
storage Initial commit 2020-03-09 09:11:07 +00:00
__init__.py Initial commit 2020-03-09 09:11:07 +00:00
_netapp.py Fix sanity test failures for _netapp.py. (#82) 2020-03-31 10:27:23 +02:00
_ovirt.py Un-remove wrongly removed ovirt modules and adjust deprecation to Ansible 2.14 (#353) 2020-05-18 20:43:50 +01:00
alicloud_ecs.py Add param for doc/fragments/alicloud (#108) 2020-04-13 08:23:38 +02:00
cloud.py Initial commit 2020-03-09 09:11:07 +00:00
cloudscale.py Initial commit 2020-03-09 09:11:07 +00:00
database.py postgresql_privs: add trust_input parameter (#177) 2020-04-20 09:01:42 +03:00
digital_ocean.py Initial commit 2020-03-09 09:11:07 +00:00
dimensiondata.py Initial commit 2020-03-09 09:11:07 +00:00
exoscale.py Initial commit 2020-03-09 09:11:07 +00:00
firewalld.py Initial commit 2020-03-09 09:11:07 +00:00
gcdns.py Initial commit 2020-03-09 09:11:07 +00:00
gce.py Initial commit 2020-03-09 09:11:07 +00:00
gcp.py Initial commit 2020-03-09 09:11:07 +00:00
gitlab.py Initial commit 2020-03-09 09:11:07 +00:00
heroku.py Initial commit 2020-03-09 09:11:07 +00:00
hetzner.py Initial commit 2020-03-09 09:11:07 +00:00
hwc_utils.py Initial commit 2020-03-09 09:11:07 +00:00
ibm_sa_utils.py Initial commit 2020-03-09 09:11:07 +00:00
infinibox.py Initial commit 2020-03-09 09:11:07 +00:00
influxdb.py Initial commit 2020-03-09 09:11:07 +00:00
ipa.py ipa: Remove redundant encoding in json.loads (#87) 2020-04-01 17:09:38 +05:30
known_hosts.py Initial commit 2020-03-09 09:11:07 +00:00
kubevirt.py Fix imports and installing dependencies in CI, part 1 (#41) 2020-03-24 22:14:53 +00:00
ldap.py Initial commit 2020-03-09 09:11:07 +00:00
linode.py Initial commit 2020-03-09 09:11:07 +00:00
lxd.py Initial commit 2020-03-09 09:11:07 +00:00
manageiq.py Initial commit 2020-03-09 09:11:07 +00:00
memset.py Initial commit 2020-03-09 09:11:07 +00:00
mysql.py Initial commit 2020-03-09 09:11:07 +00:00
oneandone.py Initial commit 2020-03-09 09:11:07 +00:00
oneview.py Initial commit 2020-03-09 09:11:07 +00:00
online.py Initial commit 2020-03-09 09:11:07 +00:00
opennebula.py Initial commit 2020-03-09 09:11:07 +00:00
postgres.py postgres: make interfaces of exec_sql clearer (#43) 2020-03-25 11:44:28 +00:00
pure.py Initial commit 2020-03-09 09:11:07 +00:00
rax.py Initial commit 2020-03-09 09:11:07 +00:00
redfish_utils.py Initial commit 2020-03-09 09:11:07 +00:00
redhat.py Initial commit 2020-03-09 09:11:07 +00:00
saslprep.py postgresql_user: add scram-sha-256 password support (#100) 2020-04-22 12:45:14 +01:00
scaleway.py scaleway: Fix case mismatch causing key lookup failure (#445) 2020-06-02 14:09:58 +01:00
sops.py Add sops lookup plugin (#374) 2020-06-06 21:36:28 +02:00
univention_umc.py Initial commit 2020-03-09 09:11:07 +00:00
utm_utils.py Initial commit 2020-03-09 09:11:07 +00:00
vexata.py Initial commit 2020-03-09 09:11:07 +00:00
xenserver.py Initial commit 2020-03-09 09:11:07 +00:00