refactor: remove obsolete Traefik installation script feat: add environment checks and configurations for Vagrant setup, including dnsmasq MetalLB and ingress
78 lines
1.9 KiB
YAML
78 lines
1.9 KiB
YAML
---
|
|
- name: Install Dnsmasq on workstation
|
|
hosts: localhost
|
|
become: true
|
|
become_user: root
|
|
serial: 1 # Ensure tasks are executed one host at a time
|
|
vars_files:
|
|
- vars.yaml
|
|
|
|
tasks:
|
|
|
|
- name: Install dnsmasq
|
|
ansible.builtin.apt:
|
|
name: dnsmasq
|
|
state: present
|
|
|
|
|
|
- name: Stop systemd-resolved
|
|
ansible.builtin.systemd:
|
|
name: systemd-resolved
|
|
state: stopped
|
|
|
|
- name: Disable systemd-resolved
|
|
ansible.builtin.systemd:
|
|
name: systemd-resolved
|
|
enabled: false
|
|
|
|
- name: check to see if /etc/resolv.conf is a symlink
|
|
ansible.builtin.stat:
|
|
path: /etc/resolv.conf
|
|
register: resolv_conf
|
|
|
|
- name: Remove /etc/resolv.conf if it is a symlink
|
|
ansible.builtin.file:
|
|
path: /etc/resolv.conf
|
|
state: absent
|
|
when: resolv_conf.stat.islnk
|
|
|
|
- name: Ensure /etc/resolv.conf is a regular file
|
|
ansible.builtin.file:
|
|
path: /etc/resolv.conf
|
|
state: touch
|
|
|
|
- name: Ensure /etc/resolv.conf uses 127.0.0.1 for server
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/resolv.conf
|
|
regexp: '^nameserver'
|
|
line: 'nameserver 127.0.0.1'
|
|
state: present
|
|
|
|
- name: Configure dnsmasq
|
|
ansible.builtin.copy:
|
|
dest: /etc/dnsmasq.d/k3s-cluster.conf
|
|
content: |
|
|
address=/{{ dnsmasq_k3s_domain }}
|
|
server=1.1.1.1
|
|
server=8.8.8.8
|
|
owner: root
|
|
group: root
|
|
mode: "0644"
|
|
notify: Restart dnsmasq
|
|
|
|
- name: Ensure conf-dir is uncommented in /etc/dnsmasq.conf
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/dnsmasq.conf
|
|
regexp: '^#?conf-dir=/etc/dnsmasq.d'
|
|
line: 'conf-dir=/etc/dnsmasq.d'
|
|
state: present
|
|
owner: root
|
|
group: root
|
|
mode: '0644'
|
|
|
|
handlers:
|
|
- name: Restart dnsmasq
|
|
ansible.builtin.systemd:
|
|
name: dnsmasq
|
|
state: restarted
|
|
|