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/tests/integration/targets/lookup_sops/files/simple.sops.yaml
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

25 lines
1.3 KiB
YAML

foo: ENC[AES256_GCM,data:a25L,iv:X8ILHZr+YiyLWa90Y+cwoMD1nVuel7JyTs0A5+oiOOo=,tag:GbBtp+Yqx1KEjdyztqS4EQ==,type:str]
sops:
kms: []
gcp_kms: []
azure_kv: []
lastmodified: '2020-02-20T10:44:32Z'
mac: ENC[AES256_GCM,data:BAwQqD9sHgHkmlxPQLKq28Xy48qPp1B/+GDLEsIxir6WNhZgw8OgjVF1u/wCAad6qHkmN02Bwenr+aay6uKfCuOEsTRSvZ7v80yAU+h0wL3zJ/KMkRsE3QP3CWxcLQxInt+YaBjR+Q0IUjDXKm3u6ZomixZe5F5pwWr36ErV6Y0=,iv:e/iiyXQiCh8C2w/bc8mr/Psv+ehmqEMqEC1/bbGFHpY=,tag:NSDo2HISIBJhYvsqrU0mSA==,type:str]
pgp:
- created_at: '2020-02-20T10:44:32Z'
enc: |-
-----BEGIN PGP MESSAGE-----
wcBMAyUpShfNkFB/AQgALJTUwdx6rAPckJ+reP5TEq+lXzHI1Zi7aHYOqZQBnA2s
z8h1gRce/fn7RPkmdsjsdSYmxGGKqwDXxUYsbN1aWXk6mb4Juktdvjl/GndF6PkU
TiN/l1GM6upgS+GPxA01NKsGkVmEtKR5NhsNEnE6OzY29+PFLsBX2vO1Zfg7kzBz
cDl6PT8fbFTEaFeyuYl9IslIV8yYsj1oHL3CF76RjCP6b18NSOHM23ytlH+KVaBV
ntoSVkTyWDx5o9iEHBEWSEGNpaCWWiEgkDEkA1VqMHdUlsW+IjZ8ggg5NJbcVtrG
YkN8rlGsNEzx+g4O4b1160A2K6AdTBcoGHwHD3u3XdLgAeTqT1ekE2N3yNT6w4sm
6uET4eTS4Cvg1OFCgOC34uUzlY3gbuVy20h8RNyQoAfhSN4DD2MexKqcMMCVCtn0
OhRMTP2jjOCe5Ex3/p3awcVxwx7qeJ26Vnfiwtg6ueFI5AA=
=tcnq
-----END PGP MESSAGE-----
fp: FBC7B9E2A4F9289AC0C1D4843D16CEE4A27381B4
unencrypted_suffix: _unencrypted
version: 3.4.0