This repo contains the derjd.general
collection. You'll find several plugins in this collection
that aren't part of the community.general collection
and aren't part of more specialized collections as well.
- python >= 3
- python-requests
- python-lxml
- ansible >= 2.9
You can use this collection simply by installing it with ansible-galaxy
:
ansible-galaxy collection install derjd.general
If you are using requirement.yml files for downloading collections and roles, add these lines:
collections:
- derjd.general
Converts nested, human readable, dicts into list of dicts, that are easily parsable by ansible loops.
---
- hosts: localhost
gather_facts: false
vars:
ini_vars:
ima_1_section:
ima_1_option: ima_1_value
ima_2_option: ima_2_value
ima_2_section:
ima_3_option: ima_3_value
ima_4_option: ima_4_value
tasks:
- name: edit /tmp/test.ini file
ini_file:
path: /tmp/test.ini
section: "{{ item.section }}"
option: "{{ item.option }}"
value: "{{ item.value }}"
loop: "{{ ini_vars | derjd.general.dict2ini }}"
Reads json inventories from any HTTP(s) source. The hosted inventory json file must comply with the new inventory script convention, containing the top level _meta
element with hostvars
inside and all groups
with children
and hosts
.
This inventory plugin should be detected by ansible's auto inventory plugin
as soon as an inventory is specified that ends on http_inventory.yml
or http_inventory.yaml
.
Example:
Inventory hosted on a plain webserver without authentication.
web.http_inventory.yml
:
plugin: derjd.general.http
url: https://example.io/example_inventories/dev/inventory.json
ansible-inventory -i web.http_inventory.yml --graph
@all:
|--@devstack:
| |--@api:
| | |--api01ve.devstack
[...]
Inventory hosted on gitlab pages and authentication enabled.
gitlab_pages.http_inventory.yml
:
plugin: derjd.general.http
url: https://example.gitlab.io/example_inventories/dev/inventory.json
auth_method: gitlab
export HTTP_USERNAME=example_USERNAME
export HTTP_PASSWORD=example_PASSWORD
ansible-inventory -i gitlab_pages.http_inventory.yml --graph
@all:
|--@devstack:
| |--@api:
| | |--api01ve.devstack
[...]
- Code released under GNU General Public License v3.0 or later