Rework the shell quoting of remote checksumming

Instead of getting rid of pipes.quote, use pipes.quote and get rid of
the manually entered toplevel quotes.  This should properly escape
backslashes, quotes, and other characters.

Also fix the new checksumming python "one-liner" for csh.
ansible_shell_type needs to be set to csh.

Fixes #10363
Fixes #10353
This commit is contained in:
Toshio Kuratomi 2015-03-02 12:25:41 -08:00
commit a8c02b7049
10 changed files with 99 additions and 4 deletions

View file

@ -1,3 +1,4 @@
- hosts: testhost
roles:
- { role: test_always_run, tags: test_always_run }
- { role: test_check_mode, tags: test_check_mode }

View file

@ -19,11 +19,13 @@
- name: clean out the test directory
file: name={{output_dir|mandatory}} state=absent
always_run: True
tags:
- prepare
- name: create the test directory
file: name={{output_dir}} state=directory
always_run: True
tags:
- prepare

View file

@ -0,0 +1 @@
templated_var_loaded

View file

@ -0,0 +1,3 @@
dependencies:
- prepare_tests

View file

@ -0,0 +1,39 @@
# 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
template: src=foo.j2 dest={{output_dir}}/foo.templated mode=0644
register: template_result
- name: verify that the file was marked as changed in check mode
assert:
that:
- "template_result.changed == true"
- name: Actually create the file
template: src=foo.j2 dest={{output_dir}}/foo.templated2 mode=0644
always_run: True
- name: fill in a basic template in check mode
template: src=foo.j2 dest={{output_dir}}/foo.templated2 mode=0644
register: template_result2
- name: verify that the file was marked as not changed in check mode
assert:
that:
- "template_result2.changed == false"

View file

@ -0,0 +1 @@
{{ templated_var }}

View file

@ -0,0 +1 @@
templated_var: templated_var_loaded

View file

@ -138,3 +138,39 @@
that:
- "template_result.changed == False"
# Test strange filenames
- name: Create a temp dir for filename tests
file:
state: directory
dest: '{{ output_dir }}/filename-tests'
- name: create a file with an unusual filename
template:
src: foo.j2
dest: "{{ output_dir }}/filename-tests/foo t'e~m\\plated"
register: template_result
- assert:
that:
- "template_result.changed == True"
- name: check that the unusual filename was created
command: "ls {{ output_dir }}/filename-tests/"
register: unusual_results
- assert:
that:
- "\"foo t'e~m\\plated\" in unusual_results.stdout_lines"
- "{{unusual_results.stdout_lines| length}} == 1"
- name: check that the unusual filename can be checked for changes
template:
src: foo.j2
dest: "{{ output_dir }}/filename-tests/foo t'e~m\\plated"
register: template_result
- assert:
that:
- "template_result.changed == False"