mirror of
https://github.com/ansible/awx.git
synced 2026-02-21 13:10:11 -03:30
Add job artifacts and workflow artifact passing
artifacts redact from job when no_log is set parent no_log artifacts treated as survey passwords
This commit is contained in:
@@ -184,6 +184,9 @@ class BaseCallbackModule(object):
|
||||
if getattr(self, 'ad_hoc_command_id', None):
|
||||
msg['ad_hoc_command_id'] = self.ad_hoc_command_id
|
||||
|
||||
if getattr(self, 'artifact_data', None):
|
||||
msg['artifact_data'] = self.artifact_data
|
||||
|
||||
active_pid = os.getpid()
|
||||
if self.job_callback_debug:
|
||||
msg.update({
|
||||
@@ -416,6 +419,9 @@ class JobCallbackModule(BaseCallbackModule):
|
||||
event_data['task'] = task_name
|
||||
if role_name and event not in self.EVENTS_WITHOUT_TASK:
|
||||
event_data['role'] = role_name
|
||||
self.artifact_data = None
|
||||
if 'res' in event_data and 'artifact_data' in event_data['res']:
|
||||
self.artifact_data = event_data['res']['artifact_data']
|
||||
super(JobCallbackModule, self)._log_event(event, **event_data)
|
||||
|
||||
def playbook_on_start(self):
|
||||
|
||||
59
awx/plugins/library/set_artifact.py
Normal file
59
awx/plugins/library/set_artifact.py
Normal file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from ansible.module_utils.basic import * # noqa
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: set_artifact
|
||||
short_description: Stash some Ansible variables for later
|
||||
description:
|
||||
- Saves a user-specified JSON dictionary of variables from a playbook
|
||||
for later use
|
||||
version_added: "2.2"
|
||||
options:
|
||||
requirements: [ ]
|
||||
author: Alan Rominger
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Example fact output:
|
||||
|
||||
# Simple specifying of an artifact dictionary, will be passed on callback
|
||||
- set_artifact:
|
||||
data:
|
||||
one_artifact: "{{ local_var * 2 }}"
|
||||
another_artifact: "{{ some_registered_var.results | map(attribute='ansible_facts.some_fact') | list }}"
|
||||
|
||||
|
||||
# Specifying a local path to save the artifacts to
|
||||
- set_artifact:
|
||||
data:
|
||||
one_artifact: "{{ local_var * 2 }}"
|
||||
another_artifact: "{{ some_registered_var.results | map(attribute='ansible_facts.some_fact') | list }}"
|
||||
dest=/tmp/prefix-{{ inventory_hostname }}
|
||||
|
||||
|
||||
|
||||
host | success >> {
|
||||
"artifact_data": {}
|
||||
}
|
||||
'''
|
||||
|
||||
def main():
|
||||
import json
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
data=dict(
|
||||
type='dict',
|
||||
default={}
|
||||
)
|
||||
)
|
||||
)
|
||||
results = dict(
|
||||
changed=True,
|
||||
artifact_data=json.dumps(module.params.get('data'))
|
||||
)
|
||||
module.exit_json(**results)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user