domain.switch.vpn.ldap.yml
1.89 KB
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
---
# switch vpn/ldap
- hosts: localhost
vars_prompt:
- name: "confirmation"
prompt: "Start to change . Please Enter YES to continue"
private: no
- name: "switch_to_where"
prompt: "Please choose master or slave: [master|slave]"
default: slave
private: no
- name: "switch_domain"
prompt: "Please choose vpn or ldap: [vpn|ldap]"
private: no
vars_files:
- extra_vars/all.yml
vars:
qcloud_key: "{{ lookup('hashi_vault', 'secret=yoho/ops/qcloud token='+'{{vault.token}}'+' url='+'{{vault.server}}') }}"
tasks:
- name: "make sure user type YES to confirm"
fail:
msg: "user do not type YES"
when: confirmation != 'YES'
# vpn switch to slave
- name: domain switch to slave
domain_modify:
secretId: "{{ qcloud_key.SecretId }}"
secretKey: "{{ qcloud_key.SecretKey }}"
domain_name: "vpn.yoho.cn"
value: "106.38.39.122"
when: switch_domain == 'vpn' and switch_to_where == 'slave'
# vpn switch to master
- name: switch to master
domain_modify:
secretId: "{{ qcloud_key.SecretId }}"
secretKey: "{{ qcloud_key.SecretKey }}"
domain_name: "vpn.yoho.cn"
value: "218.94.75.58"
when: switch_domain == 'vpn' and switch_to_where == 'master'
# ldap switch to slave
- name: domain switch to slave
domain_modify:
secretId: "{{ qcloud_key.SecretId }}"
secretKey: "{{ qcloud_key.SecretKey }}"
domain_name: "ldap.yoho.cn"
value: "106.38.39.124"
when: switch_domain == 'ldap' and switch_to_where == 'slave'
# ldap switch to master
- name: switch to master
domain_modify:
secretId: "{{ qcloud_key.SecretId }}"
secretKey: "{{ qcloud_key.SecretKey }}"
domain_name: "ldap.yoho.cn"
value: "58.213.75.179"
when: switch_domain == 'ldap' and switch_to_where == 'master'