Commit 10e116ea by Richard C Isaacson

Cleaning up my asserts

parent fc648a65
...@@ -26,43 +26,41 @@ ...@@ -26,43 +26,41 @@
register: file_result register: file_result
- name: verify that the file was marked as changed - name: verify that the file was marked as changed
assert: { that: "file_result.changed == false" } assert:
that:
- name: verify that the state is that of a file - "file_result.changed == false"
assert: { that: "file_result.state == 'file'" } - "file_result.state == 'file'"
- name: verify that we are checking an absent file - name: verify that we are checking an absent file
file: path={{output_dir}}/bar.txt state=absent file: path={{output_dir}}/bar.txt state=absent
register: file2_result register: file2_result
- name: verify that the file was marked as changed - name: verify that the file was marked as changed
assert: { that: "file2_result.changed == false" } assert:
that:
- name: verify that the file was marked as changed - "file2_result.changed == false"
assert: { that: "file2_result.state == 'absent'" } - "file2_result.state == 'absent'"
- name: verify we can touch a file - name: verify we can touch a file
file: path={{output_dir}}/baz.txt state=touch file: path={{output_dir}}/baz.txt state=touch
register: file3_result register: file3_result
- name: verify that the file was marked as changed - name: verify that the file was marked as changed
assert: { that: "file3_result.changed == true" } assert:
that:
- name: verify that the state is that of a file - "file3_result.changed == true"
assert: { that: "file3_result.state == 'file'" } - "file3_result.state == 'file'"
- "file3_result.mode == '0644'"
- name: assert that the test file has a mode of 0644
assert: { that: "file3_result.mode == '0644'" }
- name: change file mode - name: change file mode
file: path={{output_dir}}/baz.txt mode=0600 file: path={{output_dir}}/baz.txt mode=0600
register: file4_result register: file4_result
- name: verify that the file was marked as changed - name: verify that the file was marked as changed
assert: { that: "file4_result.changed == true" } assert:
that:
- name: assert that the test file has a mode of 0600 - "file4_result.changed == true"
assert: { that: "file4_result.mode == '0600'" } - "file4_result.mode == '0600'"
- name: change ownership and group - name: change ownership and group
file: path={{output_dir}}/baz.txt owner=1000 group=1000 file: path={{output_dir}}/baz.txt owner=1000 group=1000
...@@ -72,24 +70,28 @@ ...@@ -72,24 +70,28 @@
register: file5_result register: file5_result
- name: verify that the file was marked as changed - name: verify that the file was marked as changed
assert: { that: "file5_result.changed == true" } assert:
that:
- "file5_result.changed == true"
- name: create hard link to file - name: create hard link to file
file: src={{output_file}} dest={{output_dir}}/hard.txt state=hard file: src={{output_file}} dest={{output_dir}}/hard.txt state=hard
register: file6_result register: file6_result
- name: verify that the file was marked as changed - name: verify that the file was marked as changed
assert: { that: "file6_result.changed == true" } assert:
that:
- "file6_result.changed == true"
- name: create a directory - name: create a directory
file: path={{output_dir}}/foobar state=directory file: path={{output_dir}}/foobar state=directory
register: file7_result register: file7_result
- name: verify that the file was marked as changed - name: verify that the file was marked as changed
assert: { that: "file7_result.changed == true" } assert:
that:
- name: assert that the test file has a mode of 0600 - "file7_result.changed == true"
assert: { that: "file7_result.state == 'directory'" } - "file7_result.state == 'directory'"
- name: determine if selinux is installed - name: determine if selinux is installed
shell: which getenforce || exit 0 shell: which getenforce || exit 0
...@@ -127,14 +129,18 @@ ...@@ -127,14 +129,18 @@
register: file8_result register: file8_result
- name: assert that the directory has changed to have owner 1234 - name: assert that the directory has changed to have owner 1234
assert: { that: "file8_result.uid == 1234" } assert:
that:
- "file8_result.uid == 1234"
- name: verify that the permission of a file under the directory was not set - name: verify that the permission of a file under the directory was not set
file: path={{output_dir}}/foobar/fileA state=file file: path={{output_dir}}/foobar/fileA state=file
register: file9_result register: file9_result
- name: assert the file owner has not changed to 1000 - name: assert the file owner has not changed to 1000
assert: { that: "file9_result.uid != 1234" } assert:
that:
- "file9_result.uid != 1234"
- name: change the ownership of a directory with recurse=yes - name: change the ownership of a directory with recurse=yes
file: path={{output_dir}}/foobar owner=1235 recurse=yes file: path={{output_dir}}/foobar owner=1235 recurse=yes
...@@ -144,14 +150,18 @@ ...@@ -144,14 +150,18 @@
register: file10_result register: file10_result
- name: assert that the directory has changed to have owner 1235 - name: assert that the directory has changed to have owner 1235
assert: { that: "file10_result.uid == 1235" } assert:
that:
- "file10_result.uid == 1235"
- name: verify that the permission of a file under the directory was not set - name: verify that the permission of a file under the directory was not set
file: path={{output_dir}}/foobar/fileA state=file file: path={{output_dir}}/foobar/fileA state=file
register: file11_result register: file11_result
- name: assert that the file has changed to have owner 1235 - name: assert that the file has changed to have owner 1235
assert: { that: "file11_result.uid == 1235" } assert:
that:
- "file11_result.uid == 1235"
- name: remote directory foobar - name: remote directory foobar
file: path={{output_dir}}/foobar state=absent file: path={{output_dir}}/foobar state=absent
...@@ -21,10 +21,10 @@ ...@@ -21,10 +21,10 @@
register: file_se_result register: file_se_result
- name: verify that the file was marked as changed - name: verify that the file was marked as changed
assert: { that: "file_se_result.changed == true" } assert:
that:
- name: assert touch a file for testing matches expected selinux context - "file_se_result.changed == true"
assert: { that: "file_se_result.secontext == 'unconfined_u:object_r:admin_home_t:s0'" } - "file_se_result.secontext == 'unconfined_u:object_r:admin_home_t:s0'"
- name: remove the file used for testing - name: remove the file used for testing
file: path={{output_dir}}/foo-se.txt state=absent file: path={{output_dir}}/foo-se.txt state=absent
\ No newline at end of file
...@@ -36,7 +36,9 @@ ...@@ -36,7 +36,9 @@
register: unarchive01 register: unarchive01
- name: verify that the file was marked as changed - name: verify that the file was marked as changed
assert: { that: "unarchive01.changed == true" } assert:
that:
- "unarchive01.changed == true"
- name: verify that the file was unarchived - name: verify that the file was unarchived
file: path={{output_dir}}/test-unarchive-tar/foo-unarchive.txt state=file file: path={{output_dir}}/test-unarchive-tar/foo-unarchive.txt state=file
...@@ -52,7 +54,9 @@ ...@@ -52,7 +54,9 @@
register: unarchive02 register: unarchive02
- name: verify that the file was marked as changed - name: verify that the file was marked as changed
assert: { that: "unarchive02.changed == true" } assert:
that:
- "unarchive02.changed == true"
- name: verify that the file was unarchived - name: verify that the file was unarchived
file: path={{output_dir}}/test-unarchive-tar-gz/foo-unarchive.txt state=file file: path={{output_dir}}/test-unarchive-tar-gz/foo-unarchive.txt state=file
...@@ -68,7 +72,9 @@ ...@@ -68,7 +72,9 @@
register: unarchive03 register: unarchive03
- name: verify that the file was marked as changed - name: verify that the file was marked as changed
assert: { that: "unarchive03.changed == true" } assert:
that:
- "unarchive03.changed == true"
- name: verify that the file was unarchived - name: verify that the file was unarchived
file: path={{output_dir}}/test-unarchive-zip/foo-unarchive.txt state=file file: path={{output_dir}}/test-unarchive-zip/foo-unarchive.txt state=file
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment