ansible/roles/isc-dhcp-server/tasks/main.yml

111 lines
2.5 KiB
YAML
Raw Normal View History

2019-05-04 10:54:51 +02:00
---
2020-09-11 15:05:57 +02:00
- 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
2019-05-04 10:54:51 +02:00
- 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
2020-05-08 16:44:08 +02:00
notify: restart dhcpd
2019-05-04 10:54:51 +02:00
2020-04-06 17:42:54 +02:00
- name: Ensure dhcp log directory exists
file:
path: /var/log/dhcp
owner: root
group: root
mode: u=rwx,g=rx,a=rx
state: directory
2020-04-06 17:58:02 +02:00
- name: Ensure rsyslog knows where to send dhcp logs
2020-04-06 17:42:54 +02:00
lineinfile:
path: /etc/rsyslog.conf
2020-04-06 17:58:02 +02:00
line: "local7.* /var/log/dhcp/dhcpd.log"
2020-09-11 15:05:57 +02:00
notify: restart rsyslog
2020-04-06 17:58:02 +02:00
- 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: "*"
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
2020-05-08 16:44:08 +02:00
notify: restart dhcpd
- name: Configure dhcp-failover.conf
template:
src: dhcp/dhcp-failover.conf.j2
dest: /etc/dhcp/dhcp-failover.conf
mode: 0600
2020-09-11 15:05:57 +02:00
when: dhcp_failover_enabled
2020-05-08 16:44:08 +02:00
notify: restart dhcpd
- name: Configure dhcpd.conf
2019-05-04 10:54:51 +02:00
template:
src: dhcp/dhcpd.conf.j2
dest: /etc/dhcp/dhcpd.conf
mode: 0600
2020-05-08 16:44:08 +02:00
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
2020-09-11 15:05:57 +02:00
when: not is_aurore_host
- name: Configure subnets.conf (aurore service)
2020-09-11 15:05:57 +02:00
template:
src: dhcp/aurore-subnets.conf.j2
dest: /etc/dhcp/subnets.conf
2020-09-11 15:05:57 +02:00
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