Receptor plugin to communicate with Ansible Tower API
Project description
receptor-catalog
Receptor Catalog Worker Plugin
This plugin allows the receptor node to send HTTP GET and POST requests to Ansible Tower.
The config file on the receptor for this plugin should have the following values defined in the receptor.conf
[plugin_receptor_catalog]
debug=True
username=admin
password=******
url=https://your_ansible_tower/
verify_ssl=False
The payload supported by the plugin contains
- method: GET|POST
- href_slug: the href to the resource or collection e.g api/v2/job_templates/
- accept_encoding {Optional}: gzip
- fetch_all_pages {Optional}: True|False
- params: Extra query or post parameters as a hash/dictionary
- apply_filter {Optional}: A JMESPath search string to limit the amount of data that is returned. The filter can be specified as a hash/dictionary or as a string. The hash is used when filtering responses from a list call when the response contains an array of objects. The string filter is used when dealing with a single object.
The response payload coming back will have the following keys
- status: The HTTP Status code
- body: The response body received from the Ansible Tower if Accept-Encoding was gzip, the body will be compressed and the caller would have to uncompress the data. The first 2 bytes of the payload can be checked to see if the data has been gzip compressed. A valid gzip'ed buffer would start with 0x1f 0x8B
To install the plugin in your local dev environment
python setup.py install
To run the tests
python setup.py test
Filtering Examples
Filters are based on JMESPath which allows us to search and filter out sections of JSON. https://jmespath.org
When fetching an array of objects you have to specific the filter as a dictionary with the key name containing the name of the attribute. e.g apply_filter ={results='results[].{catalog_id:id, url:url,created:created,name:name, modified:modified, playbook:playbook}'}
Here we are filtering the results key so we have to specify the filter as a dictionary. The plugin will swap out the contents of the key with the filtered results. The filtered response will contain
{
"count": 28,
"next": "/api/v2/job_templates/?page=2",
"previous": null,
"results": [
{
"catalog_id": 5,
"url": "/api/v2/job_templates/5/",
"created": "2019-05-29T15:17:05.466994Z",
"name": "Demo Job Template",
"modified": "2019-05-29T15:17:05.467018Z",
"playbook": "hello_world.yml"
},
{
"catalog_id": 58,
"url": "/api/v2/job_templates/58/",
"created": "2020-03-06T21:56:55.134663Z",
"name": "Ephemeral Template",
"modified": "2020-03-06T22:15:15.655800Z",
"playbook": "hello_world.yml"
},
When a single object needs to be filtered we specify the filter as a string
apply_filter = '{id:id, url:url, name:name, description:descripti on, playbook:playbook}'
The response contains
{
"id": 6565,
"url": "/api/v2/jobs/6565/",
"name": "Hello World",
"description": "Test Description",
"playbook": "hello_world.yml"
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file receptor-catalog-0.6.3.tar.gz
.
File metadata
- Download URL: receptor-catalog-0.6.3.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffa10395a4ff13a7b3777288b158f0a75ac6c041873eca8abb8ee5431410ae03 |
|
MD5 | 4a430579d18f7dd9436ab8fa34685d8c |
|
BLAKE2b-256 | 2719b765a87b4ac7b9c01c0ec4dca5e416ce7a793eaee4c928d897f39c30395a |
File details
Details for the file receptor_catalog-0.6.3-py3-none-any.whl
.
File metadata
- Download URL: receptor_catalog-0.6.3-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 549fe94941a9131b704ad381135909df794d4a1857333e95d76e195374bacc0c |
|
MD5 | 4a32fbbb4e994dd31d7a04b1d021018d |
|
BLAKE2b-256 | 52af1f78a29198c4a0aae48c8f4dc85e1bff0776916968de0fac5ae676b0c0e7 |