mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
4fe08441be
* Warn on tests used as filters * Update docs, add aliases for tests that fit more gramatically with test syntax * Fix rst formatting * Add successful filter, alias of success * Remove renamed_deprecation, it was overkill * Make directory alias for is_dir * Update tests to use proper jinja test syntax * Update additional documentation, living outside of YAML files, to reflect proper jinja test syntax * Add conversion script, porting guide updates, and changelog updates * Update newly added uses of tests as filters * No underscore variable * Convert recent tests as filter changes to win_stat * Fix some changes related to rebasing a few integration tests * Make tests_as_filters_warning explicitly accept the name of the test, instead of inferring the name * Add test for tests_as_filters_warning * Update tests as filters in newly added/modified tests * Address recent changes to several integration tests * Address recent changes in cs_vpc
211 lines
6.3 KiB
YAML
211 lines
6.3 KiB
YAML
# (c) 2017, Martin Krizek <mkrizek@redhat.com>
|
|
|
|
# This file is part of Ansible
|
|
#
|
|
# Ansible is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# Ansible is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# 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
|
|
user:
|
|
name: "{{ ansible_user }}"
|
|
|
|
- name: Create ansible group
|
|
group:
|
|
name: "{{ ansible_group }}"
|
|
|
|
- name: Create ansible file
|
|
file:
|
|
path: "{{ ansible_file }}"
|
|
state: touch
|
|
|
|
- name: Create ansible dir
|
|
file:
|
|
path: "{{ ansible_dir }}"
|
|
state: directory
|
|
##############################################################################
|
|
- name: Grant ansible user read access to a file
|
|
acl:
|
|
path: "{{ ansible_file }}"
|
|
entity: "{{ ansible_user }}"
|
|
etype: user
|
|
permissions: r
|
|
state: present
|
|
register: output
|
|
|
|
- name: get getfacl output
|
|
shell: "getfacl {{ ansible_file }}"
|
|
register: getfacl_output
|
|
|
|
- name: verify output
|
|
assert:
|
|
that:
|
|
- output is changed
|
|
- output is not failed
|
|
- "'user:{{ ansible_user }}:r--' in output.acl"
|
|
- "'user:{{ ansible_user }}:r--' in getfacl_output.stdout_lines"
|
|
##############################################################################
|
|
- name: Obtain the acl for a specific file
|
|
acl:
|
|
path: "{{ ansible_file }}"
|
|
register: output
|
|
|
|
- name: get getfacl output
|
|
shell: "getfacl {{ ansible_file }}"
|
|
register: getfacl_output
|
|
|
|
- name: verify output
|
|
assert:
|
|
that:
|
|
- output is not changed
|
|
- output is not failed
|
|
- "'user::rw-' in output.acl"
|
|
- "'user:{{ ansible_user }}:r--' in output.acl"
|
|
- "'group::r--' in output.acl"
|
|
- "'mask::r--' in output.acl"
|
|
- "'other::r--' in output.acl"
|
|
- "'user::rw-' in getfacl_output.stdout_lines"
|
|
- "'user:{{ ansible_user }}:r--' in getfacl_output.stdout_lines"
|
|
- "'group::r--' in getfacl_output.stdout_lines"
|
|
- "'mask::r--' in getfacl_output.stdout_lines"
|
|
- "'other::r--' in getfacl_output.stdout_lines"
|
|
##############################################################################
|
|
- name: Removes the acl for ansible user on a specific file
|
|
acl:
|
|
path: "{{ ansible_file }}"
|
|
entity: "{{ ansible_user }}"
|
|
etype: user
|
|
state: absent
|
|
register: output
|
|
|
|
- name: get getfacl output
|
|
shell: "getfacl {{ ansible_file }}"
|
|
register: getfacl_output
|
|
|
|
- name: verify output
|
|
assert:
|
|
that:
|
|
- output is changed
|
|
- output is not failed
|
|
- "'user:{{ ansible_user }}:r--' not in output.acl"
|
|
- "'user:{{ ansible_user }}:r--' not in getfacl_output.stdout_lines"
|
|
##############################################################################
|
|
- name: Sets default acl for ansible user on ansible dir
|
|
acl:
|
|
path: "{{ ansible_dir }}"
|
|
entity: "{{ ansible_user }}"
|
|
etype: user
|
|
permissions: rw
|
|
default: yes
|
|
state: present
|
|
register: output
|
|
|
|
- name: get getfacl output
|
|
shell: "getfacl {{ ansible_dir }}"
|
|
register: getfacl_output
|
|
|
|
- name: verify output
|
|
assert:
|
|
that:
|
|
- output is changed
|
|
- output is not failed
|
|
- "'user:{{ ansible_user }}:rw-' in output.acl"
|
|
- "'default:user:{{ ansible_user }}:rw-' in getfacl_output.stdout_lines"
|
|
##############################################################################
|
|
- name: Cleanup
|
|
shell: "setfacl -b {{ ansible_dir }}"
|
|
##############################################################################
|
|
- name: Same as previous but using entry shorthand
|
|
acl:
|
|
path: "{{ ansible_dir }}"
|
|
entry: "user:{{ ansible_user }}:rw-"
|
|
default: yes
|
|
state: present
|
|
register: output
|
|
|
|
- name: get getfacl output
|
|
shell: "getfacl {{ ansible_dir }}"
|
|
register: getfacl_output
|
|
|
|
- name: verify output
|
|
assert:
|
|
that:
|
|
- output is changed
|
|
- output is not failed
|
|
- "'user:{{ ansible_user }}:rw-' in output.acl"
|
|
- "'default:user:{{ ansible_user }}:rw-' in getfacl_output.stdout_lines"
|
|
##############################################################################
|
|
- name: Same as previous, to test idempotence
|
|
acl:
|
|
path: "{{ ansible_dir }}"
|
|
entry: "user:{{ ansible_user }}:rw-"
|
|
default: yes
|
|
state: present
|
|
register: output
|
|
|
|
- name: get getfacl output
|
|
shell: "getfacl {{ ansible_dir }}"
|
|
register: getfacl_output
|
|
|
|
- name: verify output
|
|
assert:
|
|
that:
|
|
- output is not changed
|
|
- output is not failed
|
|
- "'user:{{ ansible_user }}:rw-' in output.acl"
|
|
- "'default:user:{{ ansible_user }}:rw-' in getfacl_output.stdout_lines"
|
|
##############################################################################
|
|
- name: Cleanup
|
|
shell: "setfacl -b {{ ansible_dir }}"
|
|
##############################################################################
|
|
- name: Set default acls
|
|
acl:
|
|
path: "{{ ansible_dir }}"
|
|
entry: "{{ item }}"
|
|
default: yes
|
|
state: present
|
|
with_items:
|
|
- "user:{{ ansible_user }}:rw-"
|
|
- "group:{{ ansible_group }}:rw-"
|
|
|
|
- name: Remove default group ansible_user acl
|
|
acl:
|
|
path: "{{ ansible_dir }}"
|
|
entry: "group:{{ ansible_group }}:rw-"
|
|
default: yes
|
|
state: absent
|
|
register: output
|
|
|
|
- name: get getfacl output
|
|
shell: "getfacl {{ ansible_dir }}"
|
|
register: getfacl_output
|
|
|
|
- name: verify output
|
|
assert:
|
|
that:
|
|
- output is changed
|
|
- output is not failed
|
|
- "'user::rwx' in getfacl_output.stdout_lines"
|
|
- "'group::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:{{ ansible_user }}:rw-' in getfacl_output.stdout_lines"
|
|
- "'default:group::r-x' in getfacl_output.stdout_lines"
|
|
- "'default:mask::rwx' 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"
|