summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/inventory_constructed
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/inventory_constructed')
-rw-r--r--test/integration/targets/inventory_constructed/aliases1
-rw-r--r--test/integration/targets/inventory_constructed/constructed.yml19
-rw-r--r--test/integration/targets/inventory_constructed/invs/1/group_vars/stuff.yml1
-rw-r--r--test/integration/targets/inventory_constructed/invs/1/host_vars/testing.yml1
-rw-r--r--test/integration/targets/inventory_constructed/invs/1/one.yml5
-rw-r--r--test/integration/targets/inventory_constructed/invs/2/constructed.yml7
-rw-r--r--test/integration/targets/inventory_constructed/keyed_group_default_value.yml5
-rw-r--r--test/integration/targets/inventory_constructed/keyed_group_list_default_value.yml5
-rw-r--r--test/integration/targets/inventory_constructed/keyed_group_str_default_value.yml5
-rw-r--r--test/integration/targets/inventory_constructed/keyed_group_trailing_separator.yml5
-rw-r--r--test/integration/targets/inventory_constructed/no_leading_separator_constructed.yml20
-rwxr-xr-xtest/integration/targets/inventory_constructed/runme.sh59
-rw-r--r--test/integration/targets/inventory_constructed/static_inventory.yml8
-rw-r--r--test/integration/targets/inventory_constructed/tag_inventory.yml12
14 files changed, 153 insertions, 0 deletions
diff --git a/test/integration/targets/inventory_constructed/aliases b/test/integration/targets/inventory_constructed/aliases
new file mode 100644
index 0000000..70a7b7a
--- /dev/null
+++ b/test/integration/targets/inventory_constructed/aliases
@@ -0,0 +1 @@
+shippable/posix/group5
diff --git a/test/integration/targets/inventory_constructed/constructed.yml b/test/integration/targets/inventory_constructed/constructed.yml
new file mode 100644
index 0000000..be02858
--- /dev/null
+++ b/test/integration/targets/inventory_constructed/constructed.yml
@@ -0,0 +1,19 @@
+plugin: ansible.builtin.constructed
+keyed_groups:
+ - key: hostvar0
+ - key: hostvar1
+ - key: hostvar2
+
+ - key: hostvar0
+ separator: 'separator'
+ - key: hostvar1
+ separator: 'separator'
+ - key: hostvar2
+ separator: 'separator'
+
+ - key: hostvar0
+ prefix: 'prefix'
+ - key: hostvar1
+ prefix: 'prefix'
+ - key: hostvar2
+ prefix: 'prefix'
diff --git a/test/integration/targets/inventory_constructed/invs/1/group_vars/stuff.yml b/test/integration/targets/inventory_constructed/invs/1/group_vars/stuff.yml
new file mode 100644
index 0000000..a67b90f
--- /dev/null
+++ b/test/integration/targets/inventory_constructed/invs/1/group_vars/stuff.yml
@@ -0,0 +1 @@
+iamdefined: group4testing
diff --git a/test/integration/targets/inventory_constructed/invs/1/host_vars/testing.yml b/test/integration/targets/inventory_constructed/invs/1/host_vars/testing.yml
new file mode 100644
index 0000000..0ffe382
--- /dev/null
+++ b/test/integration/targets/inventory_constructed/invs/1/host_vars/testing.yml
@@ -0,0 +1 @@
+hola: lola
diff --git a/test/integration/targets/inventory_constructed/invs/1/one.yml b/test/integration/targets/inventory_constructed/invs/1/one.yml
new file mode 100644
index 0000000..ad5a5e0
--- /dev/null
+++ b/test/integration/targets/inventory_constructed/invs/1/one.yml
@@ -0,0 +1,5 @@
+all:
+ children:
+ stuff:
+ hosts:
+ testing:
diff --git a/test/integration/targets/inventory_constructed/invs/2/constructed.yml b/test/integration/targets/inventory_constructed/invs/2/constructed.yml
new file mode 100644
index 0000000..ca26e2c
--- /dev/null
+++ b/test/integration/targets/inventory_constructed/invs/2/constructed.yml
@@ -0,0 +1,7 @@
+plugin: ansible.builtin.constructed
+use_vars_plugins: true
+keyed_groups:
+ - key: iamdefined
+ prefix: c
+ - key: hola
+ prefix: c
diff --git a/test/integration/targets/inventory_constructed/keyed_group_default_value.yml b/test/integration/targets/inventory_constructed/keyed_group_default_value.yml
new file mode 100644
index 0000000..d69e8ec
--- /dev/null
+++ b/test/integration/targets/inventory_constructed/keyed_group_default_value.yml
@@ -0,0 +1,5 @@
+plugin: ansible.builtin.constructed
+keyed_groups:
+ - key: tags
+ prefix: tag
+ default_value: "running"
diff --git a/test/integration/targets/inventory_constructed/keyed_group_list_default_value.yml b/test/integration/targets/inventory_constructed/keyed_group_list_default_value.yml
new file mode 100644
index 0000000..4481db3
--- /dev/null
+++ b/test/integration/targets/inventory_constructed/keyed_group_list_default_value.yml
@@ -0,0 +1,5 @@
+plugin: ansible.builtin.constructed
+keyed_groups:
+ - key: roles
+ default_value: storage
+ prefix: host
diff --git a/test/integration/targets/inventory_constructed/keyed_group_str_default_value.yml b/test/integration/targets/inventory_constructed/keyed_group_str_default_value.yml
new file mode 100644
index 0000000..256d330
--- /dev/null
+++ b/test/integration/targets/inventory_constructed/keyed_group_str_default_value.yml
@@ -0,0 +1,5 @@
+plugin: ansible.builtin.constructed
+keyed_groups:
+ - key: os
+ default_value: "fedora"
+ prefix: host
diff --git a/test/integration/targets/inventory_constructed/keyed_group_trailing_separator.yml b/test/integration/targets/inventory_constructed/keyed_group_trailing_separator.yml
new file mode 100644
index 0000000..d69899d
--- /dev/null
+++ b/test/integration/targets/inventory_constructed/keyed_group_trailing_separator.yml
@@ -0,0 +1,5 @@
+plugin: ansible.builtin.constructed
+keyed_groups:
+ - key: tags
+ prefix: tag
+ trailing_separator: False
diff --git a/test/integration/targets/inventory_constructed/no_leading_separator_constructed.yml b/test/integration/targets/inventory_constructed/no_leading_separator_constructed.yml
new file mode 100644
index 0000000..5ff8f93
--- /dev/null
+++ b/test/integration/targets/inventory_constructed/no_leading_separator_constructed.yml
@@ -0,0 +1,20 @@
+plugin: ansible.builtin.constructed
+keyed_groups:
+ - key: hostvar0
+ - key: hostvar1
+ - key: hostvar2
+
+ - key: hostvar0
+ separator: 'separator'
+ - key: hostvar1
+ separator: 'separator'
+ - key: hostvar2
+ separator: 'separator'
+
+ - key: hostvar0
+ prefix: 'prefix'
+ - key: hostvar1
+ prefix: 'prefix'
+ - key: hostvar2
+ prefix: 'prefix'
+leading_separator: False
diff --git a/test/integration/targets/inventory_constructed/runme.sh b/test/integration/targets/inventory_constructed/runme.sh
new file mode 100755
index 0000000..91bbd66
--- /dev/null
+++ b/test/integration/targets/inventory_constructed/runme.sh
@@ -0,0 +1,59 @@
+#!/usr/bin/env bash
+
+set -eux
+
+ansible-inventory -i static_inventory.yml -i constructed.yml --graph | tee out.txt
+
+grep '@_hostvalue1' out.txt
+grep '@_item0' out.txt
+grep '@_key0_value0' out.txt
+grep '@prefix_hostvalue1' out.txt
+grep '@prefix_item0' out.txt
+grep '@prefix_key0_value0' out.txt
+grep '@separatorhostvalue1' out.txt
+grep '@separatoritem0' out.txt
+grep '@separatorkey0separatorvalue0' out.txt
+
+ansible-inventory -i static_inventory.yml -i no_leading_separator_constructed.yml --graph | tee out.txt
+
+grep '@hostvalue1' out.txt
+grep '@item0' out.txt
+grep '@key0_value0' out.txt
+grep '@key0separatorvalue0' out.txt
+grep '@prefix_hostvalue1' out.txt
+grep '@prefix_item0' out.txt
+grep '@prefix_key0_value0' out.txt
+
+# keyed group with default value for key's value empty (dict)
+ansible-inventory -i tag_inventory.yml -i keyed_group_default_value.yml --graph | tee out.txt
+
+grep '@tag_name_host0' out.txt
+grep '@tag_environment_test' out.txt
+grep '@tag_status_running' out.txt
+
+# keyed group with default value for key's value empty (list)
+ansible-inventory -i tag_inventory.yml -i keyed_group_list_default_value.yml --graph | tee out.txt
+
+grep '@host_db' out.txt
+grep '@host_web' out.txt
+grep '@host_storage' out.txt
+
+# keyed group with default value for key's value empty (str)
+ansible-inventory -i tag_inventory.yml -i keyed_group_str_default_value.yml --graph | tee out.txt
+
+grep '@host_fedora' out.txt
+
+
+# keyed group with 'trailing_separator' set to 'False' for key's value empty
+ansible-inventory -i tag_inventory.yml -i keyed_group_trailing_separator.yml --graph | tee out.txt
+
+grep '@tag_name_host0' out.txt
+grep '@tag_environment_test' out.txt
+grep '@tag_status' out.txt
+
+
+# test using use_vars_plugins
+ansible-inventory -i invs/1/one.yml -i invs/2/constructed.yml --graph | tee out.txt
+
+grep '@c_lola' out.txt
+grep '@c_group4testing' out.txt
diff --git a/test/integration/targets/inventory_constructed/static_inventory.yml b/test/integration/targets/inventory_constructed/static_inventory.yml
new file mode 100644
index 0000000..d050df4
--- /dev/null
+++ b/test/integration/targets/inventory_constructed/static_inventory.yml
@@ -0,0 +1,8 @@
+all:
+ hosts:
+ host0:
+ hostvar0:
+ key0: value0
+ hostvar1: hostvalue1
+ hostvar2:
+ - item0
diff --git a/test/integration/targets/inventory_constructed/tag_inventory.yml b/test/integration/targets/inventory_constructed/tag_inventory.yml
new file mode 100644
index 0000000..acf810e
--- /dev/null
+++ b/test/integration/targets/inventory_constructed/tag_inventory.yml
@@ -0,0 +1,12 @@
+all:
+ hosts:
+ host0:
+ tags:
+ name: "host0"
+ environment: "test"
+ status: ""
+ os: ""
+ roles:
+ - db
+ - web
+ - ""