Authored by Your Name

新增vpn和ldap域名解析记录切换

1 --- 1 ---
2 -# switch ldap 2 +# switch vpn/ldap
3 3
4 - hosts: localhost 4 - hosts: localhost
5 5
@@ -11,6 +11,9 @@ @@ -11,6 +11,9 @@
11 prompt: "Please choose master or slave: [master|slave]" 11 prompt: "Please choose master or slave: [master|slave]"
12 default: slave 12 default: slave
13 private: no 13 private: no
  14 + - name: "switch_domain"
  15 + prompt: "Please choose vpn or ldap: [vpn|ldap]"
  16 + private: no
14 17
15 vars_files: 18 vars_files:
16 - extra_vars/all.yml 19 - extra_vars/all.yml
@@ -24,21 +27,38 @@ @@ -24,21 +27,38 @@
24 msg: "user do not type YES" 27 msg: "user do not type YES"
25 when: confirmation != 'YES' 28 when: confirmation != 'YES'
26 29
27 -# switch to slave 30 +# vpn switch to slave
  31 + - name: domain switch to slave
  32 + domain_modify:
  33 + secretId: "{{ qcloud_key.SecretId }}"
  34 + secretKey: "{{ qcloud_key.SecretKey }}"
  35 + domain_name: "vpn.yoho.cn"
  36 + value: "106.38.39.122"
  37 + when: switch_domain == 'vpn' and switch_to_where == 'slave'
  38 +
  39 +# vpn switch to master
  40 + - name: switch to master
  41 + domain_modify:
  42 + secretId: "{{ qcloud_key.SecretId }}"
  43 + secretKey: "{{ qcloud_key.SecretKey }}"
  44 + domain_name: "vpn.yoho.cn"
  45 + value: "218.94.75.58"
  46 + when: switch_domain == 'vpn' and switch_to_where == 'master'
  47 +
  48 +# ldap switch to slave
28 - name: domain switch to slave 49 - name: domain switch to slave
29 domain_modify: 50 domain_modify:
30 secretId: "{{ qcloud_key.SecretId }}" 51 secretId: "{{ qcloud_key.SecretId }}"
31 secretKey: "{{ qcloud_key.SecretKey }}" 52 secretKey: "{{ qcloud_key.SecretKey }}"
32 domain_name: "ldap.yoho.cn" 53 domain_name: "ldap.yoho.cn"
33 value: "106.38.39.124" 54 value: "106.38.39.124"
34 - when: switch_to_where == 'slave' 55 + when: switch_domain == 'ldap' and switch_to_where == 'slave'
35 56
36 -# switch to master 57 +# ldap switch to master
37 - name: switch to master 58 - name: switch to master
38 domain_modify: 59 domain_modify:
39 secretId: "{{ qcloud_key.SecretId }}" 60 secretId: "{{ qcloud_key.SecretId }}"
40 secretKey: "{{ qcloud_key.SecretKey }}" 61 secretKey: "{{ qcloud_key.SecretKey }}"
41 domain_name: "ldap.yoho.cn" 62 domain_name: "ldap.yoho.cn"
42 value: "58.213.75.179" 63 value: "58.213.75.179"
43 - when: switch_to_where == 'master'  
44 - 64 + when: switch_domain == 'ldap' and switch_to_where == 'master'
1 ----  
2 -# switch vpn  
3 -  
4 -- hosts: localhost  
5 -  
6 - vars_prompt:  
7 - - name: "confirmation"  
8 - prompt: "Start to change . Please Enter YES to continue"  
9 - private: no  
10 - - name: "switch_to_where"  
11 - prompt: "Please choose master or slave: [master|slave]"  
12 - default: slave  
13 - private: no  
14 -  
15 - vars_files:  
16 - - extra_vars/all.yml  
17 -  
18 - vars:  
19 - qcloud_key: "{{ lookup('hashi_vault', 'secret=yoho/ops/qcloud token='+'{{vault.token}}'+' url='+'{{vault.server}}') }}"  
20 -  
21 - tasks:  
22 - - name: "make sure user type YES to confirm"  
23 - fail:  
24 - msg: "user do not type YES"  
25 - when: confirmation != 'YES'  
26 -  
27 -# switch to slave  
28 - - name: domain switch to slave  
29 - domain_modify:  
30 - secretId: "{{ qcloud_key.SecretId }}"  
31 - secretKey: "{{ qcloud_key.SecretKey }}"  
32 - domain_name: "vpn.yoho.cn"  
33 - value: "106.38.39.122"  
34 - when: switch_to_where == 'slave'  
35 -  
36 -# switch to master  
37 - - name: switch to master  
38 - domain_modify:  
39 - secretId: "{{ qcloud_key.SecretId }}"  
40 - secretKey: "{{ qcloud_key.SecretKey }}"  
41 - domain_name: "vpn.yoho.cn"  
42 - value: "218.94.75.58"  
43 - when: switch_to_where == 'master'  
44 -