Retrofit ignored/filtered parameters to 1.0 callback

It's possible in ARA 0.x for users to specify playbook parameters
that won't be saved by ARA.
Add this to the 1.0 callback and rename them to arguments instead
of parameters.

Depends-On: https://review.openstack.org/610389
Change-Id: I517dd6f90eaee15f0d762242750c10a5fc9fc955
This commit is contained in:
David Moreau Simard 2018-10-14 12:03:30 -04:00
parent a2ce0758e4
commit 25fd771512
No known key found for this signature in database
GPG Key ID: CBEB466764A9E621
1 changed files with 19 additions and 3 deletions

View File

@ -80,6 +80,15 @@ options:
ini:
- section: ara
key: ignored_facts
ignored_arguments:
description: List of Ansible arguments that will not be saved by ARA
type: list
default: ["extra_vars"]
env:
- name: ARA_IGNORED_ARGUMENTS
ini:
- section: ara
key: ignored_arguments
"""
@ -112,6 +121,7 @@ class CallbackModule(CallbackBase):
super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
self.ignored_facts = self.get_option("ignored_facts")
self.ignored_arguments = self.get_option("ignored_arguments")
api_client = self.get_option("api_client")
if api_client == "offline":
@ -128,15 +138,21 @@ class CallbackModule(CallbackBase):
path = os.path.abspath(playbook._file_name)
if self._options is not None:
parameters = self._options.__dict__.copy()
arguments = self._options.__dict__.copy()
else:
parameters = {}
arguments = {}
# Potentially sanitize some user-specified keys
for argument in self.ignored_arguments:
if argument in arguments:
self.log.debug("Ignoring argument: %s" % argument)
arguments[argument] = "Not saved by ARA as configured by 'ignored_arguments'"
# Create the playbook
self.playbook = self.client.post(
"/api/v1/playbooks",
ansible_version=ansible_version,
parameters=parameters,
arguments=arguments,
file=dict(path=path, content=self._read_file(path)),
)