Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/xfs_quota/tasks/pquota.yml

raw symbols SCIP
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 - name: Create disk image
7 command: 'dd if=/dev/zero of={{ remote_tmp_dir }}/img-pquota bs=1M count=400
8
9 '
10 - name: Create XFS filesystem
11 filesystem:
12 dev: '{{ remote_tmp_dir }}/img-pquota'
13 fstype: xfs
14 - name: Create xfs related files
15 file:
16 path: /etc/{{ item }}
17 state: touch
18 become: true
19 loop:
20 - projid
21 - projects
22 - name: Add test xfs quota project id
23 lineinfile:
24 path: /etc/projid
25 line: xft_quotaval:99999
26 state: present
27 become: true
28 - name: Add test xfs quota project path
29 lineinfile:
30 path: /etc/projects
31 line: 99999:{{ remote_tmp_dir }}/pquota/test
32 state: present
33 become: true
34 - block:
35 - name: Mount filesystem
36 become: true
37 ansible.posix.mount:
38 fstab: '{{ remote_tmp_dir }}/fstab'
39 src: '{{ remote_tmp_dir }}/img-pquota'
40 path: '{{ remote_tmp_dir }}/pquota'
41 fstype: xfs
42 opts: pquota
43 state: mounted
44 - name: Create test directory
45 file:
46 path: '{{ remote_tmp_dir }}/pquota/test'
47 state: directory
48 become: true
49 - name: Apply default project limits
50 xfs_quota:
51 bsoft: '{{ pquota_default_bsoft }}'
52 bhard: '{{ pquota_default_bhard }}'
53 isoft: '{{ pquota_default_isoft }}'
54 ihard: '{{ pquota_default_ihard }}'
55 mountpoint: '{{ remote_tmp_dir }}/pquota'
56 rtbsoft: '{{ pquota_default_rtbsoft }}'
57 rtbhard: '{{ pquota_default_rtbhard }}'
58 type: project
59 become: true
60 register: test_pquota_default_before
61 - name: Assert default project limits results
62 assert:
63 that:
64 - test_pquota_default_before.changed
65 - test_pquota_default_before.bsoft == pquota_default_bsoft|human_to_bytes
66 - test_pquota_default_before.bhard == pquota_default_bhard|human_to_bytes
67 - test_pquota_default_before.isoft == pquota_default_isoft
68 - test_pquota_default_before.ihard == pquota_default_ihard
69 - test_pquota_default_before.rtbsoft == pquota_default_rtbsoft|human_to_bytes
70 - test_pquota_default_before.rtbhard == pquota_default_rtbhard|human_to_bytes
71 - name: Apply project limits
72 xfs_quota:
73 bsoft: '{{ pquota_project_bsoft }}'
74 bhard: '{{ pquota_project_bhard }}'
75 isoft: '{{ pquota_project_isoft }}'
76 ihard: '{{ pquota_project_ihard }}'
77 mountpoint: '{{ remote_tmp_dir }}/pquota'
78 name: xft_quotaval
79 rtbsoft: '{{ pquota_project_rtbsoft }}'
80 rtbhard: '{{ pquota_project_rtbhard }}'
81 type: project
82 become: true
83 register: test_pquota_project_before
84 - name: Assert project limits results for xft_quotaval
85 assert:
86 that:
87 - test_pquota_project_before.changed
88 - test_pquota_project_before.bsoft == pquota_project_bsoft|human_to_bytes
89 - test_pquota_project_before.bhard == pquota_project_bhard|human_to_bytes
90 - test_pquota_project_before.isoft == pquota_project_isoft
91 - test_pquota_project_before.ihard == pquota_project_ihard
92 - test_pquota_project_before.rtbsoft == pquota_project_rtbsoft|human_to_bytes
93 - test_pquota_project_before.rtbhard == pquota_project_rtbhard|human_to_bytes
94 - name: Re-apply default project limits
95 xfs_quota:
96 bsoft: '{{ pquota_default_bsoft }}'
97 bhard: '{{ pquota_default_bhard }}'
98 isoft: '{{ pquota_default_isoft }}'
99 ihard: '{{ pquota_default_ihard }}'
100 mountpoint: '{{ remote_tmp_dir }}/pquota'
101 rtbsoft: '{{ pquota_default_rtbsoft }}'
102 rtbhard: '{{ pquota_default_rtbhard }}'
103 type: project
104 become: true
105 register: test_pquota_default_after
106 - name: Assert default project limits results after re-apply
107 assert:
108 that:
109 - not test_pquota_default_after.changed
110 - name: Re-apply project limits
111 xfs_quota:
112 bsoft: '{{ pquota_project_bsoft }}'
113 bhard: '{{ pquota_project_bhard }}'
114 isoft: '{{ pquota_project_isoft }}'
115 ihard: '{{ pquota_project_ihard }}'
116 mountpoint: '{{ remote_tmp_dir }}/pquota'
117 name: xft_quotaval
118 rtbsoft: '{{ pquota_project_rtbsoft }}'
119 rtbhard: '{{ pquota_project_rtbhard }}'
120 type: project
121 become: true
122 register: test_pquota_project_after
123 - name: Assert project limits results for xft_quotaval after re-apply
124 assert:
125 that:
126 - test_pquota_project_after is not changed
127 - name: Reset default project limits
128 xfs_quota:
129 mountpoint: '{{ remote_tmp_dir }}/pquota'
130 state: absent
131 type: project
132 become: true
133 register: test_reset_pquota_default
134 - name: Assert reset of default projecy limits results
135 assert:
136 that:
137 - test_reset_pquota_default.changed
138 - test_reset_pquota_default.bsoft == 0
139 - test_reset_pquota_default.bhard == 0
140 - test_reset_pquota_default.isoft == 0
141 - test_reset_pquota_default.ihard == 0
142 - test_reset_pquota_default.rtbsoft == 0
143 - test_reset_pquota_default.rtbhard == 0
144 - name: Reset project limits for xft_quotaval
145 xfs_quota:
146 mountpoint: '{{ remote_tmp_dir }}/pquota'
147 name: xft_quotaval
148 state: absent
149 type: project
150 become: true
151 register: test_reset_pquota_project
152 - name: Assert reset of project limits results for xft_quotaval
153 assert:
154 that:
155 - test_reset_pquota_project.changed
156 - test_reset_pquota_project.bsoft == 0
157 - test_reset_pquota_project.bhard == 0
158 - test_reset_pquota_project.isoft == 0
159 - test_reset_pquota_project.ihard == 0
160 - test_reset_pquota_project.rtbsoft == 0
161 - test_reset_pquota_project.rtbhard == 0
162 always:
163 - name: Unmount filesystem
164 become: true
165 ansible.posix.mount:
166 fstab: '{{ remote_tmp_dir }}/fstab'
167 path: '{{ remote_tmp_dir }}/pquota'
168 state: unmounted
169 - name: Remove disk image
170 file:
171 path: '{{ remote_tmp_dir }}/img-pquota'
172 state: absent
173 - name: Remove xfs quota project id
174 lineinfile:
175 path: /etc/projid
176 regexp: ^xft_quotaval:99999$
177 state: absent
178 become: true
179 - name: Remove xfs quota project path
180 lineinfile:
181 path: /etc/projects
182 regexp: ^99999:.*$
183 state: absent
184 become: true