Implement ara_record data types

Data types allows a user to specify a type when recording data.
Depending on the type, the display behavior or format will be different
in the web interface.
The first implemented types are as follows:
- text (default): straight text in <pre>
- url: value becomes a hyperlink
- json: value is json pretty-printed

Other example types that could be implemented eventually would be
markdown or rst for rich formatting.

Change-Id: I28b78a2b5899ece3b0abc4648bd8d0a2678c80ee
This commit is contained in:
David Moreau-Simard
2016-11-19 16:41:16 -05:00
parent fd8d56d8aa
commit ea1f0f9cd1
16 changed files with 174 additions and 22 deletions

View File

@@ -55,5 +55,6 @@ EXAMPLES = '''
with_items:
- foo.key
- foo.value
- foo.type
- foo.playbook_id
'''

View File

@@ -22,12 +22,11 @@
DOCUMENTATION = '''
---
module: ara_record
short_description: Ansible module to record data with ARA
short_description: Ansible module to record persistent data with ARA.
version_added: "2.0"
author: "RDO Community <rdo-list@redhat.com>"
description:
- Ansible module to record data with ARA. This module should always be
executed wherever the playbook is run from.
- Ansible module to record persistent data with ARA.
options:
key:
description:
@@ -37,6 +36,11 @@ options:
description:
- Value of the key written to
required: true
type:
description:
- Type of the key
choices: [text, url, json]
default: text
requirements:
- "python >= 2.6"
@@ -57,4 +61,15 @@ EXAMPLES = '''
- ara_record:
key: "git_version"
value: "{{ git_version.stdout }}"
# Write data with a type (otherwise defaults to "text")
# This changes the behavior on how the value is presented in the web interface
- ara_record:
key: "{{ item.key }}"
value: "{{ item.value }}"
type: "{{ item.type }}"
with_items:
- { key: "log", value: "error", type: "text" }
- { key: "website", value: "http://domain.tld", type: "url" }
- { key: "data", value: "{ 'key': 'value' }", type: "json" }
'''