mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
128 lines
4.0 KiB
YAML
128 lines
4.0 KiB
YAML
11 years ago
|
# 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/>.
|
||
|
|
||
10 years ago
|
- name: Create overall groups
|
||
|
hosts: lamini
|
||
11 years ago
|
gather_facts: false
|
||
|
tasks:
|
||
10 years ago
|
- debug: var=genus
|
||
11 years ago
|
- name: group by genus
|
||
|
group_by: key={{ genus }}
|
||
10 years ago
|
|
||
11 years ago
|
- name: group by first three letters of genus with key in quotes
|
||
|
group_by: key="{{ genus | truncate(3, true, '') }}"
|
||
10 years ago
|
|
||
11 years ago
|
- name: group by first two letters of genus with key not in quotes
|
||
|
group_by: key={{ genus | truncate(2, true, '') }}
|
||
10 years ago
|
|
||
11 years ago
|
- name: group by genus in uppercase using complex args
|
||
|
group_by: { key: "{{ genus | upper() }}" }
|
||
|
|
||
10 years ago
|
- name: Vicunga group validation
|
||
|
hosts: vicugna
|
||
11 years ago
|
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
|
||
|
|
||
10 years ago
|
- name: Lama group validation
|
||
|
hosts: lama
|
||
11 years ago
|
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
|
||
|
|
||
10 years ago
|
- name: Vic group validation
|
||
|
hosts: vic
|
||
11 years ago
|
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
|
||
|
|
||
10 years ago
|
- name: Lam group validation
|
||
|
hosts: lam
|
||
11 years ago
|
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
|
||
|
|
||
10 years ago
|
- name: Vi group validation
|
||
|
hosts: vi
|
||
11 years ago
|
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
|
||
|
|
||
10 years ago
|
- name: La group validation
|
||
|
hosts: la
|
||
11 years ago
|
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
|
||
|
|
||
10 years ago
|
- name: VICUGNA group validation
|
||
|
hosts: VICUGNA
|
||
11 years ago
|
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
|
||
|
|
||
10 years ago
|
- name: LAMA group validation
|
||
|
hosts: LAMA
|
||
11 years ago
|
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
|
||
|
|
||
10 years ago
|
- name: genus group validation (expect skipped)
|
||
|
hosts: 'genus'
|
||
11 years ago
|
gather_facts: false
|
||
|
tasks:
|
||
|
- name: no hosts should match this group
|
||
|
fail: msg="should never get here"
|
||
|
|
||
10 years ago
|
- name: alpaca validation of groups
|
||
|
hosts: alpaca
|
||
11 years ago
|
gather_facts: false
|
||
|
tasks:
|
||
|
- name: check that alpaca matched all four groups
|
||
|
assert: { that: ["genus_vicugna", "genus_vic", "genus_vi", "genus_VICUGNA"] }
|
||
|
|
||
10 years ago
|
- name: llama validation of groups
|
||
|
hosts: llama
|
||
11 years ago
|
gather_facts: false
|
||
|
tasks:
|
||
|
- name: check that llama matched all four groups
|
||
|
assert: { that: ["genus_lama", "genus_lam", "genus_la", "genus_LAMA"] }
|