PageRenderTime 17ms CodeModel.GetById 12ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/test/integration/roles/test_template/tasks/main.yml

https://github.com/ajanthanm/ansible
YAML | 66 lines | 36 code | 12 blank | 18 comment | 0 complexity | df3f1689bfad05ef21c72e828905c45a MD5 | raw file
 1# test code for the template module
 2# (c) 2014, Michael DeHaan <michael.dehaan@gmail.com>
 3
 4# This file is part of Ansible
 5#
 6# Ansible is free software: you can redistribute it and/or modify
 7# it under the terms of the GNU General Public License as published by
 8# the Free Software Foundation, either version 3 of the License, or
 9# (at your option) any later version.
10#
11# Ansible is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.
18
19- name: fill in a basic template
20  template: src=foo.j2 dest={{output_dir}}/foo.templated mode=0644
21  register: template_result
22
23- assert: 
24    that: 
25        - "'changed' in template_result" 
26        - "'dest' in template_result" 
27        - "'group' in template_result" 
28        - "'gid' in template_result" 
29        - "'md5sum' in template_result" 
30        - "'owner' in template_result" 
31        - "'size' in template_result" 
32        - "'src' in template_result" 
33        - "'state' in template_result" 
34        - "'uid' in template_result" 
35
36- name: verify that the file was marked as changed
37  assert: 
38    that: 
39      - "template_result.changed == true"
40
41# VERIFY CONTENTS
42
43- name: copy known good into place
44  copy: src=foo.txt dest={{output_dir}}/foo.txt
45
46- name: compare templated file to known good
47  shell: diff {{output_dir}}/foo.templated {{output_dir}}/foo.txt
48  register: diff_result
49
50- name: verify templated file matches known good
51  assert:  
52    that: 
53        - 'diff_result.stdout == ""' 
54        - "diff_result.rc == 0" 
55
56# VERIFY MODE
57
58- name: set file mode
59  file: path={{output_dir}}/foo.templated mode=0644
60  register: file_result
61
62- name: ensure file mode did not change
63  assert: 
64    that: 
65      - "file_result.changed != True"
66