Skip to content

Commit

Permalink
Add composite inventory plugin (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyphreak authored Jan 21, 2025
1 parent 8a18d88 commit 514df13
Show file tree
Hide file tree
Showing 23 changed files with 585 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
matrix:
scenario:
- filter
- composite
steps:
- name: Check out the codebase
uses: actions/checkout@v4
Expand Down
6 changes: 3 additions & 3 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,10 @@ max-attributes=7
max-bool-expr=5

# Maximum number of branch for function / method body.
max-branches=16
max-branches=30

# Maximum number of locals for function / method body.
max-locals=15
max-locals=30

# Maximum number of parents for a class (see R0901).
max-parents=7
Expand All @@ -309,7 +309,7 @@ max-public-methods=20
max-returns=6

# Maximum number of statements in function / method body.
max-statements=50
max-statements=100

# Minimum number of public methods for a class (see R0903).
min-public-methods=1
Expand Down
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: nephelaiio
name: plugins
version: 0.0.11
version: 0.1.0
readme: README.md
authors:
- Ted Cook <[email protected]>
Expand Down
7 changes: 7 additions & 0 deletions molecule/composite/inventory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
plugin: nephelaiio.plugins.composite
inventories:
- file: primary
prefix: primary
- file: secondary
prefix: secondary
25 changes: 25 additions & 0 deletions molecule/composite/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
dependency:
name: galaxy
options:
role-file: requirements.yml
requirements-file: requirements.yml
driver:
name: default
platforms:
- name: localhost
provisioner:
name: ansible
config_options:
inventory:
enable_plugins: nephelaiio.plugins.composite, ansible.builtin.yaml, ansible.builtin.auto, ansible.builtin.constructed
unparsed_is_failed: true
defaults:
callbacks_enabled: ansible.posix.profile_tasks
inventory:
links:
hosts: inventory.yml
playbooks:
verify: ./verify.yml
verifier:
name: ansible
2 changes: 2 additions & 0 deletions molecule/composite/primary/group_vars/all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
inventory_name: "primary"
2 changes: 2 additions & 0 deletions molecule/composite/primary/group_vars/first_level/vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
group_name: "first_level"
2 changes: 2 additions & 0 deletions molecule/composite/primary/group_vars/level_a.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
construct_id: a
2 changes: 2 additions & 0 deletions molecule/composite/primary/group_vars/level_b.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
construct_id: b
3 changes: 3 additions & 0 deletions molecule/composite/primary/group_vars/second_level/vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
group_name: second_level
private_id: primary_second_level
3 changes: 3 additions & 0 deletions molecule/composite/primary/group_vars/third_level.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
group_name: third_level
private_id: primary_third_level
2 changes: 2 additions & 0 deletions molecule/composite/primary/host_vars/pri_second_level_a.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
host_id: pri_second_level_a
2 changes: 2 additions & 0 deletions molecule/composite/primary/host_vars/pri_third_level_a.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
host_id: overridden
51 changes: 51 additions & 0 deletions molecule/composite/primary/hosts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
all:
vars:
inventory_global_id: molecule
inventory_id: primary
hosts:
pri_first_level_a:
ansible_host: 10.0.0.1
alias: first_a
pri_first_level_b:
ansible_host: 10.0.0.2
alias: first_b
pri_second_level_a:
ansible_host: 10.0.1.1
alias: second_a
pri_second_level_b:
ansible_host: 10.0.1.2
alias: second_b
pri_third_level_a:
ansible_host: 10.0.2.1
host_id: pri_third_level_a
pri_third_level_b:
ansible_host: 10.0.2.2
host_id: pri_third_level_b

select_levels:
vars:
group_id: primary_select_levels
children:
first_level:
second_level:

first_level:
hosts:
pri_first_level_a:
pri_first_level_b:

second_level:
hosts:
pri_second_level_a:
pri_second_level_b:

third_level:
hosts:
pri_third_level_a:
pri_third_level_b:

private_level:
children:
first_level:
third_level:
6 changes: 6 additions & 0 deletions molecule/composite/primary/zzconstructed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
plugin: constructed
strict: true
groups:
level_a: inventory_hostname is regex('.*level_a$')
level_b: inventory_hostname is regex('.*level_b$')
39 changes: 39 additions & 0 deletions molecule/composite/secondary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
all:
hosts:
snd_first_level_a:
ansible_host: 10.0.0.1
alias: first_a
snd_first_level_b:
ansible_host: 10.0.0.2
alias: first_b
snd_second_level_a:
ansible_host: 10.0.1.1
alias: second_a
snd_second_level_b:
ansible_host: 10.0.1.2
alias: second_b
snd_third_level_a:
ansible_host: 10.0.2.1
snd_third_level_b:
ansible_host: 10.0.2.2

select_levels:
children:
first_level:
second_level:

first_level:
hosts:
snd_first_level_a:
snd_first_level_b:

second_level:
hosts:
snd_second_level_a:
snd_second_level_b:

third_level:
hosts:
snd_third_level_a:
snd_third_level_b:
2 changes: 2 additions & 0 deletions molecule/composite/secondary/group_vars/all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
inventory_name: secondary
3 changes: 3 additions & 0 deletions molecule/composite/secondary/group_vars/first_level/vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
group_name: first_level
host_id: default
2 changes: 2 additions & 0 deletions molecule/composite/secondary/group_vars/second_level/vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
group_name: second_level
3 changes: 3 additions & 0 deletions molecule/composite/secondary/group_vars/third_level.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
group_name: third_level
private_id: secondary_third_level
46 changes: 46 additions & 0 deletions molecule/composite/secondary/hosts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
all:
vars:
inventory_global_id: molecule
inventory_id: secondary
hosts:
snd_first_level_a:
ansible_host: 10.0.0.1
alias: first_a
host_id: snd_first_level_a
snd_first_level_b:
ansible_host: 10.0.0.2
alias: first_b
host_id: snd_first_level_b
snd_second_level_a:
ansible_host: 10.0.1.1
alias: second_a
snd_second_level_b:
ansible_host: 10.0.1.2
alias: second_b
snd_third_level_a:
ansible_host: 10.0.2.1
snd_third_level_b:
ansible_host: 10.0.2.2

select_levels:
vars:
group_id: secondary_select_levels
children:
first_level:
second_level:

first_level:
hosts:
snd_first_level_a:
snd_first_level_b:

second_level:
hosts:
snd_second_level_a:
snd_second_level_b:

third_level:
hosts:
snd_third_level_a:
snd_third_level_b:
Loading

0 comments on commit 514df13

Please sign in to comment.