domain.switch.java.yml 1.75 KB
---
#  switch java 

- hosts: localhost

  vars_prompt:
    - name: "confirmation"
      prompt: "Start to change . Please Enter YES to continue"
      private: no
    - name: "switch_to_where"
      prompt: "Please choose java endpoint: [qq|aws]"
      default: qq
      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'

## switch to qq
    - name: domain switch to qq
      domain_modify:
        secretId: "{{ qcloud_key.SecretId }}"
        secretKey: "{{ qcloud_key.SecretKey }}"
        domain_name: "api.yoho.cn,service.yoho.cn,union.yoho.cn,webunion.yohobuy.com,2.yohobuy.com"
        value: "123.206.1.98"
      when: switch_to_where == 'qq'

    - name: configure ask ip nginx's cloudType = 1
      uri:
       url: "http://{{item}}/switchCloud?cloudType=1"
       headers:
          Host: 'dnsresolver.yohoops.org'
      with_items: "{{ask_nginx}}"
      when: switch_to_where == 'qq'
   

# switch to aws
    - name: switch to aws
      domain_modify:
        secretId: "{{ qcloud_key.SecretId }}"
        secretKey: "{{ qcloud_key.SecretKey }}"
        domain_name: "api.yoho.cn,service.yoho.cn,union.yoho.cn,webunion.yohobuy.com,2.yohobuy.com"
        value: "java-public-lb-862332839.cn-north-1.elb.amazonaws.com.cn"
      when: switch_to_where == 'aws'

    - name: configure ask ip nginx's cloudType = 2
      uri:
       url: "http://{{item}}/switchCloud?cloudType=2"
       headers:
          Host: 'dnsresolver.yohoops.org'
      with_items: "{{ask_nginx}}"
      when: switch_to_where == 'aws'