---
- name: installation de wireguard
  apt:
    name: wireguard
    state: present

- name: installation de wireguard-tools
  apt:
    name: wireguard-tools
    state: present

- name: création du dossier conf
  file:
    path: /root/confwg
    state: directory

- name: copie du script mk-wgconf.sh
  copy:
    src: mk-wgconf.sh
    dest: /root/confwg

- name: execution script mk-wgconf.sh
  command: bash ./mk-wgconf.sh
  args:
    chdir: /root/confwg
       
- name: copie du fichier de configuration
  copy:
    src: /root/confwg/wg0-a.conf
    dest: /etc/wireguard

- name: renommage fichier de configuration
  command: "mv /etc/wireguard/wg0-a.conf /etc/wireguard/wg0.conf"

- name: demarrage du service wireguard
  tags: aaaa
  command: "systemctl enable wg-quick@wg0"
  command: "systemctl restart wg-quick@wg0"
