network config for raspy

This commit is contained in:
histausse 2021-07-08 02:13:11 +02:00
parent 9c208606de
commit 6ed2bd7dd0
Signed by: histausse
GPG key ID: 67486F107F62E9E9
4 changed files with 72 additions and 2 deletions

View file

@ -4,8 +4,7 @@ interfaces:
ipv4: 192.168.0.50
netmaskv4: 24
type: static
routes:
- {subnet: 0.0.0.0, netmask: 0, gateway: 10.0.2.1}
gateway: 10.0.2.1
wg0:
ipv4: "{{ intranet.subnets.physical.subnets.rossum.ipv4 }}"
netmaskv4: "{{ intranet.netmaskv4 }}"

View file

@ -2,3 +2,8 @@
- name: Reload network interfaces debian
become: true
command: /sbin/ifreload -a
- name: Restart dhcpcd raspbian
systemd:
name: dhcpcd
state: restarted

View file

@ -48,3 +48,13 @@
notify: Reload network interfaces debian
when: ansible_facts["lsb"]["id"] == "Debian"
- name: Create dhcpcd config files
ansible.builtin.template:
src: "raspbian_dhcpcd.conf.j2"
dest: "/etc/dhcpcd.conf"
owner: root
group: netdev
mode: '664'
notify: Restart dhcpcd raspbian
when: ansible_facts["lsb"]["id"] == "Raspbian"

View file

@ -0,0 +1,56 @@
{{ ansible_managed | comment }}
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.
# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel
# Inform the DHCP server of our hostname for DDNS.
hostname
# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
#duid
# Persist interface configuration when dhcpcd exits.
persistent
# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit
# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu
# Most distributions have NTP support.
#option ntp_servers
# A ServerID is required by RFC2131.
require dhcp_server_identifier
# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
slaac private
{% for item in lookup('dict', interfaces) %}
{% if item.value.type == 'static' %}
interface {{ item.key }}
{% if 'ipv4' in item.value %}
static ip_address={{ item.value.ipv4 }}/{{ item.value.netmaskv4 }}
{% endif %}
{% if 'gateway' in item.value %}
static routers={{ item.value.gateway }}
{% endif %}
{% endif %}
{% endfor %}