diff options
author | pdasilva <pdasilva@gmail.com> | 2017-05-22 15:38:11 -0700 |
---|---|---|
committer | Matt Davis <mdavis@ansible.com> | 2017-05-22 15:42:17 -0700 |
commit | daf2b5e5fb9fbb26ff938df169bd6e0fa9e4026d (patch) | |
tree | ef6044bd5ad62ed113e07c1d85e518f3e837bb2e | |
parent | 3ad37b320fdf31e18ee748e7dc975cb60acff909 (diff) | |
download | ansible-daf2b5e5fb9fbb26ff938df169bd6e0fa9e4026d.tar.gz |
Changed assemble_from_fragments to use os.path.join (#24909)
Fixes #19437
(cherry picked from commit f8e47e2204fb289a0480d803abf69bd8d1fe0422)
-rw-r--r-- | lib/ansible/modules/files/assemble.py | 2 | ||||
-rw-r--r-- | test/integration/targets/assemble/tasks/main.yml | 15 |
2 files changed, 13 insertions, 4 deletions
diff --git a/lib/ansible/modules/files/assemble.py b/lib/ansible/modules/files/assemble.py index 3ff02d2c39..92685357e9 100644 --- a/lib/ansible/modules/files/assemble.py +++ b/lib/ansible/modules/files/assemble.py @@ -141,7 +141,7 @@ def assemble_from_fragments(src_path, delimiter=None, compiled_regexp=None, igno for f in sorted(os.listdir(src_path)): if compiled_regexp and not compiled_regexp.search(f): continue - fragment = u"%s/%s" % (src_path, f) + fragment = os.path.join(src_path, f) if not os.path.isfile(fragment) or (ignore_hidden and os.path.basename(fragment).startswith('.')): continue fragment_content = open(fragment, 'rb').read() diff --git a/test/integration/targets/assemble/tasks/main.yml b/test/integration/targets/assemble/tasks/main.yml index 38d5532246..72f0c111d7 100644 --- a/test/integration/targets/assemble/tasks/main.yml +++ b/test/integration/targets/assemble/tasks/main.yml @@ -29,6 +29,15 @@ copy: src="./" dest="{{output_dir}}/src" register: result +- name: create unicode file for test + shell: echo "π" > {{ output_dir }}/src/ßΩ.txt + register: result + +- name: assert that the new file was created + assert: + that: + - "result.changed == true" + - name: test assemble with all fragments assemble: src="{{output_dir}}/src" dest="{{output_dir}}/assembled1" register: result @@ -38,7 +47,7 @@ that: - "result.state == 'file'" - "result.changed == True" - - "result.checksum == '048a1bd1951aa5ccc427eeb4ca19aee45e9c68b3'" + - "result.checksum == '74152e9224f774191bc0bedf460d35de86ad90e6'" - name: test assemble with all fragments assemble: src="{{output_dir}}/src" dest="{{output_dir}}/assembled1" @@ -49,7 +58,7 @@ that: - "result.state == 'file'" - "result.changed == False" - - "result.checksum == '048a1bd1951aa5ccc427eeb4ca19aee45e9c68b3'" + - "result.checksum == '74152e9224f774191bc0bedf460d35de86ad90e6'" - name: test assemble with fragments matching a regex assemble: src="{{output_dir}}/src" dest="{{output_dir}}/assembled2" regexp="^fragment[1-3]$" @@ -69,7 +78,7 @@ assert: that: - "result.state == 'file'" - - "result.checksum == '505359f48c65b3904127cf62b912991d4da7ed6d'" + - "result.checksum == 'd986cefb82e34e4cf14d33a3cda132ff45aa2980'" - name: test assemble with remote_src=False assemble: src="./" dest="{{output_dir}}/assembled4" remote_src=no |