Provide helpful return output on ara_record tasks

There's no good reason why ara_record would only return a status
message. It'd be much more helpful if it returned the same thing
as ara_read so let's do that.

Change-Id: I46d511dd39136da96afa75b447d86acd58aaf86e
This commit is contained in:
David Moreau-Simard 2017-05-25 10:21:33 -04:00 committed by David Moreau Simard
parent a72ece2e7a
commit 58e875cc9d
3 changed files with 18 additions and 4 deletions

View File

@ -78,9 +78,16 @@ EXAMPLES = """
register: git_version
delegate_to: localhost
# Registering the result of an ara_record task is equivalent to doing an
# ara_read on the key
- ara_record:
key: "git_version"
value: "{{ git_version.stdout }}"
register: version
- name: Print recorded data
debug:
msg: "{{ version.playbook_id}} - {{ version.key }}: {{ version.value }}
# Write data with a type (otherwise defaults to "text")
# This changes the behavior on how the value is presented in the web interface
@ -177,6 +184,10 @@ class ActionModule(ActionBase):
try:
self.create_or_update_key(playbook_id, key, value, type)
result['key'] = key
result['value'] = value
result['type'] = type
result['playbook_id'] = playbook_id
result['msg'] = 'Data recorded in ARA for this playbook.'
except Exception as e:
result['failed'] = True

View File

@ -28,10 +28,6 @@
ara_record:
key: "notype"
value: "text"
- name: Read notype key
ara_read:
key: "notype"
register: notype
- name: Validate notype key

View File

@ -31,10 +31,17 @@ order to register whatever you'd like in a key/value format, for example::
command: git rev-parse HEAD
register: git_version
# Registering the result of an ara_record tasks is equivalent to
# doing an ara_read on the key
- name: Record git version
ara_record:
key: "git_version"
value: "{{ git_version.stdout }}"
register: version
- name: Print recorded data
debug:
msg: "{{ version.playbook_id}} - {{ version.key }}: {{ version.value }}
It also supports data types which will have an impact on how the value will be
displayed in the web interface. The default type if not specified is "text".