1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Make xattr test conditional on feature support.

This commit is contained in:
Matt Clay 2018-01-08 22:31:17 -08:00
parent 29fbf0c756
commit 77726b471f
3 changed files with 73 additions and 65 deletions

View file

@ -1 +1 @@
test_file: ~/foo.txt test_file: "{{ output_dir }}/foo.txt"

View file

@ -1,68 +1,11 @@
- name: Setup - name: Setup
include: setup.yml include: setup.yml
- name: Set attributes - name: Check availability of xattr support
xattr: command: setfattr -n user.foo {{ test_file }}
path: "{{ test_file }}" ignore_errors: yes
key: user.foo register: xattr
value: bar
register: xattr_set_result
- name: Get attributes - name: Test
xattr: include: test.yml
path: "{{ test_file }}" when: xattr is not failed
register: xattr_get_all_result
- name: Get specific attribute
xattr:
path: "{{ test_file }}"
key: user.foo
register: xattr_get_specific_result
- assert:
that:
- "xattr_set_result.changed"
- "xattr_get_all_result['xattr']['user.foo'] == 'bar'"
- "not xattr_get_all_result.changed"
- "xattr_get_specific_result['xattr']['user.foo'] == 'bar'"
- "not xattr_get_specific_result.changed"
- name: Set attribute again
xattr:
path: "{{ test_file }}"
key: user.foo
value: bar
register: xattr_set_again_result
- assert:
that:
- "not xattr_set_again_result.changed"
- name: Unset attribute
xattr:
path: "{{ test_file }}"
key: user.foo
state: absent
register: xattr_unset_result
- name: get attributes
xattr:
path: "{{ test_file }}"
register: xattr_get_after_unset_result
- assert:
that:
- "xattr_unset_result.changed"
- "xattr_get_after_unset_result['xattr'] == {}"
- "not xattr_get_after_unset_result.changed"
- name: Unset attribute again
xattr:
path: "{{ test_file }}"
key: user.foo
state: absent
register: xattr_unset_result
- assert:
that:
- "not xattr_set_again_result.changed"

View file

@ -0,0 +1,65 @@
- name: Set attributes
xattr:
path: "{{ test_file }}"
key: user.foo
value: bar
register: xattr_set_result
- name: Get attributes
xattr:
path: "{{ test_file }}"
register: xattr_get_all_result
- name: Get specific attribute
xattr:
path: "{{ test_file }}"
key: user.foo
register: xattr_get_specific_result
- assert:
that:
- "xattr_set_result.changed"
- "xattr_get_all_result['xattr']['user.foo'] == 'bar'"
- "not xattr_get_all_result.changed"
- "xattr_get_specific_result['xattr']['user.foo'] == 'bar'"
- "not xattr_get_specific_result.changed"
- name: Set attribute again
xattr:
path: "{{ test_file }}"
key: user.foo
value: bar
register: xattr_set_again_result
- assert:
that:
- "not xattr_set_again_result.changed"
- name: Unset attribute
xattr:
path: "{{ test_file }}"
key: user.foo
state: absent
register: xattr_unset_result
- name: get attributes
xattr:
path: "{{ test_file }}"
register: xattr_get_after_unset_result
- assert:
that:
- "xattr_unset_result.changed"
- "xattr_get_after_unset_result['xattr'] == {}"
- "not xattr_get_after_unset_result.changed"
- name: Unset attribute again
xattr:
path: "{{ test_file }}"
key: user.foo
state: absent
register: xattr_unset_result
- assert:
that:
- "not xattr_set_again_result.changed"