-
Notifications
You must be signed in to change notification settings - Fork 0
/
120.1_playbook_add_exchange_policy_v3.yaml
95 lines (91 loc) · 3.33 KB
/
120.1_playbook_add_exchange_policy_v3.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Example Playbok to Add SQL Policy to PPDM
- name: Add SQL Policy
hosts: localhost
gather_facts: no
connection: local
vars_files:
- ./vars/main.yml
- ./templates/exchange_policy_template_v3.yaml
vars:
policy_name: "Exchange_Bob"
app_credentials_username: 'bob exchange demouser'
app_credentials_name: '[email protected]'
app_credentials_password: 'Password123!'
tasks:
- name: Checking Required Variable ppdm_fqdn
fail:
msg: "We do not have ppdm_fqdn set !"
when: (ppdm_fqdn is not defined) or (ppdm_fqdn|length <= 8)
- name: Checking Required Variables
fail:
msg: "We do not have ppdm_new_password set !"
when: (ppdm_new_password is not defined) or (ppdm_new_password|length == 0)
- name: Checking Required Variable ddve_fqdn
fail:
msg: "We do not have ddve_fqdn set !"
when: (ddve_fqdn is not defined) or (ddve_fqdn|length == 0)
- name: Setting Base URL
set_fact:
ppdm_baseurl: "https://{{ ppdm_fqdn | regex_replace('^https://') }}"
- name: Get PPDM Token for https://{{ ppdm_fqdn | regex_replace('^https://') }}
include_role:
name: get_ppdm_token
vars:
ppdm_password: "{{ ppdm_new_password }}"
- debug:
msg: "{{ access_token }}"
verbosity: 1
name: do we have a token ?
- name: Get Protection Policy with filter
vars:
ppdm_api_ver: "/api/v3"
filter: 'name eq "{{ policy_name }}"'
include_role:
name: get_ppdm_protection_policy
- set_fact:
protection_policy: "{{ protection_policy[0] }}"
when: protection_policy[0] is defined
- debug:
msg: "{{ protection_policy }}"
verbosity: 0
- name: "Ensure ApplicationCredentials {{ app_credentials_name }}"
vars:
data:
name: "{{ app_credentials_name }}"
type: "OS"
password: "{{ app_credentials_password }}"
username: "{{ app_credentials_username }}"
include_role:
name: create_ppdm_credentials
- name: Get DataDomain Storage Systems
include_role:
name: get_ppdm_storage-systems
vars:
filter: type eq "DATA_DOMAIN_SYSTEM" and details.dataDomain.preferredInterfaces.ipAddress eq "{{ ddve_fqdn }}"
when: protection_policy.id is not defined
- name: New operationId
set_fact:
newOperationId: "{{ 1000 | random | to_uuid }}"
when: protection_policy.id is not defined and (storagesystems[0] is defined)
- debug:
msg: "{{ newOperationId }}"
verbosity: 0
when: protection_policy.id is not defined and (storagesystems[0] is defined)
- name: Create New Protection Policy
vars:
ppdm_api_ver: "/api/v3"
name: "{{ policy_name }}"
description: "Demo SQL Policy for Bob 2024"
debugEnabled: false
operationId: "{{ newOperationId }}"
storageSystemId: "{{ storagesystems[0].id }}"
preferredInterfaceId: "{{ storagesystems[0].details.dataDomain.preferredInterfaces[0].networkName }}"
new_protection_policy: "{{ data_template }}"
credentials_id: "{{ credentials.id }}"
include_role:
name: new_ppdm_protection_policy
when: protection_policy.id is not defined and (storagesystems[0] is defined)
- debug:
msg: "{{ protection_policy }}"
verbosity: 0
when: protection_policy is defined #and (protection_policy.id is not defined)