summaryrefslogtreecommitdiff
path: root/test/integration/targets
diff options
context:
space:
mode:
authorabikouo <79859644+abikouo@users.noreply.github.com>2021-04-13 17:59:50 +0200
committerGitHub <noreply@github.com>2021-04-13 11:59:50 -0400
commit29aea9ff3466e4cd2ed00524b9e56738d568ce8b (patch)
tree0b85b70e255c781d181f431ac13d7c8262f20cef /test/integration/targets
parent270f109bb3af5c2498725b384f77ddc26da2fb73 (diff)
downloadansible-29aea9ff3466e4cd2ed00524b9e56738d568ce8b.tar.gz
constructed - Add keyed_groups suboptions 'default_value' and 'trailing_separator' (#74005)
* Support omitting the trailing separator when a dictionary key's value is an empty string * Support a default value when the value used in the group name is an empty string * Add tests * change log
Diffstat (limited to 'test/integration/targets')
-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
-rwxr-xr-xtest/integration/targets/inventory_constructed/runme.sh29
-rw-r--r--test/integration/targets/inventory_constructed/tag_inventory.yml12
6 files changed, 60 insertions, 1 deletions
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 0000000000..e4d0a76b7e
--- /dev/null
+++ b/test/integration/targets/inventory_constructed/keyed_group_default_value.yml
@@ -0,0 +1,5 @@
+plugin: 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 0000000000..1c2d00e06e
--- /dev/null
+++ b/test/integration/targets/inventory_constructed/keyed_group_list_default_value.yml
@@ -0,0 +1,5 @@
+plugin: constructed
+keyed_groups:
+ - key: roles
+ default_value: storage
+ prefix: host \ No newline at end of file
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 0000000000..ae3fd5ae39
--- /dev/null
+++ b/test/integration/targets/inventory_constructed/keyed_group_str_default_value.yml
@@ -0,0 +1,5 @@
+plugin: constructed
+keyed_groups:
+ - key: os
+ default_value: "fedora"
+ prefix: host \ No newline at end of file
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 0000000000..cbe57c6098
--- /dev/null
+++ b/test/integration/targets/inventory_constructed/keyed_group_trailing_separator.yml
@@ -0,0 +1,5 @@
+plugin: constructed
+keyed_groups:
+ - key: tags
+ prefix: tag
+ trailing_separator: False
diff --git a/test/integration/targets/inventory_constructed/runme.sh b/test/integration/targets/inventory_constructed/runme.sh
index 0cd1a29311..91bbd66bde 100755
--- a/test/integration/targets/inventory_constructed/runme.sh
+++ b/test/integration/targets/inventory_constructed/runme.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-set -ex
+set -eux
ansible-inventory -i static_inventory.yml -i constructed.yml --graph | tee out.txt
@@ -24,6 +24,33 @@ 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
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 0000000000..acf810ea21
--- /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
+ - ""