| 1 |
--- |
| 2 |
- name: SMB Share Module Operations in Unity |
| 3 |
hosts: localhost |
| 4 |
connection: local |
| 5 |
vars: |
| 6 |
unispherehost: '10.*.*.*' |
| 7 |
validate_certs: false |
| 8 |
username: 'user' |
| 9 |
password: '**' |
| 10 |
filesystem_name: "ansible_smb_share_fs" |
| 11 |
snapshot_name: "ansible_smb_share_snap" |
| 12 |
nas_server_name: "lglad071" |
| 13 |
description: "Share is created using playbook" |
| 14 |
new_description: "modified the description of share using playbook" |
| 15 |
fs_share_name: "ansible_share_2" |
| 16 |
snap_share_name: "ansible_share_21" |
| 17 |
tasks: |
| 18 |
- name: Create a SMB Share for Filesystem |
| 19 |
register: smb_result |
| 20 |
smbshare: |
| 21 |
unispherehost: "{{ unispherehost }}" |
| 22 |
username: "{{ username }}" |
| 23 |
password: "{{ password }}" |
| 24 |
validate_certs: "{{ validate_certs }}" |
| 25 |
share_name: "{{ fs_share_name }}" |
| 26 |
path: "/" |
| 27 |
filesystem_name: "{{ filesystem_name }}" |
| 28 |
nas_server_name: "{{ nas_server_name }}" |
| 29 |
umask: "000" |
| 30 |
description: "Added description of filesystem SMB share during creation" |
| 31 |
offline_availability: "PROGRAMS" |
| 32 |
is_abe_enabled: true |
| 33 |
is_branch_cache_enabled: true |
| 34 |
is_continuous_availability_enabled: true |
| 35 |
is_encryption_enabled: true |
| 36 |
state: "present" |
| 37 |
|
| 38 |
- name: Set Snapshot SMB Share ID |
| 39 |
ansible.builtin.set_fact: |
| 40 |
fs_share_id: "{{ smb_result.smb_share_details.id }}" |
| 41 |
|
| 42 |
- name: Create a SMB Share for Filesystem Idempotency |
| 43 |
smbshare: |
| 44 |
unispherehost: "{{ unispherehost }}" |
| 45 |
username: "{{ username }}" |
| 46 |
password: "{{ password }}" |
| 47 |
validate_certs: "{{ validate_certs }}" |
| 48 |
share_name: "{{ fs_share_name }}" |
| 49 |
path: "/" |
| 50 |
filesystem_name: "{{ filesystem_name }}" |
| 51 |
nas_server_name: "{{ nas_server_name }}" |
| 52 |
umask: "000" |
| 53 |
description: "Added description of filesystem SMB share during creation" |
| 54 |
offline_availability: "PROGRAMS" |
| 55 |
is_abe_enabled: true |
| 56 |
is_branch_cache_enabled: true |
| 57 |
is_continuous_availability_enabled: true |
| 58 |
is_encryption_enabled: true |
| 59 |
state: "present" |
| 60 |
|
| 61 |
- name: Get SMB Share Details using Name |
| 62 |
smbshare: |
| 63 |
unispherehost: "{{ unispherehost }}" |
| 64 |
username: "{{ username }}" |
| 65 |
password: "{{ password }}" |
| 66 |
validate_certs: "{{ validate_certs }}" |
| 67 |
share_name: "{{ fs_share_name }}" |
| 68 |
filesystem_id: "fs_65" |
| 69 |
state: "present" |
| 70 |
|
| 71 |
- name: Update the details of the SMB share |
| 72 |
smbshare: |
| 73 |
unispherehost: "{{ unispherehost }}" |
| 74 |
username: "{{ username }}" |
| 75 |
password: "{{ password }}" |
| 76 |
validate_certs: "{{ validate_certs }}" |
| 77 |
share_name: "{{ fs_share_name }}" |
| 78 |
filesystem_id: "fs_65" |
| 79 |
umask: "777" |
| 80 |
description: "updated description of filesystem SMB share" |
| 81 |
offline_availability: "DOCUMENTS" |
| 82 |
is_abe_enabled: false |
| 83 |
is_branch_cache_enabled: false |
| 84 |
is_continuous_availability_enabled: false |
| 85 |
is_encryption_enabled: false |
| 86 |
state: "present" |
| 87 |
|
| 88 |
- name: Update the details of the SMB share Idempotency |
| 89 |
smbshare: |
| 90 |
unispherehost: "{{ unispherehost }}" |
| 91 |
username: "{{ username }}" |
| 92 |
password: "{{ password }}" |
| 93 |
validate_certs: "{{ validate_certs }}" |
| 94 |
share_name: "{{ fs_share_name }}" |
| 95 |
filesystem_id: "fs_65" |
| 96 |
umask: "777" |
| 97 |
description: "updated description of filesystem SMB share" |
| 98 |
offline_availability: "DOCUMENTS" |
| 99 |
is_abe_enabled: false |
| 100 |
is_branch_cache_enabled: false |
| 101 |
is_continuous_availability_enabled: false |
| 102 |
is_encryption_enabled: false |
| 103 |
state: "present" |
| 104 |
|
| 105 |
- name: Delete SMB share for Filesystem |
| 106 |
smbshare: |
| 107 |
unispherehost: "{{ unispherehost }}" |
| 108 |
username: "{{ username }}" |
| 109 |
password: "{{ password }}" |
| 110 |
validate_certs: "{{ validate_certs }}" |
| 111 |
share_name: "{{ fs_share_name }}" |
| 112 |
filesystem_id: "fs_65" |
| 113 |
state: "absent" |
| 114 |
|
| 115 |
- name: Delete SMB share for Filesystem Idempotency |
| 116 |
smbshare: |
| 117 |
unispherehost: "{{ unispherehost }}" |
| 118 |
username: "{{ username }}" |
| 119 |
password: "{{ password }}" |
| 120 |
validate_certs: "{{ validate_certs }}" |
| 121 |
share_name: "{{ fs_share_name }}" |
| 122 |
filesystem_id: "fs_65" |
| 123 |
state: "absent" |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
- name: Create a SMB Share for Snapshot |
| 128 |
register: smb_result |
| 129 |
smbshare: |
| 130 |
unispherehost: "{{ unispherehost }}" |
| 131 |
username: "{{ username }}" |
| 132 |
password: "{{ password }}" |
| 133 |
validate_certs: "{{ validate_certs }}" |
| 134 |
share_name: "{{ snap_share_name }}" |
| 135 |
path: "/" |
| 136 |
snapshot_name: "{{ snapshot_name }}" |
| 137 |
umask: "000" |
| 138 |
description: "Added description of Snapshot SMB share during creation" |
| 139 |
offline_availability: "PROGRAMS" |
| 140 |
is_abe_enabled: true |
| 141 |
is_branch_cache_enabled: true |
| 142 |
is_continuous_availability_enabled: true |
| 143 |
is_encryption_enabled: true |
| 144 |
state: "present" |
| 145 |
|
| 146 |
- name: Set Snapshot SMB Share ID for Snapshot |
| 147 |
ansible.builtin.set_fact: |
| 148 |
snap_share_id: "{{ smb_result.smb_share_details.id }}" |
| 149 |
|
| 150 |
- name: Create a SMB Share for Snapshot Idempotency |
| 151 |
smbshare: |
| 152 |
unispherehost: "{{ unispherehost }}" |
| 153 |
username: "{{ username }}" |
| 154 |
password: "{{ password }}" |
| 155 |
validate_certs: "{{ validate_certs }}" |
| 156 |
share_name: "{{ snap_share_name }}" |
| 157 |
path: "/" |
| 158 |
snapshot_name: "{{ snapshot_name }}" |
| 159 |
umask: "000" |
| 160 |
description: "Added description of Snapshot SMB share during creation" |
| 161 |
offline_availability: "PROGRAMS" |
| 162 |
is_abe_enabled: true |
| 163 |
is_branch_cache_enabled: true |
| 164 |
is_continuous_availability_enabled: true |
| 165 |
is_encryption_enabled: true |
| 166 |
state: "present" |
| 167 |
|
| 168 |
- name: Get SMB Share Details using Name for Snapshot |
| 169 |
smbshare: |
| 170 |
unispherehost: "{{ unispherehost }}" |
| 171 |
username: "{{ username }}" |
| 172 |
password: "{{ password }}" |
| 173 |
validate_certs: "{{ validate_certs }}" |
| 174 |
share_name: "{{ snap_share_name }}" |
| 175 |
snapshot_name: "{{ snapshot_name }}" |
| 176 |
state: "present" |
| 177 |
|
| 178 |
- name: Update the details of the SMB share for Snapshot |
| 179 |
smbshare: |
| 180 |
unispherehost: "{{ unispherehost }}" |
| 181 |
username: "{{ username }}" |
| 182 |
password: "{{ password }}" |
| 183 |
validate_certs: "{{ validate_certs }}" |
| 184 |
share_name: "{{ snap_share_name }}" |
| 185 |
snapshot_name: "{{ snapshot_name }}" |
| 186 |
umask: "777" |
| 187 |
description: "updated description of snapshot's SMB share" |
| 188 |
offline_availability: "DOCUMENTS" |
| 189 |
is_abe_enabled: false |
| 190 |
is_branch_cache_enabled: false |
| 191 |
is_continuous_availability_enabled: false |
| 192 |
is_encryption_enabled: false |
| 193 |
state: "present" |
| 194 |
|
| 195 |
- name: Update the details of the SMB share for Snapshot Idempotency |
| 196 |
smbshare: |
| 197 |
unispherehost: "{{ unispherehost }}" |
| 198 |
username: "{{ username }}" |
| 199 |
password: "{{ password }}" |
| 200 |
validate_certs: "{{ validate_certs }}" |
| 201 |
share_name: "{{ snap_share_name }}" |
| 202 |
snapshot_name: "{{ snapshot_name }}" |
| 203 |
umask: "777" |
| 204 |
description: "updated description of snapshot's SMB share" |
| 205 |
offline_availability: "DOCUMENTS" |
| 206 |
is_abe_enabled: false |
| 207 |
is_branch_cache_enabled: false |
| 208 |
is_continuous_availability_enabled: false |
| 209 |
is_encryption_enabled: false |
| 210 |
state: "present" |
| 211 |
|
| 212 |
- name: Delete SMB share for Filesystem Snapshot |
| 213 |
smbshare: |
| 214 |
unispherehost: "{{ unispherehost }}" |
| 215 |
username: "{{ username }}" |
| 216 |
password: "{{ password }}" |
| 217 |
validate_certs: "{{ validate_certs }}" |
| 218 |
share_id: "{{ snap_share_id }}" |
| 219 |
state: "absent" |
| 220 |
|
| 221 |
- name: Delete SMB share for Filesystem Snapshot Idempotency |
| 222 |
smbshare: |
| 223 |
unispherehost: "{{ unispherehost }}" |
| 224 |
username: "{{ username }}" |
| 225 |
password: "{{ password }}" |
| 226 |
validate_certs: "{{ validate_certs }}" |
| 227 |
share_name: "{{ snap_share_name }}" |
| 228 |
snapshot_name: "{{ snapshot_name }}" |
| 229 |
state: "absent" |