dhcpcd: Install and configure dhcpcd

`dhcpcd` is a fully-featured network manager, without all the bloat of
`NetworkManager`.
jenkins-master
Dustin 2018-03-12 19:09:01 -05:00
parent 5181ddaa00
commit 9e73b56ac7
6 changed files with 156 additions and 0 deletions

3
dhcpcd.yml Normal file
View File

@ -0,0 +1,3 @@
- hosts: dhcpcd
roles:
- dhcpcd

View File

@ -0,0 +1,13 @@
dhcpcd_send_hostname: true
dhcpcd_use_clientid: false
dhcpcd_persistent: true
dhcpcd_rapid_commit: true
dhcpcd_options: '{{ dhcpcd_default_options }}'
dhcpcd_ntp_servers: true
dhcpcd_interface_mtu: true
dhcpcd_require_server_id: true
dhcpcd_slaac_private: true
dhcpcd_noipv4ll: false
dhcpcd_noipv4: false
dhcpcd_noipv6rs: false
dhcpcd_interfaces: []

View File

@ -0,0 +1,4 @@
- name: restart dhcpcd
service:
name=dhcpcd
state=restarted

View File

@ -0,0 +1,21 @@
- name: ensure dhcpcd is installed
package:
name=dhcpcd
state=present
- name: ensure dhcpcd is configured
template:
src=dhcpcd.conf.j2
dest=/etc/dhcpcd.conf
mode=0644
notify: restart dhcpcd
- name: ensure dhcpcd starts at boot
service:
name=dhcpcd
enabled=yes
- meta: flush_handlers
- name: ensure dhcpcd is running
service:
name=dhcpcd
state=started

View File

@ -0,0 +1,112 @@
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.
# Allow users of this group to interact with dhcpcd via the control socket.
{% if dhcpcd_controlgroup is defined %}
controlgroup {{ dhcpcd_controlgroup }}
{% else %}
#controlgroup wheel
{% endif %}
{% if dhcpcd_allow_interfaces is defined %}
allowinterfaces {{ dhcpcd_allow_interfaces }}
{% endif %}
{% if dhcpcd_deny_interfaces is defined %}
denyinterfaces {{ dhcpcd_deny_interfaces }}
{% endif %}
# Inform the DHCP server of our hostname for DDNS.
{% if dhcpcd_send_hostname|bool %}
hostname
{% else %}
#hostname
{% endif %}
# Use the hardware address of the interface for the Client ID.
{% if dhcpcd_use_clientid|bool %}
clientid
{% else %}
#clientid
{% endif %}
# 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.
{% if not dhcpcd_use_clientid|bool %}
duid
{% else %}
#duid
{% endif %}
# Persist interface configuration when dhcpcd exits.
{% if dhcpcd_persistent|bool %}
persistent
{% else %}
#persistent
{% endif %}
# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
{% if dhcpcd_rapid_commit|bool %}
option rapid_commit
{% else %}
#option rapid_commit
{% endif %}
# A list of options to request from the DHCP server.
{% for option in dhcpcd_options %}
option {{ option }}
{% endfor %}
# Most distributions have NTP support.
{% if dhcpcd_ntp_servers|bool %}
option ntp_servers
{% else %}
#option ntp_servers
{% endif %}
# Respect the network MTU. This is applied to DHCP routes.
{% if dhcpcd_interface_mtu|bool %}
option interface_mtu
{% else %}
#option interface_mtu
{% endif %}
# A ServerID is required by RFC2131.
{% if dhcpcd_require_server_id|bool %}
require dhcp_server_identifier
{% else %}
#require dhcp_server_identifier
{% endif %}
# Generate Stable Private IPv6 Addresses instead of hardware based ones
{% if dhcpcd_slaac_private|bool %}
slaac private
{% else %}
#slaac private
{% endif %}
{% if dhcpcd_noipv4ll|bool %}
# Disable IPv4 link-local address automatic configuration (APIPA)
noipv4ll
{% endif %}
{% if dhcpcd_noipv4|bool %}
# Disable IPv4 configuration entirely
noipv4
{% endif %}
{% if dhcpcd_noipv6rs|bool %}
# Disable IPv6 router solicitations
noipv6rs
{% endif %}
{% for iface in dhcpcd_interfaces %}
{% if iface.description is defined %}
# {{ iface.description }}
{% endif %}
interface {{ iface.name }}
{% for setting in iface.config %}
{{ setting }}
{% endfor %}
{% endfor %}

View File

@ -0,0 +1,3 @@
dhcpcd_default_options:
- domain_name_servers, domain_name, domain_search, host_name
- classless_static_routes