domain.switch.yml 873 Bytes
---
#  domain switch  

- hosts: localhost

  vars_prompt:
    - name: "confirmation"
      prompt: "Start to change . Please Enter YES to continue"
      private: no
    - name: "switch_domain"
      prompt: "Please input switch_domain"
      private: no
    - name: "switch_ip"
      prompt: "Please input switch_ip"
      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'

    - name: domain switch 
      domain_modify:
        secretId: "{{ qcloud_key.SecretId }}"
        secretKey: "{{ qcloud_key.SecretKey }}"
        domain_name: "{{ switch_domain }}"
        value: "{{ switch_ip }}"