ansible/test/integration/targets/xfs_quota/tasks/pquota.yml
William Leemans 993727ff5e New module: xfs_quota (#51654)
* New module: xfs_quota

* wildcard import resolution

* pep8 fixes

* validate-modules fixes

* pep8 and validate-module fixes

* removal of extra copyright info

* description capitalization and trailing dot

* Some more description

* type specification

* removal of notes

* reorder imports

* sorting

* starting with variable type

* removal of defaults

* results to dict

* results to dict

* complete condition

* removal of spaces for pep8 compliancy, removal of root check, addition of tests for failed xfs_quota commands indicating the need for elevation/capabilities

* lost result

* typo

* historical override removal

* report back values

* unexpected spaces removal

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* typo

* raw data, full data

* removal of several else: statements and indentation

* pep8

* typo

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* typo

* use bytes as base, not kilobytes

* be consistent

* integration tests

* lint

* empty lines

* Update lib/ansible/modules/system/xfs_quota.py

Co-Authored-By: bushvin <bushvin@users.noreply.github.com>

* updates

* ci group

* XFS not supported on osx

* XFS not supported by freebsd

* long lines and removal of xfs_quota dict in return

* RETURN values

* no more xfs_quota dict
2019-04-07 20:11:32 +01:00

202 lines
6.6 KiB
YAML

---
- name: 'Create disk image'
command: >
dd if=/dev/zero of={{ ansible_user_dir }}/ansible_testing/img-pquota bs=1M count=20
- name: 'Create XFS filesystem'
filesystem:
dev: '{{ ansible_user_dir }}/ansible_testing/img-pquota'
fstype: xfs
- name: Create xfs related files
file:
path: '/etc/{{ item }}'
state: touch
become: True
loop:
- 'projid'
- 'projects'
- name: 'Add test xfs quota project id'
lineinfile:
path: /etc/projid
line: 'xft_quotaval:99999'
state: present
become: True
- name: 'Add test xfs quota project path'
lineinfile:
path: /etc/projects
line: '99999:{{ ansible_user_dir }}/ansible_testing/pquota/test'
state: present
become: True
- block:
- name: 'Mount filesystem'
mount:
fstab: '{{ ansible_user_dir }}/ansible_testing/fstab'
src: '{{ ansible_user_dir }}/ansible_testing/img-pquota'
path: '{{ ansible_user_dir }}/ansible_testing/pquota'
fstype: xfs
opts: pquota
state: mounted
become: True
- name: 'Create test directory'
file:
path: '{{ ansible_user_dir }}/ansible_testing/pquota/test'
state: directory
become: True
- name: 'Apply default project limits'
xfs_quota:
bsoft: '{{ pquota_default_bsoft }}'
bhard: '{{ pquota_default_bhard }}'
isoft: '{{ pquota_default_isoft }}'
ihard: '{{ pquota_default_ihard }}'
mountpoint: '{{ ansible_user_dir }}/ansible_testing/pquota'
rtbsoft: '{{ pquota_default_rtbsoft }}'
rtbhard: '{{ pquota_default_rtbhard }}'
type: project
become: True
register: test_pquota_default_before
- name: Assert default project limits results
assert:
that:
- test_pquota_default_before.changed
- test_pquota_default_before.bsoft == pquota_default_bsoft|human_to_bytes
- test_pquota_default_before.bhard == pquota_default_bhard|human_to_bytes
- test_pquota_default_before.isoft == pquota_default_isoft
- test_pquota_default_before.ihard == pquota_default_ihard
- test_pquota_default_before.rtbsoft == pquota_default_rtbsoft|human_to_bytes
- test_pquota_default_before.rtbhard == pquota_default_rtbhard|human_to_bytes
- name: 'Apply project limits'
xfs_quota:
bsoft: '{{ pquota_project_bsoft }}'
bhard: '{{ pquota_project_bhard }}'
isoft: '{{ pquota_project_isoft }}'
ihard: '{{ pquota_project_ihard }}'
mountpoint: '{{ ansible_user_dir }}/ansible_testing/pquota'
name: xft_quotaval
rtbsoft: '{{ pquota_project_rtbsoft }}'
rtbhard: '{{ pquota_project_rtbhard }}'
type: project
become: True
register: test_pquota_project_before
- name: Assert project limits results for xft_quotaval
assert:
that:
- test_pquota_project_before.changed
- test_pquota_project_before.bsoft == pquota_project_bsoft|human_to_bytes
- test_pquota_project_before.bhard == pquota_project_bhard|human_to_bytes
- test_pquota_project_before.isoft == pquota_project_isoft
- test_pquota_project_before.ihard == pquota_project_ihard
- test_pquota_project_before.rtbsoft == pquota_project_rtbsoft|human_to_bytes
- test_pquota_project_before.rtbhard == pquota_project_rtbhard|human_to_bytes
- name: 'Re-apply default project limits'
xfs_quota:
bsoft: '{{ pquota_default_bsoft }}'
bhard: '{{ pquota_default_bhard }}'
isoft: '{{ pquota_default_isoft }}'
ihard: '{{ pquota_default_ihard }}'
mountpoint: '{{ ansible_user_dir }}/ansible_testing/pquota'
rtbsoft: '{{ pquota_default_rtbsoft }}'
rtbhard: '{{ pquota_default_rtbhard }}'
type: project
become: True
register: test_pquota_default_after
- name: Assert default project limits results after re-apply
assert:
that:
- not test_pquota_default_after.changed
- name: 'Re-apply project limits'
xfs_quota:
bsoft: '{{ pquota_project_bsoft }}'
bhard: '{{ pquota_project_bhard }}'
isoft: '{{ pquota_project_isoft }}'
ihard: '{{ pquota_project_ihard }}'
mountpoint: '{{ ansible_user_dir }}/ansible_testing/pquota'
name: xft_quotaval
rtbsoft: '{{ pquota_project_rtbsoft }}'
rtbhard: '{{ pquota_project_rtbhard }}'
type: project
become: True
register: test_pquota_project_after
- name: Assert project limits results for xft_quotaval after re-apply
assert:
that:
- not test_pquota_project_after.changed
- name: 'Reset default project limits'
xfs_quota:
mountpoint: '{{ ansible_user_dir }}/ansible_testing/pquota'
state: absent
type: project
become: True
register: test_reset_pquota_default
- name: Assert reset of default projecy limits results
assert:
that:
- test_reset_pquota_default.changed
- test_reset_pquota_default.bsoft == 0
- test_reset_pquota_default.bhard == 0
- test_reset_pquota_default.isoft == 0
- test_reset_pquota_default.ihard == 0
- test_reset_pquota_default.rtbsoft == 0
- test_reset_pquota_default.rtbhard == 0
- name: 'Reset project limits for xft_quotaval'
xfs_quota:
mountpoint: '{{ ansible_user_dir }}/ansible_testing/pquota'
name: xft_quotaval
state: absent
type: project
become: True
register: test_reset_pquota_project
- name: Assert reset of project limits results for xft_quotaval
assert:
that:
- test_reset_pquota_project.changed
- test_reset_pquota_project.bsoft == 0
- test_reset_pquota_project.bhard == 0
- test_reset_pquota_project.isoft == 0
- test_reset_pquota_project.ihard == 0
- test_reset_pquota_project.rtbsoft == 0
- test_reset_pquota_project.rtbhard == 0
always:
- name: 'Unmount filesystem'
mount:
fstab: '{{ ansible_user_dir }}/ansible_testing/fstab'
path: '{{ ansible_user_dir }}/ansible_testing/pquota'
state: unmounted
become: True
- name: Remove disk image
file:
path: '{{ ansible_user_dir }}/ansible_testing/img-pquota'
state: absent
- name: Remove xfs quota project id
lineinfile:
path: /etc/projid
regexp: '^xft_quotaval:99999$'
state: absent
become: True
- name: Remove xfs quota project path
lineinfile:
path: /etc/projects
regexp: '^99999:.*$'
state: absent
become: True