update ansible collections sops, docker and debops
This commit is contained in:
parent
f1135b818f
commit
e31ee5e39c
910 changed files with 27667 additions and 19786 deletions
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import typing as t
|
||||
from collections.abc import Sequence, Mapping
|
||||
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
|
|
@ -19,10 +20,19 @@ try:
|
|||
except ImportError:
|
||||
HAS_DATATAGGING = False
|
||||
|
||||
try:
|
||||
from ansible.plugins.action import VariableLayer # type: ignore[attr-defined]
|
||||
HAS_REGISTER_HOST_VARIABLES = True
|
||||
except ImportError:
|
||||
HAS_REGISTER_HOST_VARIABLES = False
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
from ansible_collections.community.sops.plugins.plugin_utils.action_module import AnsibleActionModule
|
||||
|
||||
display = Display()
|
||||
|
||||
|
||||
def _make_safe(value):
|
||||
def _make_safe(value: t.Any) -> t.Any:
|
||||
if HAS_DATATAGGING and isinstance(value, str):
|
||||
return _trust_as_template(value)
|
||||
return value
|
||||
|
|
@ -30,7 +40,7 @@ def _make_safe(value):
|
|||
|
||||
class ActionModule(ActionModuleBase):
|
||||
|
||||
def _load(self, filename, module):
|
||||
def _load(self, filename: str, module: AnsibleActionModule) -> dict:
|
||||
def get_option_value(argument_name):
|
||||
return module.params.get(argument_name)
|
||||
|
||||
|
|
@ -71,6 +81,7 @@ class ActionModule(ActionModuleBase):
|
|||
file=dict(type='path', required=True),
|
||||
name=dict(type='str'),
|
||||
expressions=dict(type='str', default='ignore', choices=['ignore', 'evaluate-on-load', 'lazy-evaluation']),
|
||||
return_method=dict(type='str', default='auto', choices=['auto', 'facts-only', 'vars-only']),
|
||||
),
|
||||
)
|
||||
argument_spec.argument_spec.update(get_sops_argument_spec())
|
||||
|
|
@ -81,7 +92,15 @@ class ActionModule(ActionModuleBase):
|
|||
if expressions == 'lazy-evaluation' and not HAS_DATATAGGING:
|
||||
module.fail_json(msg='expressions=lazy-evaluation requires ansible-core 2.19+ with Data Tagging support.')
|
||||
|
||||
data = dict()
|
||||
return_method_str = module.params['return_method']
|
||||
if return_method_str == 'auto':
|
||||
return_as_facts = not HAS_REGISTER_HOST_VARIABLES
|
||||
else:
|
||||
return_as_facts = return_method_str == 'facts-only'
|
||||
if not HAS_REGISTER_HOST_VARIABLES and not return_as_facts:
|
||||
module.fail_json(msg='return_method=vars-only requires ansible-core 2.21+')
|
||||
|
||||
data = {}
|
||||
files = []
|
||||
try:
|
||||
filename = self._find_needle('vars', module.params['file'])
|
||||
|
|
@ -94,8 +113,7 @@ class ActionModule(ActionModuleBase):
|
|||
if name is None:
|
||||
value = data
|
||||
else:
|
||||
value = dict()
|
||||
value[name] = data
|
||||
value = {name: data}
|
||||
|
||||
if expressions == 'evaluate-on-load':
|
||||
value = self._evaluate(value)
|
||||
|
|
@ -103,8 +121,14 @@ class ActionModule(ActionModuleBase):
|
|||
if expressions == 'lazy-evaluation':
|
||||
value = self._make_safe(value)
|
||||
|
||||
module.exit_json(
|
||||
ansible_included_var_files=files,
|
||||
ansible_facts=value,
|
||||
_ansible_no_log=True,
|
||||
)
|
||||
result = {
|
||||
'ansible_included_var_files': files,
|
||||
'_ansible_no_log': True,
|
||||
}
|
||||
|
||||
if return_as_facts:
|
||||
result['ansible_facts'] = value
|
||||
else:
|
||||
self.register_host_variables(variables=value, layer=VariableLayer.INCLUDE_VARS)
|
||||
|
||||
module.exit_json(**result)
|
||||
|
|
|
|||
Loading…
Reference in a new issue