Ensure $(hostname).local is in hosts file on WSL
This commit is contained in:
parent
cee0c443a3
commit
1895f1561d
@ -40,3 +40,21 @@
|
||||
with_items:
|
||||
- win_git.ps1
|
||||
- win_git.py
|
||||
|
||||
- name: read /etc/resolv.conf file contents
|
||||
set_fact:
|
||||
resolv_conf: '{{lookup("ansible.builtin.file", "/etc/resolv.conf")}}'
|
||||
|
||||
- name: get Windows host IP from /etc/resolv.conf
|
||||
set_fact:
|
||||
host_ip: '{{resolv_conf | regex_search("(\d+\.\d+\.\d+\.\d+)")}}'
|
||||
|
||||
- name: add $(hostname).local to /etc/hosts
|
||||
become: true
|
||||
lineinfile:
|
||||
path: /etc/hosts
|
||||
regexp: '^{{host_ip | replace(".", "\.")}}'
|
||||
line: '{{host_ip}} {{ansible_hostname}}.local'
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
Loading…
x
Reference in New Issue
Block a user