---

- name: Remove hold on vault package
  ansible.builtin.dpkg_selections:
    name: vault
    selection: install

- name: Pause to let the operator step-down master is needed
  ansible.builtin.pause:
    prompt: "Run vault operator step-down if needed"
    echo: false
  when: "'<MasterNodeName>' in inventory_hostname"

- name: Stopping vault service
  ansible.builtin.systemd_service:
    name: vault
    state: stopped

- name: Upgrading vault package
  ansible.builtin.apt:
    name: vault
    update_cache: true
    state: present

- name: Starting vault service
  ansible.builtin.systemd_service:
    name: vault
    state: started

- name: Set hold on vault package
  ansible.builtin.dpkg_selections:
    name: vault
    selection: hold

- name: Pause to unseal vault
  ansible.builtin.pause:
    prompt: "Go to vault interface and unseal the node : https://{{ inventory_hostname }}:8200"
    echo: false
