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.
27 lines
581 B
YAML
27 lines
581 B
YAML
3 years ago
|
- hosts: testhost,testhost2
|
||
|
gather_facts: no
|
||
|
tasks:
|
||
|
- set_fact:
|
||
|
module_to_run: 'debug'
|
||
|
when: inventory_hostname == 'testhost'
|
||
|
|
||
|
- set_fact:
|
||
|
module_to_run: 'ping'
|
||
|
when: inventory_hostname == 'testhost2'
|
||
|
|
||
|
- action:
|
||
|
module: '{{ module_to_run }}'
|
||
|
register: out
|
||
|
|
||
|
- assert:
|
||
|
that:
|
||
|
- "'msg' in out"
|
||
|
- "'ping' not in out"
|
||
|
when: inventory_hostname == 'testhost'
|
||
|
|
||
|
- assert:
|
||
|
that:
|
||
|
- "'ping' in out"
|
||
|
- "'msg' not in out"
|
||
|
when: inventory_hostname == 'testhost2'
|