mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-03 23:14:02 -07:00
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
This commit is contained in:
parent
889024e101
commit
993727ff5e
7 changed files with 1016 additions and 0 deletions
5
test/integration/targets/xfs_quota/aliases
Normal file
5
test/integration/targets/xfs_quota/aliases
Normal file
|
@ -0,0 +1,5 @@
|
|||
needs/privileged
|
||||
needs/root
|
||||
shippable/posix/group1
|
||||
skip/osx
|
||||
skip/freebsd
|
42
test/integration/targets/xfs_quota/defaults/main.yml
Normal file
42
test/integration/targets/xfs_quota/defaults/main.yml
Normal file
|
@ -0,0 +1,42 @@
|
|||
---
|
||||
uquota_default_bsoft: 1m
|
||||
uquota_default_bhard: 2m
|
||||
uquota_default_isoft: 100
|
||||
uquota_default_ihard: 200
|
||||
uquota_default_rtbsoft: 1m
|
||||
uquota_default_rtbhard: 2m
|
||||
|
||||
uquota_user_bsoft: 2m
|
||||
uquota_user_bhard: 3m
|
||||
uquota_user_isoft: 300
|
||||
uquota_user_ihard: 400
|
||||
uquota_user_rtbsoft: 3m
|
||||
uquota_user_rtbhard: 4m
|
||||
|
||||
gquota_default_bsoft: 1m
|
||||
gquota_default_bhard: 2m
|
||||
gquota_default_isoft: 100
|
||||
gquota_default_ihard: 200
|
||||
gquota_default_rtbsoft: 1m
|
||||
gquota_default_rtbhard: 2m
|
||||
|
||||
gquota_group_bsoft: 2m
|
||||
gquota_group_bhard: 3m
|
||||
gquota_group_isoft: 300
|
||||
gquota_group_ihard: 400
|
||||
gquota_group_rtbsoft: 3m
|
||||
gquota_group_rtbhard: 4m
|
||||
|
||||
pquota_default_bsoft: 1m
|
||||
pquota_default_bhard: 2m
|
||||
pquota_default_isoft: 100
|
||||
pquota_default_ihard: 200
|
||||
pquota_default_rtbsoft: 1m
|
||||
pquota_default_rtbhard: 2m
|
||||
|
||||
pquota_project_bsoft: 2m
|
||||
pquota_project_bhard: 3m
|
||||
pquota_project_isoft: 300
|
||||
pquota_project_ihard: 400
|
||||
pquota_project_rtbsoft: 3m
|
||||
pquota_project_rtbhard: 4m
|
158
test/integration/targets/xfs_quota/tasks/gquota.yml
Normal file
158
test/integration/targets/xfs_quota/tasks/gquota.yml
Normal file
|
@ -0,0 +1,158 @@
|
|||
---
|
||||
- name: 'Create disk image'
|
||||
command: >
|
||||
dd if=/dev/zero of={{ ansible_user_dir }}/ansible_testing/img-gquota bs=1M count=20
|
||||
|
||||
- name: 'Create XFS filesystem'
|
||||
filesystem:
|
||||
dev: '{{ ansible_user_dir }}/ansible_testing/img-gquota'
|
||||
fstype: xfs
|
||||
|
||||
- block:
|
||||
- name: 'Mount filesystem'
|
||||
mount:
|
||||
fstab: '{{ ansible_user_dir }}/ansible_testing/fstab'
|
||||
src: '{{ ansible_user_dir }}/ansible_testing/img-gquota'
|
||||
path: '{{ ansible_user_dir }}/ansible_testing/gquota'
|
||||
fstype: xfs
|
||||
opts: gquota
|
||||
state: mounted
|
||||
become: True
|
||||
|
||||
- name: 'Apply default group limits'
|
||||
xfs_quota:
|
||||
bsoft: '{{ gquota_default_bsoft }}'
|
||||
bhard: '{{ gquota_default_bhard }}'
|
||||
isoft: '{{ gquota_default_isoft }}'
|
||||
ihard: '{{ gquota_default_ihard }}'
|
||||
mountpoint: '{{ ansible_user_dir }}/ansible_testing/gquota'
|
||||
rtbsoft: '{{ gquota_default_rtbsoft }}'
|
||||
rtbhard: '{{ gquota_default_rtbhard }}'
|
||||
type: group
|
||||
become: True
|
||||
register: test_gquota_default_before
|
||||
|
||||
- name: Assert default group limits results
|
||||
assert:
|
||||
that:
|
||||
- test_gquota_default_before.changed
|
||||
- test_gquota_default_before.bsoft == gquota_default_bsoft|human_to_bytes
|
||||
- test_gquota_default_before.bhard == gquota_default_bhard|human_to_bytes
|
||||
- test_gquota_default_before.isoft == gquota_default_isoft
|
||||
- test_gquota_default_before.ihard == gquota_default_ihard
|
||||
- test_gquota_default_before.rtbsoft == gquota_default_rtbsoft|human_to_bytes
|
||||
- test_gquota_default_before.rtbhard == gquota_default_rtbhard|human_to_bytes
|
||||
|
||||
- name: 'Apply group limits'
|
||||
xfs_quota:
|
||||
bsoft: '{{ gquota_group_bsoft }}'
|
||||
bhard: '{{ gquota_group_bhard }}'
|
||||
isoft: '{{ gquota_group_isoft }}'
|
||||
ihard: '{{ gquota_group_ihard }}'
|
||||
mountpoint: '{{ ansible_user_dir }}/ansible_testing/gquota'
|
||||
name: xfsquotauser
|
||||
rtbsoft: '{{ gquota_group_rtbsoft }}'
|
||||
rtbhard: '{{ gquota_group_rtbhard }}'
|
||||
type: group
|
||||
become: True
|
||||
register: test_gquota_group_before
|
||||
|
||||
- name: Assert group limits results for xfsquotauser
|
||||
assert:
|
||||
that:
|
||||
- test_gquota_group_before.changed
|
||||
- test_gquota_group_before.bsoft == gquota_group_bsoft|human_to_bytes
|
||||
- test_gquota_group_before.bhard == gquota_group_bhard|human_to_bytes
|
||||
- test_gquota_group_before.isoft == gquota_group_isoft
|
||||
- test_gquota_group_before.ihard == gquota_group_ihard
|
||||
- test_gquota_group_before.rtbsoft == gquota_group_rtbsoft|human_to_bytes
|
||||
- test_gquota_group_before.rtbhard == gquota_group_rtbhard|human_to_bytes
|
||||
|
||||
- name: 'Re-apply default group limits'
|
||||
xfs_quota:
|
||||
bsoft: '{{ gquota_default_bsoft }}'
|
||||
bhard: '{{ gquota_default_bhard }}'
|
||||
isoft: '{{ gquota_default_isoft }}'
|
||||
ihard: '{{ gquota_default_ihard }}'
|
||||
mountpoint: '{{ ansible_user_dir }}/ansible_testing/gquota'
|
||||
rtbsoft: '{{ gquota_default_rtbsoft }}'
|
||||
rtbhard: '{{ gquota_default_rtbhard }}'
|
||||
type: group
|
||||
become: True
|
||||
register: test_gquota_default_after
|
||||
|
||||
- name: Assert default group limits results after re-apply
|
||||
assert:
|
||||
that:
|
||||
- not test_gquota_default_after.changed
|
||||
|
||||
- name: 'Re-apply group limits'
|
||||
xfs_quota:
|
||||
bsoft: '{{ gquota_group_bsoft }}'
|
||||
bhard: '{{ gquota_group_bhard }}'
|
||||
isoft: '{{ gquota_group_isoft }}'
|
||||
ihard: '{{ gquota_group_ihard }}'
|
||||
mountpoint: '{{ ansible_user_dir }}/ansible_testing/gquota'
|
||||
name: xfsquotauser
|
||||
rtbsoft: '{{ gquota_group_rtbsoft }}'
|
||||
rtbhard: '{{ gquota_group_rtbhard }}'
|
||||
type: group
|
||||
become: True
|
||||
register: test_gquota_group_after
|
||||
|
||||
- name: Assert group limits results for xfsquotauser after re-apply
|
||||
assert:
|
||||
that:
|
||||
- not test_gquota_group_after.changed
|
||||
|
||||
- name: 'Reset default group limits'
|
||||
xfs_quota:
|
||||
mountpoint: '{{ ansible_user_dir }}/ansible_testing/gquota'
|
||||
state: absent
|
||||
type: group
|
||||
become: True
|
||||
register: test_reset_gquota_default
|
||||
|
||||
- name: Assert reset of default group limits results
|
||||
assert:
|
||||
that:
|
||||
- test_reset_gquota_default.changed
|
||||
- test_reset_gquota_default.bsoft == 0
|
||||
- test_reset_gquota_default.bhard == 0
|
||||
- test_reset_gquota_default.isoft == 0
|
||||
- test_reset_gquota_default.ihard == 0
|
||||
- test_reset_gquota_default.rtbsoft == 0
|
||||
- test_reset_gquota_default.rtbhard == 0
|
||||
|
||||
- name: 'Reset group limits for xfsquotauser'
|
||||
xfs_quota:
|
||||
mountpoint: '{{ ansible_user_dir }}/ansible_testing/gquota'
|
||||
name: xfsquotauser
|
||||
state: absent
|
||||
type: group
|
||||
become: True
|
||||
register: test_reset_gquota_group
|
||||
|
||||
- name: Assert reset of default group limits results
|
||||
assert:
|
||||
that:
|
||||
- test_reset_gquota_group.changed
|
||||
- test_reset_gquota_group.bsoft == 0
|
||||
- test_reset_gquota_group.bhard == 0
|
||||
- test_reset_gquota_group.isoft == 0
|
||||
- test_reset_gquota_group.ihard == 0
|
||||
- test_reset_gquota_group.rtbsoft == 0
|
||||
- test_reset_gquota_group.rtbhard == 0
|
||||
|
||||
always:
|
||||
- name: 'Unmount filesystem'
|
||||
mount:
|
||||
fstab: '{{ ansible_user_dir }}/ansible_testing/fstab'
|
||||
path: '{{ ansible_user_dir }}/ansible_testing/gquota'
|
||||
state: unmounted
|
||||
become: True
|
||||
|
||||
- name: Remove disk image
|
||||
file:
|
||||
path: '{{ ansible_user_dir }}/ansible_testing/img-gquota'
|
||||
state: absent
|
18
test/integration/targets/xfs_quota/tasks/main.yml
Normal file
18
test/integration/targets/xfs_quota/tasks/main.yml
Normal file
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
- block:
|
||||
- name: Create test user
|
||||
user:
|
||||
name: xfsquotauser
|
||||
state: present
|
||||
become: yes
|
||||
|
||||
- include_tasks: uquota.yml
|
||||
- include_tasks: gquota.yml
|
||||
- include_tasks: pquota.yml
|
||||
|
||||
always:
|
||||
- name: cleanup test user
|
||||
user:
|
||||
name: xfsquotauser
|
||||
state: absent
|
||||
become: yes
|
202
test/integration/targets/xfs_quota/tasks/pquota.yml
Normal file
202
test/integration/targets/xfs_quota/tasks/pquota.yml
Normal file
|
@ -0,0 +1,202 @@
|
|||
---
|
||||
- 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
|
158
test/integration/targets/xfs_quota/tasks/uquota.yml
Normal file
158
test/integration/targets/xfs_quota/tasks/uquota.yml
Normal file
|
@ -0,0 +1,158 @@
|
|||
---
|
||||
- name: 'Create disk image'
|
||||
command: >
|
||||
dd if=/dev/zero of={{ ansible_user_dir }}/ansible_testing/img-uquota bs=1M count=20
|
||||
|
||||
- name: 'Create XFS filesystem'
|
||||
filesystem:
|
||||
dev: '{{ ansible_user_dir }}/ansible_testing/img-uquota'
|
||||
fstype: xfs
|
||||
|
||||
- block:
|
||||
- name: 'Mount filesystem'
|
||||
mount:
|
||||
fstab: '{{ ansible_user_dir }}/ansible_testing/fstab'
|
||||
src: '{{ ansible_user_dir }}/ansible_testing/img-uquota'
|
||||
path: '{{ ansible_user_dir }}/ansible_testing/uquota'
|
||||
fstype: xfs
|
||||
opts: uquota
|
||||
state: mounted
|
||||
become: True
|
||||
|
||||
- name: 'Apply default user limits'
|
||||
xfs_quota:
|
||||
bsoft: '{{ uquota_default_bsoft }}'
|
||||
bhard: '{{ uquota_default_bhard }}'
|
||||
isoft: '{{ uquota_default_isoft }}'
|
||||
ihard: '{{ uquota_default_ihard }}'
|
||||
mountpoint: '{{ ansible_user_dir }}/ansible_testing/uquota'
|
||||
rtbsoft: '{{ uquota_default_rtbsoft }}'
|
||||
rtbhard: '{{ uquota_default_rtbhard }}'
|
||||
type: user
|
||||
become: True
|
||||
register: test_uquota_default_before
|
||||
|
||||
- name: Assert default user limits results
|
||||
assert:
|
||||
that:
|
||||
- test_uquota_default_before.changed
|
||||
- test_uquota_default_before.bsoft == uquota_default_bsoft|human_to_bytes
|
||||
- test_uquota_default_before.bhard == uquota_default_bhard|human_to_bytes
|
||||
- test_uquota_default_before.isoft == uquota_default_isoft
|
||||
- test_uquota_default_before.ihard == uquota_default_ihard
|
||||
- test_uquota_default_before.rtbsoft == uquota_default_rtbsoft|human_to_bytes
|
||||
- test_uquota_default_before.rtbhard == uquota_default_rtbhard|human_to_bytes
|
||||
|
||||
- name: 'Apply user limits'
|
||||
xfs_quota:
|
||||
bsoft: '{{ uquota_user_bsoft }}'
|
||||
bhard: '{{ uquota_user_bhard }}'
|
||||
isoft: '{{ uquota_user_isoft }}'
|
||||
ihard: '{{ uquota_user_ihard }}'
|
||||
mountpoint: '{{ ansible_user_dir }}/ansible_testing/uquota'
|
||||
name: xfsquotauser
|
||||
rtbsoft: '{{ uquota_user_rtbsoft }}'
|
||||
rtbhard: '{{ uquota_user_rtbhard }}'
|
||||
type: user
|
||||
become: True
|
||||
register: test_uquota_user_before
|
||||
|
||||
- name: Assert user limits results
|
||||
assert:
|
||||
that:
|
||||
- test_uquota_user_before.changed
|
||||
- test_uquota_user_before.bsoft == uquota_user_bsoft|human_to_bytes
|
||||
- test_uquota_user_before.bhard == uquota_user_bhard|human_to_bytes
|
||||
- test_uquota_user_before.isoft == uquota_user_isoft
|
||||
- test_uquota_user_before.ihard == uquota_user_ihard
|
||||
- test_uquota_user_before.rtbsoft == uquota_user_rtbsoft|human_to_bytes
|
||||
- test_uquota_user_before.rtbhard == uquota_user_rtbhard|human_to_bytes
|
||||
|
||||
- name: 'Re-apply default user limits'
|
||||
xfs_quota:
|
||||
bsoft: '{{ uquota_default_bsoft }}'
|
||||
bhard: '{{ uquota_default_bhard }}'
|
||||
isoft: '{{ uquota_default_isoft }}'
|
||||
ihard: '{{ uquota_default_ihard }}'
|
||||
mountpoint: '{{ ansible_user_dir }}/ansible_testing/uquota'
|
||||
rtbsoft: '{{ uquota_default_rtbsoft }}'
|
||||
rtbhard: '{{ uquota_default_rtbhard }}'
|
||||
type: user
|
||||
become: True
|
||||
register: test_uquota_default_after
|
||||
|
||||
- name: Assert default user limits results after re-apply
|
||||
assert:
|
||||
that:
|
||||
- not test_uquota_default_after.changed
|
||||
|
||||
- name: 'Re-apply user limits'
|
||||
xfs_quota:
|
||||
bsoft: '{{ uquota_user_bsoft }}'
|
||||
bhard: '{{ uquota_user_bhard }}'
|
||||
isoft: '{{ uquota_user_isoft }}'
|
||||
ihard: '{{ uquota_user_ihard }}'
|
||||
mountpoint: '{{ ansible_user_dir }}/ansible_testing/uquota'
|
||||
name: xfsquotauser
|
||||
rtbsoft: '{{ uquota_user_rtbsoft }}'
|
||||
rtbhard: '{{ uquota_user_rtbhard }}'
|
||||
type: user
|
||||
become: True
|
||||
register: test_uquota_user_after
|
||||
|
||||
- name: Assert user limits results for xfsquotauser after re-apply
|
||||
assert:
|
||||
that:
|
||||
- not test_uquota_user_after.changed
|
||||
|
||||
- name: 'Reset default user limits'
|
||||
xfs_quota:
|
||||
mountpoint: '{{ ansible_user_dir }}/ansible_testing/uquota'
|
||||
state: absent
|
||||
type: user
|
||||
become: True
|
||||
register: test_reset_uquota_default
|
||||
|
||||
- name: Assert reset of default user limits results
|
||||
assert:
|
||||
that:
|
||||
- test_reset_uquota_default.changed
|
||||
- test_reset_uquota_default.bsoft == 0
|
||||
- test_reset_uquota_default.bhard == 0
|
||||
- test_reset_uquota_default.isoft == 0
|
||||
- test_reset_uquota_default.ihard == 0
|
||||
- test_reset_uquota_default.rtbsoft == 0
|
||||
- test_reset_uquota_default.rtbhard == 0
|
||||
|
||||
- name: 'Reset user limits for xfsquotauser'
|
||||
xfs_quota:
|
||||
mountpoint: '{{ ansible_user_dir }}/ansible_testing/uquota'
|
||||
name: xfsquotauser
|
||||
state: absent
|
||||
type: user
|
||||
become: True
|
||||
register: test_reset_uquota_user
|
||||
|
||||
- name: Assert reset of default user limits results
|
||||
assert:
|
||||
that:
|
||||
- test_reset_uquota_user.changed
|
||||
- test_reset_uquota_user.bsoft == 0
|
||||
- test_reset_uquota_user.bhard == 0
|
||||
- test_reset_uquota_user.isoft == 0
|
||||
- test_reset_uquota_user.ihard == 0
|
||||
- test_reset_uquota_user.rtbsoft == 0
|
||||
- test_reset_uquota_user.rtbhard == 0
|
||||
|
||||
always:
|
||||
- name: 'Unmount filesystem'
|
||||
mount:
|
||||
fstab: '{{ ansible_user_dir }}/ansible_testing/fstab'
|
||||
path: '{{ ansible_user_dir }}/ansible_testing/uquota'
|
||||
state: unmounted
|
||||
become: True
|
||||
|
||||
- name: Remove disk image
|
||||
file:
|
||||
path: '{{ ansible_user_dir }}/ansible_testing/img-uquota'
|
||||
state: absent
|
Loading…
Add table
Add a link
Reference in a new issue