2014-02-20 00:05:35 +01:00
|
|
|
- name: install the test daemon script
|
|
|
|
copy: src=ansible_test_service dest=/usr/sbin/ansible_test_service mode=755
|
|
|
|
register: install_result
|
|
|
|
|
|
|
|
- name: assert that the daemon script was installed
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "install_result.dest == '/usr/sbin/ansible_test_service'"
|
2014-11-07 06:28:04 +01:00
|
|
|
- "install_result.checksum == 'baaa79448a976922c080f1971321d203c6df0961'"
|
2014-02-20 00:05:35 +01:00
|
|
|
- "install_result.state == 'file'"
|
|
|
|
- "install_result.mode == '0755'"
|
|
|
|
|
|
|
|
- include: 'sysv_setup.yml'
|
2014-03-06 22:16:00 +01:00
|
|
|
when: ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux']
|
2014-02-20 00:05:35 +01:00
|
|
|
- include: 'systemd_setup.yml'
|
|
|
|
when: ansible_distribution == 'Fedora'
|
|
|
|
- include: 'upstart_setup.yml'
|
|
|
|
when: ansible_distribution == 'Ubuntu'
|
|
|
|
|
|
|
|
- name: enable the ansible test service
|
|
|
|
service: name=ansible_test enabled=yes
|
|
|
|
register: enable_result
|
|
|
|
|
|
|
|
- name: assert that the service was enabled
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "enable_result.enabled == true"
|
|
|
|
|
|
|
|
- name: start the ansible test service
|
|
|
|
service: name=ansible_test state=started
|
|
|
|
register: start_result
|
|
|
|
|
|
|
|
- name: assert that the service was started
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "start_result.state == 'started'"
|
|
|
|
|
|
|
|
- name: find the service with a pattern
|
|
|
|
service: name=ansible_test pattern="ansible_test_ser*" state=started
|
|
|
|
register: start2_result
|
|
|
|
|
|
|
|
- name: assert that the service was started via the pattern
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "start2_result.name == 'ansible_test'"
|
|
|
|
- "start2_result.state == 'started'"
|
|
|
|
|
|
|
|
- name: restart the ansible test service
|
|
|
|
service: name=ansible_test state=restarted
|
|
|
|
register: restart_result
|
|
|
|
|
|
|
|
- name: assert that the service was restarted
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "restart_result.state == 'started'"
|
|
|
|
|
|
|
|
- name: restart the ansible test service with a sleep
|
|
|
|
service: name=ansible_test state=restarted sleep=2
|
|
|
|
register: restart_sleep_result
|
|
|
|
|
|
|
|
- name: assert that the service was restarted with a sleep
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "restart_sleep_result.state == 'started'"
|
|
|
|
|
|
|
|
- name: reload the ansible test service
|
|
|
|
service: name=ansible_test state=reloaded
|
|
|
|
register: reload_result
|
|
|
|
|
|
|
|
- name: assert that the service was reloaded
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "reload_result.state == 'started'"
|
|
|
|
|
|
|
|
- name: stop the ansible test service
|
|
|
|
service: name=ansible_test state=stopped
|
|
|
|
register: stop_result
|
|
|
|
|
|
|
|
- name: assert that the service was stopped
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "stop_result.state == 'stopped'"
|
|
|
|
|
|
|
|
- name: disable the ansible test service
|
|
|
|
service: name=ansible_test enabled=no
|
|
|
|
register: disable_result
|
|
|
|
|
|
|
|
- name: assert that the service was disabled
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "disable_result.enabled == false"
|
|
|
|
|
2014-09-18 21:39:54 +02:00
|
|
|
- name: try to enable a broken service
|
2014-09-18 22:18:31 +02:00
|
|
|
service: name=ansible_broken_test enabled=yes
|
2014-09-18 21:39:54 +02:00
|
|
|
register: broken_enable_result
|
|
|
|
ignore_errors: True
|
|
|
|
|
|
|
|
- name: assert that the broken test failed
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "broken_enable_result.failed == True"
|
|
|
|
|
2014-02-20 00:05:35 +01:00
|
|
|
- name: remove the test daemon script
|
|
|
|
file: path=/usr/sbin/ansible_test_service state=absent
|
|
|
|
register: remove_result
|
|
|
|
|
|
|
|
- name: assert that the test daemon script was removed
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "remove_result.path == '/usr/sbin/ansible_test_service'"
|
|
|
|
- "remove_result.state == 'absent'"
|
|
|
|
|
|
|
|
- include: 'sysv_cleanup.yml'
|
2014-03-06 22:16:00 +01:00
|
|
|
when: ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux']
|
2014-02-20 00:05:35 +01:00
|
|
|
- include: 'systemd_cleanup.yml'
|
|
|
|
when: ansible_distribution == 'Fedora'
|
|
|
|
- include: 'upstart_cleanup.yml'
|
|
|
|
when: ansible_distribution == 'Ubuntu'
|