---
- name: cluster/systemd | Copy down vault.service systemd file
  template:
    src: "{{ vault_deployment_type }}.service.j2"
    dest: /etc/systemd/system/vault.service
    backup: yes
  register: vault_systemd_placement
  notify: restart vault

- name: Create vault service systemd directory
  file:
    path: /etc/systemd/system/vault.service.d
    state: directory

- name: cluster/systemd | Add vault proxy env vars
  template:
    src: "http-proxy.conf.j2"
    dest: /etc/systemd/system/vault.service.d/http-proxy.conf
    backup: yes
  when: http_proxy is defined or https_proxy is defined
  notify: restart vault

- name: cluster/systemd | Enable vault.service
  systemd:
    daemon_reload: true
    enabled: yes
    name: vault
    state: started
  notify: wait for vault up
