Initial commit
This commit is contained in:
commit
7335a8decf
7 changed files with 62 additions and 0 deletions
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
A minimal ansible role to set up dnsmasq on any linux machine for dns caching.
|
||||||
|
|
||||||
|
It will disable systemd-resolved in the process and be available at localhost:53
|
3
defaults/main.yml
Normal file
3
defaults/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
dnsmasq_os_supported: False
|
||||||
|
dnsmasq_upstream_server: 9.9.9.9
|
5
example_playbook.yml
Normal file
5
example_playbook.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
- hosts: my.machine.tld
|
||||||
|
roles:
|
||||||
|
- dnsmasq
|
||||||
|
vars:
|
||||||
|
dnsmasq_upstream_server: "208.67.222.220"
|
2
meta/main.yml
Normal file
2
meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
galaxy_info:
|
43
tasks/main.yml
Normal file
43
tasks/main.yml
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
---
|
||||||
|
- name: Set OS dependent variables
|
||||||
|
ansible.builtin.include_vars: "{{ lookup('first_found', params) }}"
|
||||||
|
vars:
|
||||||
|
params:
|
||||||
|
files:
|
||||||
|
- "{{ ansible_distribution | lower }}_{{ ansible_distribution_version | lower }}.yml"
|
||||||
|
- "{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version | lower }}.yml"
|
||||||
|
- "{{ ansible_distribution | lower }}.yml"
|
||||||
|
- "{{ ansible_os_family | lower }}.yml"
|
||||||
|
- "{{ ansible_system | lower }}.yml"
|
||||||
|
paths:
|
||||||
|
- '{{ role_path }}/vars'
|
||||||
|
ignore_errors: True
|
||||||
|
|
||||||
|
- name: OS is supported
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that: __os_supported
|
||||||
|
quiet: True
|
||||||
|
vars:
|
||||||
|
__os_supported: "{{ lookup('vars', '{}_os_supported'.format(role_name)) | bool }}"
|
||||||
|
|
||||||
|
- name: Disable and stop systemd-resolved
|
||||||
|
service:
|
||||||
|
name: systemd-resolved
|
||||||
|
state: stopped
|
||||||
|
enabled: no
|
||||||
|
|
||||||
|
- name: Install dnsmasq
|
||||||
|
apt:
|
||||||
|
name: dnsmasq
|
||||||
|
state: latest
|
||||||
|
|
||||||
|
- name: Set dnsmasq config
|
||||||
|
template:
|
||||||
|
src: default.conf
|
||||||
|
dest: /etc/dnsmasq.d/default.conf
|
||||||
|
|
||||||
|
- name: Enable and restart dnsmasq
|
||||||
|
service:
|
||||||
|
name: dnsmasq
|
||||||
|
state: restarted
|
||||||
|
enabled: yes
|
4
templates/default.conf.j2
Normal file
4
templates/default.conf.j2
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
listen-address=127.0.0.1
|
||||||
|
cache-size=10000
|
||||||
|
|
||||||
|
server={{ dnsmasq_upstream_server }}
|
2
vars/debian.yml
Normal file
2
vars/debian.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
dnsmasq_os_supported: True
|
Loading…
Add table
Add a link
Reference in a new issue