Compare commits
2 commits
02086cdc32
...
a3dd4eba65
Author | SHA1 | Date | |
---|---|---|---|
Timotej Lazar | a3dd4eba65 | ||
Timotej Lazar | b20e9cccff |
|
@ -14,5 +14,6 @@ query_filters:
|
||||||
- role: 'firewall'
|
- role: 'firewall'
|
||||||
- role: 'server'
|
- role: 'server'
|
||||||
- role: 'storage-node'
|
- role: 'storage-node'
|
||||||
|
- role: 'desktop-computer'
|
||||||
group_by:
|
group_by:
|
||||||
- cluster
|
- cluster
|
||||||
|
|
|
@ -12,10 +12,10 @@ table inet filter {
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if prefixes4 or prefixes6 %}
|
{% if prefixes4 or prefixes6 %}
|
||||||
{% if prefixes4 %}
|
{% if prefixes4 %}
|
||||||
ip saddr { {{ prefixes4 | join(', ') }} } tcp dport { {{ ports }} } accept
|
ip saddr { {{ prefixes4 | join(', ') }} } {{ service.protocol.value }} dport { {{ ports }} } accept
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if prefixes6 %}
|
{% if prefixes6 %}
|
||||||
ip6 saddr { {{ prefixes6 | join(', ') }} } tcp dport { {{ ports }} } accept
|
ip6 saddr { {{ prefixes6 | join(', ') }} } {{ service.protocol.value }} dport { {{ ports }} } accept
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
tcp dport { {{ ports }} } accept
|
tcp dport { {{ ports }} } accept
|
||||||
|
|
5
roles/dnsmasq/handlers/main.yml
Normal file
5
roles/dnsmasq/handlers/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
- name: restart dnsmasq
|
||||||
|
service:
|
||||||
|
name: dnsmasq
|
||||||
|
state: restarted
|
||||||
|
when: "'handler' not in ansible_skip_tags"
|
16
roles/dnsmasq/tasks/main.yml
Normal file
16
roles/dnsmasq/tasks/main.yml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
- name: Install packages
|
||||||
|
package:
|
||||||
|
name:
|
||||||
|
- dnsmasq
|
||||||
|
|
||||||
|
- name: Configure dnsmasq
|
||||||
|
template:
|
||||||
|
dest: '/etc/dnsmasq.d/{{ item }}'
|
||||||
|
src: '{{ item }}.j2'
|
||||||
|
loop:
|
||||||
|
- 00-options.conf
|
||||||
|
- 10-ranges.conf
|
||||||
|
notify: restart dnsmasq
|
||||||
|
|
||||||
|
# TODO DNS update
|
||||||
|
# TODO netboot config
|
11
roles/dnsmasq/templates/00-options.conf.j2
Normal file
11
roles/dnsmasq/templates/00-options.conf.j2
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# disable DNS server
|
||||||
|
port = 0
|
||||||
|
|
||||||
|
bind-interfaces
|
||||||
|
interface = {{ interfaces | map(attribute='name') | join(',') }}
|
||||||
|
|
||||||
|
dhcp-authoritative
|
||||||
|
dhcp-proxy
|
||||||
|
|
||||||
|
dhcp-option = option:dns-server,{{ dns | join(',') }}
|
||||||
|
dhcp-option = option:ntp-server,{{ ntp | join(',') }}
|
18
roles/dnsmasq/templates/10-ranges.conf.j2
Normal file
18
roles/dnsmasq/templates/10-ranges.conf.j2
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{% for prefix in prefixes | selectattr('custom_fields.dhcp_server') %}
|
||||||
|
{% if prefix.custom_fields.dhcp_server.address | ipaddr('address') == primary_ip4 %}
|
||||||
|
# {{ prefix.vlan.name }}
|
||||||
|
dhcp-range = set:{{ prefix.vlan.name }},{{ prefix.prefix | ipmath(100) }},{{ prefix.prefix | ipmath(200) }},{{ prefix.prefix | ipaddr('netmask') }}
|
||||||
|
{% if prefix.custom_fields.gateway %}
|
||||||
|
dhcp-option = tag:{{ prefix.vlan.name }},option:router,{{ prefix.custom_fields.gateway.address | ipaddr('address') }}
|
||||||
|
{% endif -%}
|
||||||
|
|
||||||
|
{% for host in hostvars.values() | selectattr('primary_ip4') | selectattr('primary_ip4', 'ansible.utils.in_network', prefix.prefix) %}
|
||||||
|
{% for interface in host.interfaces | selectattr('mac_address') %}
|
||||||
|
{% for address in interface.ip_addresses | selectattr('status.value', '==', 'dhcp') %}
|
||||||
|
dhcp-host = {{ interface.mac_address | lower }},{{ address.address | ipaddr('address') }},{{ interface.device.name | lower }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
Loading…
Reference in a new issue