local/roles/wsl/tasks/main.yaml

73 lines
1.6 KiB
YAML

---
- name: create wsl.conf
template:
src: templates/wsl.conf.j2
dest: /etc/wsl.conf
- name: install apt packages
become: true
apt:
name: sshpass
state: latest
- name: create /etc/ansible
become: true
file:
dest: /etc/ansible
state: directory
- name: create hosts file
become: true
template:
src: templates/hosts.j2
dest: /etc/ansible/hosts
- name: create binfmt_misc config file
become: true
template:
src: templates/binfmt_misc.j2
dest: /usr/lib/binfmt.d/WSLInterop.conf
notify: restart systemd-binfmt
- name: create external directory
file:
dest: external
state: directory
- name: clone ansible win_git module
git:
repo: https://github.com/tivrobo/ansible-win_git.git
dest: external/ansible-win_git
version: master
- name: create ansible modules directory
file:
dest: ~/.ansible/plugins/modules
state: directory
- name: copy win_git files to ansible modules directory
copy:
src: '~/.config/local/external/ansible-win_git/{{item}}'
dest: '~/.config/local/modules/{{item}}'
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'