110 lines
2.5 KiB
YAML
110 lines
2.5 KiB
YAML
---
|
|
- name: Install dhcp (re2o-service)
|
|
import_role:
|
|
name: re2o-service
|
|
vars:
|
|
service_repo: https://gitlab.federez.net/re2o/dhcp.git
|
|
service_name: dhcp
|
|
service_version: master
|
|
service_config:
|
|
hostname: re2o.auro.re
|
|
username: service-user
|
|
password: "{{ vault_serviceuser_passwd }}"
|
|
|
|
- name: Ensure appropriate permissions on dhcp re2o service
|
|
file:
|
|
path: /var/local/re2o-services/dhcp/
|
|
state: directory
|
|
owner: re2o-services
|
|
group: nogroup
|
|
recurse: yes
|
|
|
|
- name: Install isc-dhcp-server
|
|
apt:
|
|
update_cache: true
|
|
name: isc-dhcp-server
|
|
state: present
|
|
register: apt_result
|
|
retries: 3
|
|
until: apt_result is succeeded
|
|
notify: restart dhcpd
|
|
|
|
- name: Ensure dhcp log directory exists
|
|
file:
|
|
path: /var/log/dhcp
|
|
owner: root
|
|
group: root
|
|
mode: u=rwx,g=rx,a=rx
|
|
state: directory
|
|
|
|
- name: Ensure rsyslog knows where to send dhcp logs
|
|
lineinfile:
|
|
path: /etc/rsyslog.conf
|
|
line: "local7.* /var/log/dhcp/dhcpd.log"
|
|
notify: restart rsyslog
|
|
|
|
- name: Configure dhcp log rotation
|
|
template:
|
|
src: logrotate.d/dhcp.j2
|
|
dest: /etc/logrotate.d/dhcp
|
|
mode: 0644
|
|
|
|
- name: set up cron to reload dhcp re2o service
|
|
cron:
|
|
# Do not change this name or idempotence *might* be lost.
|
|
name: dhcp-re2o-service
|
|
cron_file: re2o-services
|
|
minute: "*/2"
|
|
hour: "*"
|
|
day: "*"
|
|
weekday: "*"
|
|
month: "*"
|
|
user: root
|
|
job: "/usr/bin/python3 /var/local/re2o-services/dhcp/main.py"
|
|
|
|
- name: Configure /etc/default/isc-dhcp-server
|
|
template:
|
|
src: default/isc-dhcp-server.j2
|
|
dest: /etc/default/isc-dhcp-server
|
|
mode: 0644
|
|
notify: restart dhcpd
|
|
|
|
- name: Configure dhcp-failover.conf
|
|
template:
|
|
src: dhcp/dhcp-failover.conf.j2
|
|
dest: /etc/dhcp/dhcp-failover.conf
|
|
mode: 0600
|
|
when: dhcp_failover_enabled
|
|
notify: restart dhcpd
|
|
|
|
- name: Configure dhcpd.conf
|
|
template:
|
|
src: dhcp/dhcpd.conf.j2
|
|
dest: /etc/dhcp/dhcpd.conf
|
|
mode: 0600
|
|
notify: restart dhcpd
|
|
|
|
- name: Configure subnets.conf (regular service)
|
|
template:
|
|
src: dhcp/regular-subnets.conf.j2
|
|
dest: /etc/dhcp/subnets.conf
|
|
mode: 0600
|
|
notify: restart dhcpd
|
|
when: not is_aurore_host
|
|
|
|
- name: Configure subnets.conf (aurore service)
|
|
template:
|
|
src: dhcp/aurore-subnets.conf.j2
|
|
dest: /etc/dhcp/subnets.conf
|
|
mode: 0600
|
|
notify: restart dhcpd
|
|
when: is_aurore_host
|
|
|
|
- name: force run dhcp re2o-service
|
|
shell: /var/local/re2o-services/dhcp/main.py --force
|
|
|
|
- name: Ensure dhcpd is running
|
|
service:
|
|
name: isc-dhcp-server
|
|
state: started
|
|
enabled: true
|