get IP address
This commit is contained in:
parent
5a8c281342
commit
0e0dda8acf
1 changed files with 13 additions and 1 deletions
|
@ -61,7 +61,8 @@
|
|||
# - Restart Wireguard service
|
||||
# - Ping Wireguard server
|
||||
|
||||
- name: Configure peers hosts file entry
|
||||
|
||||
- name: Configure peers hosts file entry (from wg_address)
|
||||
lineinfile:
|
||||
path: /etc/hosts
|
||||
regexp: "^{{ hostvars[item]['wg_address'] | regex_replace('/.*$', '')}} "
|
||||
|
@ -69,3 +70,14 @@
|
|||
backup: true
|
||||
create: true
|
||||
loop: "{{ groups['wireguard_clients'] }}"
|
||||
when: "'wg_address' in hostvars[item]"
|
||||
|
||||
- name: Configure peers hosts file entry (from allowed IPs)
|
||||
lineinfile:
|
||||
path: /etc/hosts
|
||||
regexp: "^{{ hostvars[item]['AllowedIPs'] | regex_replace('/.*$', '')}} "
|
||||
line: "{{ hostvars[item]['AllowedIPs'] | regex_replace('/.*$', '')}} {{ item }}.{{ vpn_domain }}"
|
||||
backup: true
|
||||
create: true
|
||||
loop: "{{ groups['wireguard_clients'] }}"
|
||||
when: "'wg_address' not in hostvars[item]"
|
||||
|
|
Loading…
Reference in a new issue