summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/group_by
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/group_by')
-rw-r--r--test/integration/targets/group_by/aliases1
-rw-r--r--test/integration/targets/group_by/create_groups.yml39
-rw-r--r--test/integration/targets/group_by/group_vars/all3
-rw-r--r--test/integration/targets/group_by/group_vars/camelus1
-rw-r--r--test/integration/targets/group_by/group_vars/vicugna1
-rw-r--r--test/integration/targets/group_by/inventory.group_by9
-rwxr-xr-xtest/integration/targets/group_by/runme.sh6
-rw-r--r--test/integration/targets/group_by/test_group_by.yml187
-rw-r--r--test/integration/targets/group_by/test_group_by_skipped.yml30
9 files changed, 277 insertions, 0 deletions
diff --git a/test/integration/targets/group_by/aliases b/test/integration/targets/group_by/aliases
new file mode 100644
index 0000000..765b70d
--- /dev/null
+++ b/test/integration/targets/group_by/aliases
@@ -0,0 +1 @@
+shippable/posix/group2
diff --git a/test/integration/targets/group_by/create_groups.yml b/test/integration/targets/group_by/create_groups.yml
new file mode 100644
index 0000000..3494a20
--- /dev/null
+++ b/test/integration/targets/group_by/create_groups.yml
@@ -0,0 +1,39 @@
+# test code for the group_by module
+# (c) 2014, Chris Church <cchurch@ansible.com>
+
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+- debug: var=genus
+
+- name: group by genus
+ group_by: key={{ genus }}
+ register: grouped_by_genus
+
+- debug: var=grouped_by_genus
+
+- name: ensure we reflect 'changed' on change
+ assert:
+ that:
+ - grouped_by_genus is changed
+
+- name: group by first three letters of genus with key in quotes
+ group_by: key="{{ genus[:3] }}"
+
+- name: group by first two letters of genus with key not in quotes
+ group_by: key={{ genus[:2] }}
+
+- name: group by genus in uppercase using complex args
+ group_by: { key: "{{ genus | upper() }}" }
diff --git a/test/integration/targets/group_by/group_vars/all b/test/integration/targets/group_by/group_vars/all
new file mode 100644
index 0000000..0b674e0
--- /dev/null
+++ b/test/integration/targets/group_by/group_vars/all
@@ -0,0 +1,3 @@
+uno: 1
+dos: 2
+tres: 3
diff --git a/test/integration/targets/group_by/group_vars/camelus b/test/integration/targets/group_by/group_vars/camelus
new file mode 100644
index 0000000..b214ad6
--- /dev/null
+++ b/test/integration/targets/group_by/group_vars/camelus
@@ -0,0 +1 @@
+dos: 'two'
diff --git a/test/integration/targets/group_by/group_vars/vicugna b/test/integration/targets/group_by/group_vars/vicugna
new file mode 100644
index 0000000..8feb93f
--- /dev/null
+++ b/test/integration/targets/group_by/group_vars/vicugna
@@ -0,0 +1 @@
+tres: 'three'
diff --git a/test/integration/targets/group_by/inventory.group_by b/test/integration/targets/group_by/inventory.group_by
new file mode 100644
index 0000000..9c7fe7e
--- /dev/null
+++ b/test/integration/targets/group_by/inventory.group_by
@@ -0,0 +1,9 @@
+# ungrouped
+camel genus=camelus ansible_connection=local
+
+[lamini]
+alpaca genus=vicugna
+llama genus=lama
+
+[lamini:vars]
+ansible_connection=local
diff --git a/test/integration/targets/group_by/runme.sh b/test/integration/targets/group_by/runme.sh
new file mode 100755
index 0000000..d119268
--- /dev/null
+++ b/test/integration/targets/group_by/runme.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+set -eux
+
+ansible-playbook test_group_by.yml -i inventory.group_by -v "$@"
+ANSIBLE_HOST_PATTERN_MISMATCH=warning ansible-playbook test_group_by_skipped.yml -i inventory.group_by -v "$@"
diff --git a/test/integration/targets/group_by/test_group_by.yml b/test/integration/targets/group_by/test_group_by.yml
new file mode 100644
index 0000000..07368df
--- /dev/null
+++ b/test/integration/targets/group_by/test_group_by.yml
@@ -0,0 +1,187 @@
+# test code for the group_by module
+# (c) 2014, Chris Church <cchurch@ansible.com>
+
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+- name: Create overall groups
+ hosts: all
+ gather_facts: false
+ tasks:
+ - include_tasks: create_groups.yml
+
+- name: Vicunga group validation
+ hosts: vicugna
+ gather_facts: false
+ tasks:
+ - name: verify that only the alpaca is in this group
+ assert: { that: "inventory_hostname == 'alpaca'" }
+ - name: set a fact to check that we ran this play
+ set_fact: genus_vicugna=true
+
+- name: Lama group validation
+ hosts: lama
+ gather_facts: false
+ tasks:
+ - name: verify that only the llama is in this group
+ assert: { that: "inventory_hostname == 'llama'" }
+ - name: set a fact to check that we ran this play
+ set_fact: genus_lama=true
+
+- name: Camelus group validation
+ hosts: camelus
+ gather_facts: false
+ tasks:
+ - name: verify that only the camel is in this group
+ assert: { that: "inventory_hostname == 'camel'" }
+ - name: set a fact to check that we ran this play
+ set_fact: genus_camelus=true
+
+- name: Vic group validation
+ hosts: vic
+ gather_facts: false
+ tasks:
+ - name: verify that only the alpaca is in this group
+ assert: { that: "inventory_hostname == 'alpaca'" }
+ - name: set a fact to check that we ran this play
+ set_fact: genus_vic=true
+
+- name: Lam group validation
+ hosts: lam
+ gather_facts: false
+ tasks:
+ - name: verify that only the llama is in this group
+ assert: { that: "inventory_hostname == 'llama'" }
+ - name: set a fact to check that we ran this play
+ set_fact: genus_lam=true
+
+- name: Cam group validation
+ hosts: cam
+ gather_facts: false
+ tasks:
+ - name: verify that only the camel is in this group
+ assert: { that: "inventory_hostname == 'camel'" }
+ - name: set a fact to check that we ran this play
+ set_fact: genus_cam=true
+
+- name: Vi group validation
+ hosts: vi
+ gather_facts: false
+ tasks:
+ - name: verify that only the alpaca is in this group
+ assert: { that: "inventory_hostname == 'alpaca'" }
+ - name: set a fact to check that we ran this play
+ set_fact: genus_vi=true
+
+- name: La group validation
+ hosts: la
+ gather_facts: false
+ tasks:
+ - name: verify that only the llama is in this group
+ assert: { that: "inventory_hostname == 'llama'" }
+ - name: set a fact to check that we ran this play
+ set_fact: genus_la=true
+
+- name: Ca group validation
+ hosts: ca
+ gather_facts: false
+ tasks:
+ - name: verify that only the camel is in this group
+ assert: { that: "inventory_hostname == 'camel'" }
+ - name: set a fact to check that we ran this play
+ set_fact: genus_ca=true
+
+- name: VICUGNA group validation
+ hosts: VICUGNA
+ gather_facts: false
+ tasks:
+ - name: verify that only the alpaca is in this group
+ assert: { that: "inventory_hostname == 'alpaca'" }
+ - name: set a fact to check that we ran this play
+ set_fact: genus_VICUGNA=true
+
+- name: LAMA group validation
+ hosts: LAMA
+ gather_facts: false
+ tasks:
+ - name: verify that only the llama is in this group
+ assert: { that: "inventory_hostname == 'llama'" }
+ - name: set a fact to check that we ran this play
+ set_fact: genus_LAMA=true
+
+- name: CAMELUS group validation
+ hosts: CAMELUS
+ gather_facts: false
+ tasks:
+ - name: verify that only the camel is in this group
+ assert: { that: "inventory_hostname == 'camel'" }
+ - name: set a fact to check that we ran this play
+ set_fact: genus_CAMELUS=true
+
+- name: alpaca validation of groups
+ hosts: alpaca
+ gather_facts: false
+ tasks:
+ - name: check that alpaca matched all four groups
+ assert: { that: ["genus_vicugna", "genus_vic", "genus_vi", "genus_VICUGNA"] }
+
+- name: llama validation of groups
+ hosts: llama
+ gather_facts: false
+ tasks:
+ - name: check that llama matched all four groups
+ assert: { that: ["genus_lama", "genus_lam", "genus_la", "genus_LAMA"] }
+
+- hosts: camel
+ gather_facts: false
+ tasks:
+ - name: check that camel matched all four groups
+ assert: { that: ["genus_camelus", "genus_cam", "genus_ca", "genus_CAMELUS"] }
+
+- hosts: vicugna
+ gather_facts: false
+ tasks:
+ - name: check group_vars variable overrides for vicugna
+ assert: { that: ["uno == 1", "dos == 2", "tres == 'three'"] }
+
+- hosts: lama
+ gather_facts: false
+ tasks:
+ - name: check group_vars variable overrides for lama
+ assert: { that: ["uno == 1", "dos == 2", "tres == 3"] }
+
+- hosts: camelus
+ gather_facts: false
+ tasks:
+ - name: check group_vars variable overrides for camelus
+ assert: { that: ["uno == 1", "dos == 'two'", "tres == 3"] }
+
+- name: Nested group validation
+ hosts: lama
+ gather_facts: false
+ tasks:
+ - name: group by genus with parent
+ group_by: key=vicugna-{{ genus }} parents=vicugna
+ - name: check group_vars variable overrides for vicugna-lama
+ assert: { that: ["uno == 1", "dos == 2", "tres == 'three'"] }
+
+ - name: group by genus with nonexistent parent
+ group_by:
+ key: "{{ genus }}"
+ parents:
+ - oxydactylus
+ - stenomylus
+ - name: check parent groups
+ assert: { that: ["'oxydactylus' in group_names", "'stenomylus' in group_names"] }
diff --git a/test/integration/targets/group_by/test_group_by_skipped.yml b/test/integration/targets/group_by/test_group_by_skipped.yml
new file mode 100644
index 0000000..6c18b4e
--- /dev/null
+++ b/test/integration/targets/group_by/test_group_by_skipped.yml
@@ -0,0 +1,30 @@
+# test code for the group_by module
+# (c) 2014, Chris Church <cchurch@ansible.com>
+
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+- name: Create overall groups
+ hosts: all
+ gather_facts: false
+ tasks:
+ - include_tasks: create_groups.yml
+
+- name: genus group validation (expect skipped)
+ hosts: 'genus'
+ gather_facts: false
+ tasks:
+ - name: no hosts should match this group
+ fail: msg="should never get here"