2012-03-18 22:29:11 +00:00
|
|
|
# extremely simple test of the most basic of playbook engine/functions
|
|
|
|
---
|
|
|
|
- hosts: all
|
2012-03-24 00:51:15 +00:00
|
|
|
|
2012-08-07 01:00:21 +00:00
|
|
|
# the 'weasels' string should show up in the output
|
2012-03-24 00:51:15 +00:00
|
|
|
|
2012-03-18 22:29:11 +00:00
|
|
|
vars:
|
2012-03-18 23:50:22 +00:00
|
|
|
answer: "Wuh, I think so, Brain, but if we didn't have ears, we'd look like weasels."
|
2012-03-18 22:29:11 +00:00
|
|
|
port: 5150
|
2012-03-24 00:51:15 +00:00
|
|
|
|
|
|
|
# we should have import events for common_vars and CentOS.yml (if run on CentOS)
|
|
|
|
# sorry, tests are a bit platform specific just for now
|
|
|
|
|
2012-03-20 02:42:31 +00:00
|
|
|
vars_files:
|
|
|
|
- common_vars.yml
|
|
|
|
- [ '$facter_operatingsystem.yml', 'default_os.yml' ]
|
2012-08-07 01:00:21 +00:00
|
|
|
|
2012-03-18 22:29:11 +00:00
|
|
|
tasks:
|
|
|
|
|
|
|
|
- name: test basic success command
|
2012-07-30 01:59:29 +00:00
|
|
|
action: command true
|
2012-03-18 22:29:11 +00:00
|
|
|
|
|
|
|
- name: test basic success command 2
|
2012-07-30 01:59:29 +00:00
|
|
|
action: command true
|
2012-03-18 22:29:11 +00:00
|
|
|
|
2012-03-19 23:32:38 +00:00
|
|
|
- name: test basic shell, plus two ways to dereference a variable
|
|
|
|
action: shell echo $HOME $port {{ port }}
|
2012-03-18 22:29:11 +00:00
|
|
|
|
2012-03-20 02:42:31 +00:00
|
|
|
- name: test vars_files imports
|
|
|
|
action: shell echo $duck $cow $testing
|
|
|
|
|
2012-03-18 23:25:56 +00:00
|
|
|
# in the command below, the test file should contain a valid template
|
|
|
|
# and trigger the change handler
|
|
|
|
|
2012-03-18 22:29:11 +00:00
|
|
|
- name: test copy
|
2012-03-18 22:50:25 +00:00
|
|
|
action: copy src=sample.j2 dest=/tmp/ansible_test_data_copy.out
|
2012-08-07 01:00:21 +00:00
|
|
|
notify:
|
2012-03-18 23:25:56 +00:00
|
|
|
- on change 1
|
|
|
|
|
|
|
|
# this should trigger two change handlers, but the 2nd should
|
|
|
|
# not be triggered twice because it's already triggered
|
2012-03-18 22:29:11 +00:00
|
|
|
|
|
|
|
- name: test template
|
2012-11-06 19:57:35 +00:00
|
|
|
action: template src=$item dest=/tmp/ansible_test_data_template.out
|
|
|
|
first_available_file:
|
|
|
|
- nonexistantfile
|
|
|
|
- sample.j2
|
2012-08-07 01:00:21 +00:00
|
|
|
notify:
|
2012-03-18 23:25:56 +00:00
|
|
|
- on change 1
|
|
|
|
- on change 2
|
|
|
|
|
|
|
|
# there should be various poll events within the range
|
|
|
|
|
|
|
|
- name: async poll test
|
|
|
|
action: shell sleep 5
|
|
|
|
async: 10
|
|
|
|
poll: 3
|
2012-03-18 22:29:11 +00:00
|
|
|
|
2012-03-24 00:51:15 +00:00
|
|
|
# the following command should be skipped
|
|
|
|
|
|
|
|
- name: this should be skipped
|
|
|
|
action: shell echo 'if you see this, this is wrong ($facter_operatingsystem)'
|
|
|
|
only_if: "'$facter_operatingsystem' == 'Imaginary'"
|
|
|
|
|
2012-03-18 22:29:11 +00:00
|
|
|
handlers:
|
|
|
|
|
2012-03-18 23:25:56 +00:00
|
|
|
# in the above test example, this should fire ONCE (at the end)
|
2012-03-18 22:29:11 +00:00
|
|
|
- name: on change 1
|
2012-03-24 00:51:15 +00:00
|
|
|
action: shell echo 'this should fire once'
|
2012-03-18 23:25:56 +00:00
|
|
|
|
|
|
|
# in the above test example, this should fire ONCE (at the end)
|
|
|
|
|
2012-03-18 22:29:11 +00:00
|
|
|
- name: on change 2
|
2012-03-24 00:51:15 +00:00
|
|
|
action: shell echo 'this should fire once also'
|
2012-03-18 23:25:56 +00:00
|
|
|
|
|
|
|
# in the above test example, this should NOT FIRE
|
|
|
|
|
|
|
|
- name: on change 3
|
2012-03-24 00:51:15 +00:00
|
|
|
action: shell echo 'if you see this, this is wrong'
|
2012-03-18 22:29:11 +00:00
|
|
|
|
|
|
|
|