feat: add dns management for alpine and debian
This commit is contained in:
parent
63d9880750
commit
0ba18a512f
4 changed files with 27 additions and 1 deletions
|
|
@ -17,6 +17,11 @@ apt_repository_security: "https://archive.ubuntu.com/ubuntu"
|
|||
debian_repo_url_security: "http://security.debian.org/debian-security"
|
||||
debian_repo_url_update: "http://deb.debian.org/debian"
|
||||
|
||||
# dns
|
||||
dns_search: "example.internal"
|
||||
dns_servers:
|
||||
- "192.168.10.1"
|
||||
|
||||
# firewall
|
||||
firewall_enable: true
|
||||
firewall_basic_rules:
|
||||
|
|
|
|||
11
tasks/dns.yaml
Normal file
11
tasks/dns.yaml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
|
||||
# manage resolve.conf
|
||||
- name: "configure resolv.conf"
|
||||
ansible.builtin.template:
|
||||
src: "dns/resolv.conf.j2"
|
||||
dest: "/etc/resolv.conf"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
when: ansible_facts['distribution'] in ['Alpine', 'Debian']
|
||||
|
|
@ -11,6 +11,11 @@
|
|||
ansible.builtin.include_vars: "vars/{{ ansible_os_family }}.yaml"
|
||||
tags: "always"
|
||||
|
||||
# set dns
|
||||
- name: "set dns"
|
||||
ansible.builtin.import_tasks: "dns.yaml"
|
||||
tags: "dns"
|
||||
|
||||
# set hostname
|
||||
- name: "set hostname"
|
||||
ansible.builtin.import_tasks: "hostname.yaml"
|
||||
|
|
@ -46,7 +51,6 @@
|
|||
- "ansible_virtualization_type == 'kvm'"
|
||||
tags: "swap"
|
||||
|
||||
|
||||
# manage fstab
|
||||
- name: "manage fstab"
|
||||
ansible.builtin.import_tasks: "fstab.yaml"
|
||||
|
|
|
|||
6
templates/dns/resolve.conf.j2
Normal file
6
templates/dns/resolve.conf.j2
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{% for dns_server in dns_servers -%}
|
||||
nameserver {{ dns_server }}
|
||||
{% endfor %}
|
||||
{% if "example" not in dns_search -%}
|
||||
search {{ dns_search }}
|
||||
{% endif %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue