summaryrefslogtreecommitdiff
path: root/test/integration/targets/unsafe_writes
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2020-12-21 11:20:52 -0500
committerGitHub <noreply@github.com>2020-12-21 11:20:52 -0500
commit932ba3616067007fd5e449611a34e7e3837fc8ae (patch)
tree81f17f85e3cc4fb905d2993545c4f96c6f6daf44 /test/integration/targets/unsafe_writes
parent202689b1c0560b68a93e93d0a250ea186a8e3e1a (diff)
downloadansible-932ba3616067007fd5e449611a34e7e3837fc8ae.tar.gz
ensure unsafe writes fallback (#70722)
* Ensure we actually fallback to unsafe_writes when set to true add integration test add fix for get_url not passing the parameter from args
Diffstat (limited to 'test/integration/targets/unsafe_writes')
-rw-r--r--test/integration/targets/unsafe_writes/aliases6
-rw-r--r--test/integration/targets/unsafe_writes/basic.yml53
-rwxr-xr-xtest/integration/targets/unsafe_writes/runme.sh5
3 files changed, 64 insertions, 0 deletions
diff --git a/test/integration/targets/unsafe_writes/aliases b/test/integration/targets/unsafe_writes/aliases
new file mode 100644
index 0000000000..4fb7a11640
--- /dev/null
+++ b/test/integration/targets/unsafe_writes/aliases
@@ -0,0 +1,6 @@
+needs/root
+skip/freebsd
+skip/osx
+skip/macos
+skip/aix
+shippable/posix/group3
diff --git a/test/integration/targets/unsafe_writes/basic.yml b/test/integration/targets/unsafe_writes/basic.yml
new file mode 100644
index 0000000000..b173c7f872
--- /dev/null
+++ b/test/integration/targets/unsafe_writes/basic.yml
@@ -0,0 +1,53 @@
+- hosts: testhost
+ gather_facts: false
+ vars:
+ testudir: '{{output_dir}}/unsafe_writes_test'
+ testufile: '{{testudir}}/unreplacablefile.txt'
+ tasks:
+ - name: test unsafe_writes on immutable dir (file cannot be atomically replaced)
+ block:
+ - name: create target dir
+ file: path={{testudir}} state=directory
+ - name: setup test file
+ copy: content=ORIGINAL dest={{testufile}}
+ - name: make target dir immutable (cannot write to file w/o unsafe_writes)
+ file: path={{testudir}} state=directory attributes="+i"
+ become: yes
+ ignore_errors: true
+ register: madeimmutable
+
+ - name: only run if immutable dir command worked, some of our test systems don't allow for it
+ when: madeimmutable is success
+ block:
+ - name: test this is actually immmutable working as we expect
+ file: path={{testufile}} state=absent
+ register: breakimmutable
+ ignore_errors: True
+
+ - name: only run if reallyh immutable dir
+ when: breakimmutable is failed
+ block:
+ - name: test overwriting file w/o unsafe
+ copy: content=NEW dest={{testufile}} unsafe_writes=False
+ ignore_errors: true
+ register: copy_without
+
+ - name: ensure we properly failed
+ assert:
+ that:
+ - copy_without is failed
+
+ - name: test overwriting file with unsafe
+ copy: content=NEW dest={{testufile}} unsafe_writes=True
+ register: copy_with
+
+ - name: ensure we properly changed
+ assert:
+ that:
+ - copy_with is changed
+
+ always:
+ - name: remove immutable flag from dir to prevent issues with cleanup
+ file: path={{testudir}} state=directory attributes="-i"
+ ignore_errors: true
+ become: yes
diff --git a/test/integration/targets/unsafe_writes/runme.sh b/test/integration/targets/unsafe_writes/runme.sh
new file mode 100755
index 0000000000..5c37f727ee
--- /dev/null
+++ b/test/integration/targets/unsafe_writes/runme.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+set -eux
+
+ansible-playbook basic.yml -i ../../inventory -e "output_dir=${OUTPUT_DIR}" "$@"