| 1 | --- |
| 2 | - name: User Quota Operations |
| 3 | hosts: localhost |
| 4 | connection: local |
| 5 | vars: |
| 6 | unispherehost: '10.*.*.*' |
| 7 | validate_certs: false |
| 8 | username: 'admin' |
| 9 | password: 'Password123!' |
| 10 | filesystem_name: "SP_Filesystem_test" |
| 11 | filesystem_id: "fs_2279" |
| 12 | nas_server_name: "lglad068" |
| 13 | user_name: "test2" |
| 14 | uid: "2" |
| 15 | tree_quota_id: "treequota_171798701972_1" |
| 16 | path: "/sample" |
| 17 | state_present: "present" |
| 18 | state_absent: "absent" |
| 19 | |
| 20 | tasks: |
| 21 | - name: Create user quota for a filesystem |
| 22 | register: result_user_quota |
| 23 | user_quota: |
| 24 | unispherehost: "{{ unispherehost }}" |
| 25 | username: "{{ username }}" |
| 26 | password: "{{ password }}" |
| 27 | validate_certs: "{{ validate_certs }}" |
| 28 | filesystem_name: "{{ filesystem_name }}" |
| 29 | nas_server_name: "{{ nas_server_name }}" |
| 30 | user_type: "Unix" |
| 31 | user_name: "{{ user_name }}" |
| 32 | soft_limit: "1" |
| 33 | cap_unit: "TB" |
| 34 | hard_limit: "2" |
| 35 | state: "{{ state_present }}" |
| 36 | |
| 37 | - name: Set user_quota_id |
| 38 | ansible.builtin.set_fact: |
| 39 | user_quota_id: "{{ result_user_quota.get_user_quota_details.id }}" |
| 40 | |
| 41 | - name: Create user quota for a filesystem -- Idempotency |
| 42 | register: result_user_quota |
| 43 | user_quota: |
| 44 | unispherehost: "{{ unispherehost }}" |
| 45 | username: "{{ username }}" |
| 46 | password: "{{ password }}" |
| 47 | validate_certs: "{{ validate_certs }}" |
| 48 | filesystem_name: "{{ filesystem_name }}" |
| 49 | nas_server_name: "{{ nas_server_name }}" |
| 50 | user_type: "Unix" |
| 51 | user_name: "{{ user_name }}" |
| 52 | soft_limit: "1" |
| 53 | cap_unit: "TB" |
| 54 | hard_limit: "2" |
| 55 | state: "{{ state_present }}" |
| 56 | |
| 57 | |
| 58 | - name: Get user quota details from user_name |
| 59 | user_quota: |
| 60 | unispherehost: "{{ unispherehost }}" |
| 61 | username: "{{ username }}" |
| 62 | password: "{{ password }}" |
| 63 | validate_certs: "{{ validate_certs }}" |
| 64 | filesystem_id: "{{ filesystem_id }}" |
| 65 | user_name: "{{ user_name }}" |
| 66 | state: "{{ state_present }}" |
| 67 | |
| 68 | - name: Modify user quota through user_quota_id |
| 69 | user_quota: |
| 70 | unispherehost: "{{ unispherehost }}" |
| 71 | username: "{{ username }}" |
| 72 | password: "{{ password }}" |
| 73 | validate_certs: "{{ validate_certs }}" |
| 74 | soft_limit: "900" |
| 75 | hard_limit: "1000" |
| 76 | user_quota_id: "{{ user_quota_id }}" |
| 77 | state: "{{ state_present }}" |
| 78 | |
| 79 | |
| 80 | - name: Modify user quota through user_quota_id -- Idempotency |
| 81 | user_quota: |
| 82 | unispherehost: "{{ unispherehost }}" |
| 83 | username: "{{ username }}" |
| 84 | password: "{{ password }}" |
| 85 | validate_certs: "{{ validate_certs }}" |
| 86 | soft_limit: "900" |
| 87 | hard_limit: "1000" |
| 88 | user_quota_id: "{{ user_quota_id }}" |
| 89 | state: "{{ state_present }}" |
| 90 | |
| 91 | - name: Modify user quota details from uid |
| 92 | user_quota: |
| 93 | unispherehost: "{{ unispherehost }}" |
| 94 | username: "{{ username }}" |
| 95 | password: "{{ password }}" |
| 96 | validate_certs: "{{ validate_certs }}" |
| 97 | filesystem_id: "{{ filesystem_id }}" |
| 98 | uid: "{{ uid }}" |
| 99 | soft_limit: "1" |
| 100 | cap_unit: "TB" |
| 101 | state: "{{ state_present }}" |
| 102 | |
| 103 | - name: Modify user quota details from uid -- Idempotency |
| 104 | user_quota: |
| 105 | unispherehost: "{{ unispherehost }}" |
| 106 | username: "{{ username }}" |
| 107 | password: "{{ password }}" |
| 108 | validate_certs: "{{ validate_certs }}" |
| 109 | filesystem_id: "{{ filesystem_id }}" |
| 110 | uid: "{{ uid }}" |
| 111 | soft_limit: "1" |
| 112 | cap_unit: "TB" |
| 113 | state: "{{ state_present }}" |
| 114 | |
| 115 | - name: Delete user quota |
| 116 | user_quota: |
| 117 | unispherehost: "{{ unispherehost }}" |
| 118 | username: "{{ username }}" |
| 119 | password: "{{ password }}" |
| 120 | validate_certs: "{{ validate_certs }}" |
| 121 | filesystem_id: "{{ filesystem_id }}" |
| 122 | user_name: "{{ user_name }}" |
| 123 | state: "{{ state_absent }}" |
| 124 | |
| 125 | - name: Delete user quota -- Idempotency |
| 126 | user_quota: |
| 127 | unispherehost: "{{ unispherehost }}" |
| 128 | username: "{{ username }}" |
| 129 | password: "{{ password }}" |
| 130 | validate_certs: "{{ validate_certs }}" |
| 131 | filesystem_id: "{{ filesystem_id }}" |
| 132 | user_name: "{{ user_name }}" |
| 133 | state: "{{ state_absent }}" |
| 134 | |
| 135 | - name: Create user quota for a quota tree |
| 136 | register: result_user_quota |
| 137 | user_quota: |
| 138 | unispherehost: "{{ unispherehost }}" |
| 139 | username: "{{ username }}" |
| 140 | password: "{{ password }}" |
| 141 | validate_certs: "{{ validate_certs }}" |
| 142 | filesystem_name: "{{ filesystem_name }}" |
| 143 | nas_server_name: "{{ nas_server_name }}" |
| 144 | path: "{{ path }}" |
| 145 | user_type: "Unix" |
| 146 | user_name: "{{ user_name }}" |
| 147 | soft_limit: "1" |
| 148 | cap_unit: "TB" |
| 149 | hard_limit: "2" |
| 150 | state: "{{ state_present }}" |
| 151 | |
| 152 | - name: Set user_quota_id for tree |
| 153 | ansible.builtin.set_fact: |
| 154 | user_quota_id: "{{ result_user_quota.get_user_quota_details.id }}" |
| 155 | |
| 156 | - name: Create user quota for a quota tree -- Idempotency |
| 157 | user_quota: |
| 158 | unispherehost: "{{ unispherehost }}" |
| 159 | username: "{{ username }}" |
| 160 | password: "{{ password }}" |
| 161 | validate_certs: "{{ validate_certs }}" |
| 162 | filesystem_name: "{{ filesystem_name }}" |
| 163 | nas_server_name: "{{ nas_server_name }}" |
| 164 | path: "{{ path }}" |
| 165 | user_type: "Unix" |
| 166 | user_name: "{{ user_name }}" |
| 167 | soft_limit: "1" |
| 168 | cap_unit: "TB" |
| 169 | hard_limit: "2" |
| 170 | state: "{{ state_present }}" |
| 171 | |
| 172 | - name: Modify user quota for a quota tree by path |
| 173 | user_quota: |
| 174 | unispherehost: "{{ unispherehost }}" |
| 175 | username: "{{ username }}" |
| 176 | password: "{{ password }}" |
| 177 | validate_certs: "{{ validate_certs }}" |
| 178 | filesystem_name: "{{ filesystem_name }}" |
| 179 | nas_server_name: "{{ nas_server_name }}" |
| 180 | path: "{{ path }}" |
| 181 | user_type: "Unix" |
| 182 | user_name: "{{ user_name }}" |
| 183 | soft_limit: "2" |
| 184 | cap_unit: "TB" |
| 185 | hard_limit: "2" |
| 186 | state: "{{ state_present }}" |
| 187 | |
| 188 | - name: Modify user quota for a quota tree by quota tree id |
| 189 | user_quota: |
| 190 | unispherehost: "{{ unispherehost }}" |
| 191 | username: "{{ username }}" |
| 192 | password: "{{ password }}" |
| 193 | validate_certs: "{{ validate_certs }}" |
| 194 | filesystem_name: "{{ filesystem_name }}" |
| 195 | nas_server_name: "{{ nas_server_name }}" |
| 196 | tree_quota_id: "{{ tree_quota_id }}" |
| 197 | user_type: "Unix" |
| 198 | user_name: "{{ user_name }}" |
| 199 | soft_limit: "800" |
| 200 | hard_limit: "900" |
| 201 | state: "{{ state_present }}" |
| 202 | |
| 203 | - name: Modify user quota for a quota tree by quota tree id -- Idempotency |
| 204 | user_quota: |
| 205 | unispherehost: "{{ unispherehost }}" |
| 206 | username: "{{ username }}" |
| 207 | password: "{{ password }}" |
| 208 | validate_certs: "{{ validate_certs }}" |
| 209 | filesystem_name: "{{ filesystem_name }}" |
| 210 | nas_server_name: "{{ nas_server_name }}" |
| 211 | tree_quota_id: "{{ tree_quota_id }}" |
| 212 | user_type: "Unix" |
| 213 | user_name: "{{ user_name }}" |
| 214 | soft_limit: "800" |
| 215 | hard_limit: "900" |
| 216 | state: "{{ state_present }}" |
| 217 | |
| 218 | - name: Delete user quota for a quota tree by quota tree id |
| 219 | user_quota: |
| 220 | unispherehost: "{{ unispherehost }}" |
| 221 | username: "{{ username }}" |
| 222 | password: "{{ password }}" |
| 223 | validate_certs: "{{ validate_certs }}" |
| 224 | filesystem_name: "{{ filesystem_name }}" |
| 225 | nas_server_name: "{{ nas_server_name }}" |
| 226 | tree_quota_id: "{{ tree_quota_id }}" |
| 227 | user_type: "Unix" |
| 228 | user_name: "{{ user_name }}" |
| 229 | state: "{{ state_absent }}" |
| 230 | |
| 231 | - name: Delete user quota for a quota tree by path |
| 232 | user_quota: |
| 233 | unispherehost: "{{ unispherehost }}" |
| 234 | username: "{{ username }}" |
| 235 | password: "{{ password }}" |
| 236 | validate_certs: "{{ validate_certs }}" |
| 237 | filesystem_name: "{{ filesystem_name }}" |
| 238 | nas_server_name: "{{ nas_server_name }}" |
| 239 | path: "{{ path }}" |
| 240 | user_type: "Unix" |
| 241 | user_name: "{{ user_name }}" |
| 242 | state: "{{ state_absent }}" |
| 243 | |
| 244 | - name: Delete user quota for a quota tree by path -- Idempotency |
| 245 | user_quota: |
| 246 | unispherehost: "{{ unispherehost }}" |
| 247 | username: "{{ username }}" |
| 248 | password: "{{ password }}" |
| 249 | validate_certs: "{{ validate_certs }}" |
| 250 | filesystem_name: "{{ filesystem_name }}" |
| 251 | nas_server_name: "{{ nas_server_name }}" |
| 252 | path: "{{ path }}" |
| 253 | user_type: "Unix" |
| 254 | user_name: "{{ user_name }}" |
| 255 | state: "{{ state_absent }}" |