Skip to content
Snippets Groups Projects
remove-node.yml 1.6 KiB
Newer Older
  • Learn to ignore specific revisions
  • rong.zhang's avatar
    rong.zhang committed
    ---
    
    - name: Check ansible version
      import_playbook: ansible_version.yml
    
    rong.zhang's avatar
    rong.zhang committed
    
    
    - name: Ensure compatibility with old groups
      import_playbook: legacy_groups.yml
    
    - hosts: bastion[0]
      gather_facts: False
      environment: "{{ proxy_disable_env }}"
      roles:
        - { role: kubespray-defaults }
        - { role: bastion-ssh-config, tags: ["localhost", "bastion"] }
    
    
    - hosts: "{{ node | default('etcd:k8s_cluster:calico_rr') }}"
    
      tasks:
        - name: Confirm Execution
          pause:
            prompt: "Are you sure you want to delete nodes state? Type 'yes' to delete nodes."
          register: pause_result
          run_once: True
          when:
            - not (skip_confirmation | default(false) | bool)
    
    rong.zhang's avatar
    rong.zhang committed
    
    
        - name: Fail if user does not confirm deletion
    
    rong.zhang's avatar
    rong.zhang committed
          fail:
            msg: "Delete nodes confirmation failed"
    
          when: pause_result.user_input | default('yes') != 'yes'
    
    rong.zhang's avatar
    rong.zhang committed
    
    
    - name: Gather facts
      import_playbook: facts.yml
    
      when: reset_nodes|default(True)|bool
    
    - hosts: "{{ node | default('kube_node') }}"
    
      gather_facts: no
    
      environment: "{{ proxy_disable_env }}"
    
    rong.zhang's avatar
    rong.zhang committed
      roles:
    
    Samuel Liu's avatar
    Samuel Liu committed
        - { role: kubespray-defaults, when: reset_nodes|default(True)|bool }
    
        - { role: remove-node/pre-remove, tags: pre-remove }
    
    Samuel Liu's avatar
    Samuel Liu committed
        - { role: remove-node/remove-etcd-node }
        - { role: reset, tags: reset, when: reset_nodes|default(True)|bool }
    
    rong.zhang's avatar
    rong.zhang committed
    
    
    # Currently cannot remove first master or etcd
    
    - hosts: "{{ node | default('kube_control_plane[1:]:etcd[1:]') }}"
    
      gather_facts: no
    
      environment: "{{ proxy_disable_env }}"
    
    rong.zhang's avatar
    rong.zhang committed
      roles:
    
    Samuel Liu's avatar
    Samuel Liu committed
        - { role: kubespray-defaults, when: reset_nodes|default(True)|bool }
    
    rong.zhang's avatar
    rong.zhang committed
        - { role: remove-node/post-remove, tags: post-remove }