fix(security,common)!: moved sysctl and resolvconf tasks from common to security role to fix DNS resolution fail due to firewall rules
This commit is contained in:
parent
b7ba39bce9
commit
3701ea6276
13 changed files with 57 additions and 55 deletions
|
@ -2,6 +2,7 @@
|
|||
security_apt_force_https: true
|
||||
security_apt_https_ignore_list: []
|
||||
security_clamav_version: 1.3.1
|
||||
security_configure_resolve_conf: false
|
||||
security_firewall_enabled: true
|
||||
security_firewall_filter_policy_forward: drop
|
||||
security_firewall_filter_policy_input: drop
|
||||
|
@ -16,3 +17,4 @@ security_firewall_nat_policy_output: accept
|
|||
security_firewall_nat_policy_postrouting: accept
|
||||
security_firewall_nat_policy_prerouting: accept
|
||||
security_ssh_port: 22
|
||||
security_sysctl_configuration: {}
|
||||
|
|
|
@ -44,3 +44,8 @@
|
|||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
force_apt_get: true
|
||||
|
||||
- name: '[system] reload sysctl configuration'
|
||||
become: true
|
||||
ansible.builtin.command:
|
||||
cmd: sysctl --system
|
||||
|
|
|
@ -4,6 +4,49 @@
|
|||
gather_subset:
|
||||
- distribution
|
||||
|
||||
- name: '[system] setup DNS server'
|
||||
block:
|
||||
- name: disable resolv.conf updates from dhclient
|
||||
ansible.builtin.copy:
|
||||
dest: /etc/dhcp/dhclient-enter-hooks.d/nodnsupdate
|
||||
content: |
|
||||
#!/bin/sh
|
||||
make_resolv_conf(){
|
||||
:
|
||||
}
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
- name: update resolv.conf
|
||||
ansible.builtin.template:
|
||||
src: ../templates/system/debian/resolv.conf.j2
|
||||
dest: /etc/resolv.conf
|
||||
mode: '0644'
|
||||
owner: root
|
||||
group: root
|
||||
become: true
|
||||
when: security_configure_resolve_conf is truthy
|
||||
|
||||
- name: '[system] re-allow DHCP client to setup DNS resolvers'
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: /etc/dhcp/dhclient-enter-hooks.d/nodnsupdate
|
||||
state: absent
|
||||
failed_when: false
|
||||
when : security_configure_resolve_conf is falsy
|
||||
|
||||
- name: '[system] add sysctl tweaks'
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: ../templates/system/debian/sysctld.local.conf.j2
|
||||
dest: /etc/sysctl.d/local.conf
|
||||
mode: '0644'
|
||||
when: security_sysctl_configuration is truthy
|
||||
vars:
|
||||
sysctl_values: "{{ security_sysctl_configuration }}"
|
||||
notify:
|
||||
- 'security : [system] reload sysctl configuration'
|
||||
|
||||
- ansible.builtin.include_tasks:
|
||||
file: firewall.yml
|
||||
apply:
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
{% set dns4_servers = hostvars[inventory_hostname]["global_dns_{}_dns4".format(global_dns_type)] | default([]) %}
|
||||
{% set dns6_servers = hostvars[inventory_hostname]["global_dns_{}_dns6".format(global_dns_type)] | default([]) %}
|
||||
{% if dns4_servers is defined and dns4_servers | length > 0 -%}
|
||||
{% for server in dns4_servers -%}
|
||||
nameserver {{ server }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if global_ip_dualstack | default(false) and dns6_servers is defined and dns6_servers | length > 0 -%}
|
||||
{% for server in dns6_servers -%}
|
||||
nameserver {{ server }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
|
@ -0,0 +1,3 @@
|
|||
{% for item in security_sysctl_configuration.keys() -%}
|
||||
{{ item }} = {{ security_sysctl_configuration[item] }}
|
||||
{% endfor %}
|
Loading…
Add table
Add a link
Reference in a new issue