Commit graph

8 commits

Author SHA1 Message Date
Toshio Kuratomi
bc66faa328 Add more tests for copy/file/template with harlinks 2017-08-17 18:16:17 -07:00
Mehran Kholdi
ecfa7f696d Enforce state='file' in copy module
This was causing wrong behaviour when `prev_state` was `hard`-link,
since the `file` module tried to apply the same `state` on the new
file, causing unexpected errors.

Particularly, both `overlay` and `devicemapper` storage drivers in
docker use hardlinks to share files between layers. This causes
most ansible playbooks to fail when working with files from layers
below.
2017-08-17 18:16:17 -07:00
Sam Doran
a8e4c9be7a Cause copy module to fail on empty string as source (#27975)
* Fail if an empty string is set as src for copy module

Fixes #27363

* Cleanup task formatting on copy tests

Use multi-line YAML
Add debug statements with verbosity: 1 rather than leave them in there commented out.

* Add test for empty string as source

* Do more checks in order to add more specific errors messages

Add more integration tests for the various failure scenarios.
Cleanup some syntax on existing integration test tasks.
2017-08-15 12:41:16 -04:00
Pierre-Louis Bonicoli
022d45cb52 copy: clearer parameter values (tests) 2017-08-13 08:22:22 -07:00
Pierre-Louis Bonicoli
efd17915f1 copy: clearer comments, filenames, task names (tests) 2017-08-13 08:22:22 -07:00
Pierre-Louis Bonicoli
6f47b3e9e8 copy: check non-existing one level directory too 2017-08-13 08:22:22 -07:00
Pierre-Louis Bonicoli
470989bff9 copy: check behavior related to dest creation when src is a file 2017-08-13 08:22:22 -07:00
Pilou
ade593da52 Copy module: improve tests allowing to use a managed host which isn't the controller host (#25672)
* set output_dir_expanded using module result

'path' values are expanded using 'expandvars' too

* foo.txt is located in 'files' directory

* Use 'role_path' and 'connection: local' for local paths

'{{ role_path }}/tmp' is used for generated paths

* Use local connection with local paths

/tmp/ansible-test-abs-link and /tmp/ansible-test-abs-link-dir are
defined by targets/copy/files/subdir/subdir1/ansible-test-abs-link
and targets/copy/files/subdir/subdir1/ansible-test-abs-link-dir links.

* task names: add a suffix when same name is reused

* Check that item exists before checking file mode

then error message is more explicit when item doesn't exist

* Use output_dir_expanded only when necessary

* Enforce remote_user when root is required

* Fix remote path

* Use different local & remote user

this is useful when controller and managed hosts are identical

* Checks must not expect output of tested module to be right

* Use a temporary directory on the controller

* Use sha1 & md5 filters instead of hardcoded values

* Use 'remote_dir' for directory on managed host

* Workaround tempfile error on OS X

Error was:
temp_path = tempfile.mkdtemp(prefix='ansible_')
AttributeError: 'module' object has no attribute 'mkdtemp'"
2017-07-31 22:07:22 -07:00