Refactor(ansible): Correctly generate client config via role
This commit is contained in:
@@ -1,21 +1,20 @@
|
||||
- name: wireguard-client-gen
|
||||
- name: Generate WireGuard Client Configuration
|
||||
hosts: localhost
|
||||
#connection: local
|
||||
gather_facts: false
|
||||
|
||||
vars_files:
|
||||
- ../../group_vars/vault.yml
|
||||
- ../../group_vars/all.yml
|
||||
|
||||
vars:
|
||||
user: matej
|
||||
IP: "{{ lookup('vars', 'wireguard-client')[user]['ip'] }}"
|
||||
priv: "{{ lookup('vars', 'wireguard-client-vault')[user]['pub'] }}"
|
||||
|
||||
tasks:
|
||||
- name: Copy from template
|
||||
template:
|
||||
src: ../../roles/wireguard_server/templates/wireguardclient.conf
|
||||
dest: ~/{{ user }}.conf
|
||||
owner: "{{ ansible_user_id }}"
|
||||
group: "{{ ansible_user_id }}"
|
||||
mode: '0644'
|
||||
|
||||
|
||||
- name: Include wireguard_server role to generate client config
|
||||
ansible.builtin.include_role:
|
||||
name: wireguard_server
|
||||
tasks_from: generate_client
|
||||
vars:
|
||||
# Pass the required variables to the role
|
||||
IP: "{{ lookup('vars', 'wireguard-client')[user]['ip'] }}"
|
||||
priv: "{{ lookup('vars', 'wireguard-client-vault')[user]['pub'] }}"
|
||||
|
||||
Reference in New Issue
Block a user