---

- name: Create wireguard systemd service config directory
  file:
    path: "{{ wireguard_systemd_config_path }}"
    state: directory

- name: create wireguard template config file
  template:
    src: "wireguard/config/wg-{{ layerops_instance_type }}.conf"
    dest: "{{ wireguard_template_path }}/{{ wireguard_interface }}.conf"
    variable_start_string: "€#"
    variable_end_string: "#€"
    block_start_string: "€%"
    block_end_string: "%€"

- name: create wireguard template config file for consul_template
  template:
    src: "wireguard/config/wg-{{ layerops_instance_type }}.conf.tmpl"
    dest: "{{ wireguard_template_path }}/{{ wireguard_interface }}.conf.tmpl"
    variable_start_string: "€#"
    variable_end_string: "#€"
    block_start_string: "€%"
    block_end_string: "%€"

- name: Create wg-reload script
  template:
    src: wireguard/wg-reload.sh
    dest: "{{ local_bin_path }}/wg_reload"
    mode: 0755

- name: copy wireguard consul-template systemd startup script
  template:
    src: wireguard/config/consul-template-wg.service
    dest: "{{ wireguard_template_path }}/consul-template-wg.service"
    variable_start_string: "€#"
    variable_end_string: "#€"
    block_start_string: "€%"
    block_end_string: "%€"

- name: Create wireguard systemd service config
  template:
    src: "wireguard/{{ item }}"
    dest: "{{ wireguard_systemd_config_path }}/{{ item }}"
    mode: 0755
  with_items:
    - startup-timeout.conf
