acl integration tests: don't use restricted key, allow to run twice in a row (#34858)

* acl test: don't use restricted key

Fix this warning: [WARNING]: Removed restricted key from module data: ansible_user = ansible_user

* acl test: allow to execute twice in a row
pull/34874/head
Pilou 7 years ago committed by Martin Krizek
parent 191b934dbd
commit 9e918c8003

@ -15,41 +15,35 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- set_fact:
ansible_user: ansible_user
ansible_group: ansible_group
ansible_file: /tmp/ansible_file
ansible_dir: /tmp/ansible_dir
- name: Create ansible user - name: Create ansible user
user: user:
name: "{{ ansible_user }}" name: "{{ test_user }}"
- name: Create ansible group - name: Create ansible group
group: group:
name: "{{ ansible_group }}" name: "{{ test_group }}"
- name: Create ansible file - name: Create ansible file
file: file:
path: "{{ ansible_file }}" path: "{{ test_file }}"
state: touch state: touch
- name: Create ansible dir - name: Create ansible dir
file: file:
path: "{{ ansible_dir }}" path: "{{ test_dir }}"
state: directory state: directory
############################################################################## ##############################################################################
- name: Grant ansible user read access to a file - name: Grant ansible user read access to a file
acl: acl:
path: "{{ ansible_file }}" path: "{{ test_file }}"
entity: "{{ ansible_user }}" entity: "{{ test_user }}"
etype: user etype: user
permissions: r permissions: r
state: present state: present
register: output register: output
- name: get getfacl output - name: get getfacl output
shell: "getfacl {{ ansible_file }}" shell: "getfacl {{ test_file }}"
register: getfacl_output register: getfacl_output
- name: verify output - name: verify output
@ -57,16 +51,16 @@
that: that:
- output is changed - output is changed
- output is not failed - output is not failed
- "'user:{{ ansible_user }}:r--' in output.acl" - "'user:{{ test_user }}:r--' in output.acl"
- "'user:{{ ansible_user }}:r--' in getfacl_output.stdout_lines" - "'user:{{ test_user }}:r--' in getfacl_output.stdout_lines"
############################################################################## ##############################################################################
- name: Obtain the acl for a specific file - name: Obtain the acl for a specific file
acl: acl:
path: "{{ ansible_file }}" path: "{{ test_file }}"
register: output register: output
- name: get getfacl output - name: get getfacl output
shell: "getfacl {{ ansible_file }}" shell: "getfacl {{ test_file }}"
register: getfacl_output register: getfacl_output
- name: verify output - name: verify output
@ -75,26 +69,26 @@
- output is not changed - output is not changed
- output is not failed - output is not failed
- "'user::rw-' in output.acl" - "'user::rw-' in output.acl"
- "'user:{{ ansible_user }}:r--' in output.acl" - "'user:{{ test_user }}:r--' in output.acl"
- "'group::r--' in output.acl" - "'group::r--' in output.acl"
- "'mask::r--' in output.acl" - "'mask::r--' in output.acl"
- "'other::r--' in output.acl" - "'other::r--' in output.acl"
- "'user::rw-' in getfacl_output.stdout_lines" - "'user::rw-' in getfacl_output.stdout_lines"
- "'user:{{ ansible_user }}:r--' in getfacl_output.stdout_lines" - "'user:{{ test_user }}:r--' in getfacl_output.stdout_lines"
- "'group::r--' in getfacl_output.stdout_lines" - "'group::r--' in getfacl_output.stdout_lines"
- "'mask::r--' in getfacl_output.stdout_lines" - "'mask::r--' in getfacl_output.stdout_lines"
- "'other::r--' in getfacl_output.stdout_lines" - "'other::r--' in getfacl_output.stdout_lines"
############################################################################## ##############################################################################
- name: Removes the acl for ansible user on a specific file - name: Removes the acl for ansible user on a specific file
acl: acl:
path: "{{ ansible_file }}" path: "{{ test_file }}"
entity: "{{ ansible_user }}" entity: "{{ test_user }}"
etype: user etype: user
state: absent state: absent
register: output register: output
- name: get getfacl output - name: get getfacl output
shell: "getfacl {{ ansible_file }}" shell: "getfacl {{ test_file }}"
register: getfacl_output register: getfacl_output
- name: verify output - name: verify output
@ -102,13 +96,13 @@
that: that:
- output is changed - output is changed
- output is not failed - output is not failed
- "'user:{{ ansible_user }}:r--' not in output.acl" - "'user:{{ test_user }}:r--' not in output.acl"
- "'user:{{ ansible_user }}:r--' not in getfacl_output.stdout_lines" - "'user:{{ test_user }}:r--' not in getfacl_output.stdout_lines"
############################################################################## ##############################################################################
- name: Sets default acl for ansible user on ansible dir - name: Sets default acl for ansible user on ansible dir
acl: acl:
path: "{{ ansible_dir }}" path: "{{ test_dir }}"
entity: "{{ ansible_user }}" entity: "{{ test_user }}"
etype: user etype: user
permissions: rw permissions: rw
default: yes default: yes
@ -116,7 +110,7 @@
register: output register: output
- name: get getfacl output - name: get getfacl output
shell: "getfacl {{ ansible_dir }}" shell: "getfacl {{ test_dir }}"
register: getfacl_output register: getfacl_output
- name: verify output - name: verify output
@ -124,22 +118,22 @@
that: that:
- output is changed - output is changed
- output is not failed - output is not failed
- "'user:{{ ansible_user }}:rw-' in output.acl" - "'user:{{ test_user }}:rw-' in output.acl"
- "'default:user:{{ ansible_user }}:rw-' in getfacl_output.stdout_lines" - "'default:user:{{ test_user }}:rw-' in getfacl_output.stdout_lines"
############################################################################## ##############################################################################
- name: Cleanup - name: Cleanup
shell: "setfacl -b {{ ansible_dir }}" shell: "setfacl -b {{ test_dir }}"
############################################################################## ##############################################################################
- name: Same as previous but using entry shorthand - name: Same as previous but using entry shorthand
acl: acl:
path: "{{ ansible_dir }}" path: "{{ test_dir }}"
entry: "user:{{ ansible_user }}:rw-" entry: "user:{{ test_user }}:rw-"
default: yes default: yes
state: present state: present
register: output register: output
- name: get getfacl output - name: get getfacl output
shell: "getfacl {{ ansible_dir }}" shell: "getfacl {{ test_dir }}"
register: getfacl_output register: getfacl_output
- name: verify output - name: verify output
@ -147,19 +141,19 @@
that: that:
- output is changed - output is changed
- output is not failed - output is not failed
- "'user:{{ ansible_user }}:rw-' in output.acl" - "'user:{{ test_user }}:rw-' in output.acl"
- "'default:user:{{ ansible_user }}:rw-' in getfacl_output.stdout_lines" - "'default:user:{{ test_user }}:rw-' in getfacl_output.stdout_lines"
############################################################################## ##############################################################################
- name: Same as previous, to test idempotence - name: Same as previous, to test idempotence
acl: acl:
path: "{{ ansible_dir }}" path: "{{ test_dir }}"
entry: "user:{{ ansible_user }}:rw-" entry: "user:{{ test_user }}:rw-"
default: yes default: yes
state: present state: present
register: output register: output
- name: get getfacl output - name: get getfacl output
shell: "getfacl {{ ansible_dir }}" shell: "getfacl {{ test_dir }}"
register: getfacl_output register: getfacl_output
- name: verify output - name: verify output
@ -167,32 +161,32 @@
that: that:
- output is not changed - output is not changed
- output is not failed - output is not failed
- "'user:{{ ansible_user }}:rw-' in output.acl" - "'user:{{ test_user }}:rw-' in output.acl"
- "'default:user:{{ ansible_user }}:rw-' in getfacl_output.stdout_lines" - "'default:user:{{ test_user }}:rw-' in getfacl_output.stdout_lines"
############################################################################## ##############################################################################
- name: Cleanup - name: Cleanup
shell: "setfacl -b {{ ansible_dir }}" shell: "setfacl -b {{ test_dir }}"
############################################################################## ##############################################################################
- name: Set default acls - name: Set default acls
acl: acl:
path: "{{ ansible_dir }}" path: "{{ test_dir }}"
entry: "{{ item }}" entry: "{{ item }}"
default: yes default: yes
state: present state: present
with_items: with_items:
- "user:{{ ansible_user }}:rw-" - "user:{{ test_user }}:rw-"
- "group:{{ ansible_group }}:rw-" - "group:{{ test_group }}:rw-"
- name: Remove default group ansible_user acl - name: Remove default group test_user acl
acl: acl:
path: "{{ ansible_dir }}" path: "{{ test_dir }}"
entry: "group:{{ ansible_group }}:rw-" entry: "group:{{ test_group }}:rw-"
default: yes default: yes
state: absent state: absent
register: output register: output
- name: get getfacl output - name: get getfacl output
shell: "getfacl {{ ansible_dir }}" shell: "getfacl {{ test_dir }}"
register: getfacl_output register: getfacl_output
- name: verify output - name: verify output
@ -204,8 +198,8 @@
- "'group::r-x' in getfacl_output.stdout_lines" - "'group::r-x' in getfacl_output.stdout_lines"
- "'other::r-x' in getfacl_output.stdout_lines" - "'other::r-x' in getfacl_output.stdout_lines"
- "'default:user::rwx' in getfacl_output.stdout_lines" - "'default:user::rwx' in getfacl_output.stdout_lines"
- "'default:user:{{ ansible_user }}:rw-' in getfacl_output.stdout_lines" - "'default:user:{{ test_user }}:rw-' in getfacl_output.stdout_lines"
- "'default:group::r-x' in getfacl_output.stdout_lines" - "'default:group::r-x' in getfacl_output.stdout_lines"
- "'default:mask::rwx' in getfacl_output.stdout_lines" - "'default:mask::rwx' in getfacl_output.stdout_lines"
- "'default:other::r-x' in getfacl_output.stdout_lines" - "'default:other::r-x' in getfacl_output.stdout_lines"
- "'default:group:{{ ansible_group }}:rw-' not in getfacl_output.stdout_lines" - "'default:group:{{ test_group }}:rw-' not in getfacl_output.stdout_lines"

@ -15,5 +15,22 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- include: acl.yml - block:
when: ansible_system == 'Linux' # TODO enable acls mount option on FreeBSD to test it there too
- include: acl.yml
when: ansible_system == 'Linux' # TODO enable acls mount option on FreeBSD to test it there too
always:
- name: delete created directory and file
file:
path: '{{ item }}'
state: absent
with_items:
- '{{ test_dir }}'
- '{{ test_file }}'
vars:
test_user: ansible_user
test_group: ansible_group
test_file: /tmp/ansible_file
test_dir: /tmp/ansible_dir

Loading…
Cancel
Save