2015-03-02 21:25:41 +01:00
|
|
|
# test code for the template module
|
|
|
|
# (c) 2014, Michael DeHaan <michael.dehaan@gmail.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: fill in a basic template in check mode
|
2016-07-23 02:40:14 +02:00
|
|
|
template: src=foo.j2 dest={{output_dir}}/checkmode_foo.templated mode=0644
|
2015-03-02 21:25:41 +01:00
|
|
|
register: template_result
|
|
|
|
|
2016-07-23 02:40:14 +02:00
|
|
|
- name: check whether file exists
|
|
|
|
stat: path={{output_dir}}/checkmode_foo.templated
|
|
|
|
register: foo
|
|
|
|
|
2015-03-02 21:25:41 +01:00
|
|
|
- name: verify that the file was marked as changed in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2016-07-23 02:40:14 +02:00
|
|
|
- "template_result|changed"
|
|
|
|
- "not foo.stat.exists"
|
2015-03-02 21:25:41 +01:00
|
|
|
|
2016-07-23 02:40:14 +02:00
|
|
|
- name: Actually create the file, disable check mode
|
|
|
|
template: src=foo.j2 dest={{output_dir}}/checkmode_foo.templated2 mode=0644
|
|
|
|
check_mode: no
|
|
|
|
register: checkmode_disabled
|
2015-03-02 21:25:41 +01:00
|
|
|
|
2016-07-23 02:40:14 +02:00
|
|
|
- name: fill in template with new content
|
|
|
|
template: src=foo.j2 dest={{output_dir}}/checkmode_foo.templated2 mode=0644
|
2015-03-02 21:25:41 +01:00
|
|
|
register: template_result2
|
|
|
|
|
2016-07-23 02:40:14 +02:00
|
|
|
- name: verify that the file was not changed
|
2015-03-02 21:25:41 +01:00
|
|
|
assert:
|
|
|
|
that:
|
2016-07-23 02:40:14 +02:00
|
|
|
- "checkmode_disabled|changed"
|
|
|
|
- "not template_result2|changed"
|