Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
65 lines (49 sloc) 2.94 KB
---
# The source code packaged with this file is Free Software, Copyright (C) 2016 by
# Unidad de Laboratorios, Escuela Politecnica Superior, Universidad de Alicante :: <aeps at eps.ua.es>.
# It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.
# You can get copies of the licenses here: http://www.affero.org/oagpl.html
# AFFERO GENERAL PUBLIC LICENSE is also included in the file called "LICENSE".
# DHCP (P1) configuration
- name: /etc/dhcp directory permissions
file: path=/etc/dhcp state=directory owner=root group=manager mode=0750
- name: Copy dhcpd.conf file to DHCP Server to check syntax (P1)
copy: src=etc/dhcp/dhcpd-P1.conf dest=/etc/dhcp/.dhcpd.conf.check owner=manager group=manager mode=0640
register: checkFile
- name: Check syntax (P1)
shell: "{{ path.commands.dhcpd }} -t -cf /etc/dhcp/.dhcpd.conf.check executable='/bin/bash'"
register: checkResult
ignore_errors: True
when: checkFile|changed
- name: If check OK -> Copy dhcpd.conf file to DHCP Servers (P1)
copy: src=etc/dhcp/dhcpd-P1.conf dest=/etc/dhcp/dhcpd.conf owner=manager group=manager mode=0640 backup=yes
when: checkFile|changed and checkResult|success
- name: If check fails -> move .dhcpd.conf.check as .dhcpd.conf.error
shell: mv -f /etc/dhcp/.dhcpd.conf.check /etc/dhcp/.dhcpd.conf.error
when: checkFile|changed and checkResult|failed
- name: Getting Paths
action: path_EPS
changed_when: False
ignore_errors: yes
when: path.daemons.dhcp.name|default("") == ""
- name: Restart dhcp (P1) systemd
systemd: name={{ path.daemons.dhcp.name }} state=restarted
when: path.daemons.dhcp.type == "systemctl" and path.daemons.dhcp.name != "" and checkFile|changed and checkResult|success
- name: Restart dhcp (P1) service
service: name={{ path.daemons.dhcp.name }} state=restarted
when: path.daemons.dhcp.type == "service" and path.daemons.dhcp.name != "" and checkFile|changed and checkResult|success
- name: Restart dhcp (P1) init
shell: '{{ path.daemons.dhcp.name }} restart executable="/bin/bash"'
when: path.daemons.dhcp.type == "init" and path.daemons.dhcp.name != "" and checkFile|changed and checkResult|success
- name: Checking dhcp (P1) systemd
systemd: name={{ path.daemons.dhcp.name }} state=started enabled=true
changed_when: False
when: path.daemons.dhcp.type == "systemctl" and path.daemons.dhcp.name != ""
- name: Checking dhcp (P1) service
service: name={{ path.daemons.dhcp.name }} state=started enabled=true
changed_when: False
when: path.daemons.dhcp.type == "service" and path.daemons.dhcp.name != ""
- name: Checking dhcp (P1) init
shell: "{{ path.daemons.dhcp.name }} start; ([ \"{{ ansible_os_family }}\" == \"Debian\" ] && update-rc.d $(basename {{ path.daemons.dhcp.name }}) defaults) || ([ \"{{ ansible_os_family }}\" == \"RedHat\" ] && chkconfig $(basename {{ path.daemons.dhcp.name }}) on) executable='/bin/bash'"
changed_when: False
when: path.daemons.dhcp.type == "init" and path.daemons.dhcp.name != ""