Merge branch 'Anthony25-use_package'
This commit is contained in:
commit
4d003cee65
@ -28,15 +28,6 @@ dhcpd_mode: 'server'
|
|||||||
dhcpd_ipversion: '4'
|
dhcpd_ipversion: '4'
|
||||||
|
|
||||||
|
|
||||||
# .. envvar:: dhcpd_base_packages_map
|
|
||||||
#
|
|
||||||
# What packages should be installed, depending on mode of operation
|
|
||||||
dhcpd_base_packages_map:
|
|
||||||
'server': [ 'isc-dhcp-server' ]
|
|
||||||
'relay': [ 'isc-dhcp-relay' ]
|
|
||||||
'probe': []
|
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
# ISC DHCP Relay configuration
|
# ISC DHCP Relay configuration
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
|
@ -1,23 +1,28 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: Restart isc-dhcp-server
|
- name: Restart dhcp server
|
||||||
service:
|
service:
|
||||||
name: 'isc-dhcp-server'
|
name: '{{ item }}'
|
||||||
state: 'restarted'
|
state: 'restarted'
|
||||||
|
with_items: "{{ dhcpd_services.server }}"
|
||||||
|
|
||||||
- name: Restart isc-dhcp-relay
|
- name: Restart dhcp relay
|
||||||
service:
|
service:
|
||||||
name: 'isc-dhcp-relay'
|
name: '{{ item }}'
|
||||||
state: 'restarted'
|
state: 'restarted'
|
||||||
|
with_items: "{{ dhcpd_services.relay }}"
|
||||||
|
|
||||||
- name: Restart dhcp-probe
|
- name: Restart dhcp probe
|
||||||
service:
|
service:
|
||||||
name: 'dhcp-probe'
|
name: '{{ item }}'
|
||||||
state: 'stopped'
|
state: 'stopped'
|
||||||
notify: [ 'Start dhcp-probe' ]
|
with_items: "{{ dhcpd_services.probe }}"
|
||||||
|
notify: [ 'Start dhcp probe' ]
|
||||||
|
|
||||||
- name: Start dhcp-probe
|
- name: Start dhcp probe
|
||||||
service:
|
service:
|
||||||
name: 'dhcp-probe'
|
name: '{{ item }}'
|
||||||
state: 'started'
|
state: 'started'
|
||||||
|
with_items: "{{ dhcpd_services.probe }}"
|
||||||
|
|
||||||
|
# vim: set ts=2 sw=2:
|
||||||
|
@ -17,6 +17,8 @@ galaxy_info:
|
|||||||
- name: Debian
|
- name: Debian
|
||||||
versions:
|
versions:
|
||||||
- all
|
- all
|
||||||
|
- name: Archlinux
|
||||||
|
- name: Alpine
|
||||||
categories:
|
categories:
|
||||||
- networking
|
- networking
|
||||||
- system
|
- system
|
||||||
|
20
tasks/dist_vars.yml
Normal file
20
tasks/dist_vars.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Include distribution specific variables
|
||||||
|
include_vars:
|
||||||
|
file: "{{ item }}"
|
||||||
|
name: _os_specific
|
||||||
|
with_first_found:
|
||||||
|
- "{{ ansible_distribution_release }}.yml"
|
||||||
|
- "{{ ansible_distribution }}.yml"
|
||||||
|
- "{{ ansible_os_family }}.yml"
|
||||||
|
- "default.yml"
|
||||||
|
|
||||||
|
- name: Set OS specific vars if undefined
|
||||||
|
set_fact: {
|
||||||
|
"{{ item.key }}":
|
||||||
|
"{{ hostvars[inventory_hostname][item.key] | default(item.value) }}"
|
||||||
|
}
|
||||||
|
with_dict: "{{ _os_specific }}"
|
||||||
|
|
||||||
|
# vim: set ts=2 sw=2:
|
31
tasks/install.yml
Normal file
31
tasks/install.yml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Configure DHCP relay in debconf
|
||||||
|
debconf:
|
||||||
|
name: 'isc-dhcp-relay'
|
||||||
|
question: 'isc-dhcp-relay/{{ item.key }}'
|
||||||
|
vtype: 'string'
|
||||||
|
value: '{{ item.value }}'
|
||||||
|
with_dict:
|
||||||
|
servers: '{{ dhcpd_relay_servers | join(" ") }}'
|
||||||
|
interfaces: '{{ dhcpd_relay_interfaces | join(" ") }}'
|
||||||
|
options: '{{ dhcpd_relay_options }}'
|
||||||
|
register: dhcpd_register_relay_debconf
|
||||||
|
when:
|
||||||
|
- ansible_os_family == "Debian"
|
||||||
|
- dhcpd_mode == 'relay'
|
||||||
|
|
||||||
|
- name: Install DHCP packages
|
||||||
|
package:
|
||||||
|
name: '{{ item }}'
|
||||||
|
state: 'present'
|
||||||
|
with_flattened:
|
||||||
|
- '{{ dhcpd_base_packages_map[dhcpd_mode] }}'
|
||||||
|
- '{{ dhcpd_base_packages_map["probe"] }}'
|
||||||
|
|
||||||
|
- name: Reconfigure ISC DHCP relay
|
||||||
|
command: dpkg-reconfigure --frontend=noninteractive isc-dhcp-relay
|
||||||
|
notify: [ 'Restart dhcp relay' ]
|
||||||
|
when:
|
||||||
|
- ansible_os_family == "Debian"
|
||||||
|
- dhcpd_register_relay_debconf|d() and dhcpd_register_relay_debconf.changed
|
@ -1,31 +1,7 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: Configure DHCP relay in debconf
|
- include: dist_vars.yml
|
||||||
debconf:
|
- include: install.yml
|
||||||
name: 'isc-dhcp-relay'
|
|
||||||
question: 'isc-dhcp-relay/{{ item.key }}'
|
|
||||||
vtype: 'string'
|
|
||||||
value: '{{ item.value }}'
|
|
||||||
with_dict:
|
|
||||||
servers: '{{ dhcpd_relay_servers | join(" ") }}'
|
|
||||||
interfaces: '{{ dhcpd_relay_interfaces | join(" ") }}'
|
|
||||||
options: '{{ dhcpd_relay_options }}'
|
|
||||||
register: dhcpd_register_relay_debconf
|
|
||||||
when: dhcpd_mode == 'relay'
|
|
||||||
|
|
||||||
- name: Install DHCP packages
|
|
||||||
apt:
|
|
||||||
name: '{{ item }}'
|
|
||||||
state: 'present'
|
|
||||||
install_recommends: False
|
|
||||||
with_flattened:
|
|
||||||
- '{{ dhcpd_base_packages_map[dhcpd_mode] }}'
|
|
||||||
- [ '{{ "dhcp-probe" if (dhcpd_probe|d() and dhcpd_probe) else [] }}' ]
|
|
||||||
|
|
||||||
- name: Reconfigure ISC DHCP relay
|
|
||||||
command: dpkg-reconfigure --frontend=noninteractive isc-dhcp-relay
|
|
||||||
notify: [ 'Restart isc-dhcp-relay' ]
|
|
||||||
when: dhcpd_register_relay_debconf|d() and dhcpd_register_relay_debconf.changed
|
|
||||||
|
|
||||||
- name: Get list of nameservers configured in /etc/resolv.conf
|
- name: Get list of nameservers configured in /etc/resolv.conf
|
||||||
shell: grep -E '^nameserver\s' /etc/resolv.conf | awk '{print $2}'
|
shell: grep -E '^nameserver\s' /etc/resolv.conf | awk '{print $2}'
|
||||||
@ -46,8 +22,8 @@
|
|||||||
owner: 'root'
|
owner: 'root'
|
||||||
group: 'root'
|
group: 'root'
|
||||||
mode: '0644'
|
mode: '0644'
|
||||||
with_items: [ 'etc/default/isc-dhcp-server', 'etc/dhcp/dhcpd.conf' ]
|
with_items: "{{ dhcpd_templates }}"
|
||||||
notify: [ 'Restart isc-dhcp-server' ]
|
notify: [ 'Restart dhcp server' ]
|
||||||
register: dhcpd_register_config
|
register: dhcpd_register_config
|
||||||
when: dhcpd_mode == 'server'
|
when: dhcpd_mode == 'server'
|
||||||
|
|
||||||
@ -59,7 +35,7 @@
|
|||||||
group: 'root'
|
group: 'root'
|
||||||
mode: '0644'
|
mode: '0644'
|
||||||
with_items: '{{ dhcpd_includes }}'
|
with_items: '{{ dhcpd_includes }}'
|
||||||
notify: [ 'Restart isc-dhcp-server' ]
|
notify: [ 'Restart dhcp server' ]
|
||||||
when: ((item is defined and item) and dhcpd_mode == 'server' and
|
when: ((item is defined and item) and dhcpd_mode == 'server' and
|
||||||
(dhcpd_register_config is defined and dhcpd_register_config.changed))
|
(dhcpd_register_config is defined and dhcpd_register_config.changed))
|
||||||
|
|
||||||
@ -69,4 +45,3 @@
|
|||||||
|
|
||||||
- include: dhcp-probe.yml
|
- include: dhcp-probe.yml
|
||||||
when: dhcpd_probe|d() and dhcpd_probe
|
when: dhcpd_probe|d() and dhcpd_probe
|
||||||
|
|
||||||
|
22
vars/Alpine.yml
Normal file
22
vars/Alpine.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
dhcpd_base_packages_map:
|
||||||
|
'server':
|
||||||
|
- 'dhcp'
|
||||||
|
'relay':
|
||||||
|
- 'dhcp'
|
||||||
|
'probe':
|
||||||
|
- 'dhcp-probe'
|
||||||
|
|
||||||
|
dhcpd_services:
|
||||||
|
'server':
|
||||||
|
- 'dhcpd'
|
||||||
|
'relay':
|
||||||
|
- 'dhcpd'
|
||||||
|
'probe':
|
||||||
|
- 'dhcp-probe'
|
||||||
|
|
||||||
|
dhcpd_templates:
|
||||||
|
- 'etc/dhcp/dhcpd.conf'
|
||||||
|
|
||||||
|
# vim: set ts=2 sw=2:
|
22
vars/Archlinux.yml
Normal file
22
vars/Archlinux.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
dhcpd_base_packages_map:
|
||||||
|
'server':
|
||||||
|
- 'dhcp'
|
||||||
|
'relay':
|
||||||
|
- 'dhcp'
|
||||||
|
'probe': []
|
||||||
|
|
||||||
|
dhcpd_services:
|
||||||
|
'server':
|
||||||
|
- 'dhcpd4'
|
||||||
|
- 'dhcpd6'
|
||||||
|
'relay':
|
||||||
|
- 'dhcpd4'
|
||||||
|
- 'dhcpd6'
|
||||||
|
'probe': []
|
||||||
|
|
||||||
|
dhcpd_templates:
|
||||||
|
- 'etc/dhcp/dhcpd.conf'
|
||||||
|
|
||||||
|
# vim: set ts=2 sw=2:
|
22
vars/Debian.yml
Normal file
22
vars/Debian.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
dhcpd_base_packages_map:
|
||||||
|
'server':
|
||||||
|
- 'isc-dhcp-server'
|
||||||
|
'relay':
|
||||||
|
- 'isc-dhcp-relay'
|
||||||
|
'probe': []
|
||||||
|
|
||||||
|
dhcpd_services:
|
||||||
|
'server':
|
||||||
|
- 'isc-dhcp-server'
|
||||||
|
'relay':
|
||||||
|
- 'isc-dhcp-relay'
|
||||||
|
'probe':
|
||||||
|
- 'dhcp-probe'
|
||||||
|
|
||||||
|
dhcpd_templates:
|
||||||
|
- 'etc/default/isc-dhcp-server'
|
||||||
|
- 'etc/dhcp/dhcpd.conf'
|
||||||
|
|
||||||
|
# vim: set ts=2 sw=2:
|
20
vars/RedHat.yml
Normal file
20
vars/RedHat.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
dhcpd_base_packages_map:
|
||||||
|
'server':
|
||||||
|
- 'dhcp'
|
||||||
|
'relay':
|
||||||
|
- 'dhcp'
|
||||||
|
'probe': []
|
||||||
|
|
||||||
|
dhcpd_services:
|
||||||
|
'server':
|
||||||
|
- 'dhcpd'
|
||||||
|
'relay':
|
||||||
|
- 'dhcpd'
|
||||||
|
'probe': []
|
||||||
|
|
||||||
|
dhcpd_templates:
|
||||||
|
- 'etc/dhcp/dhcpd.conf'
|
||||||
|
|
||||||
|
# vim: set ts=2 sw=2:
|
22
vars/default.yml
Normal file
22
vars/default.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
dhcpd_base_packages_map:
|
||||||
|
'server':
|
||||||
|
- 'dhcp'
|
||||||
|
'relay':
|
||||||
|
- 'dhcp'
|
||||||
|
'probe': []
|
||||||
|
|
||||||
|
dhcpd_services:
|
||||||
|
'server':
|
||||||
|
- 'dhcpd4'
|
||||||
|
- 'dhcpd6'
|
||||||
|
'relay':
|
||||||
|
- 'dhcpd4'
|
||||||
|
- 'dhcpd6'
|
||||||
|
'probe': []
|
||||||
|
|
||||||
|
dhcpd_templates:
|
||||||
|
- 'etc/dhcp/dhcpd.conf'
|
||||||
|
|
||||||
|
# vim: set ts=2 sw=2:
|
3
vars/main.yml
Normal file
3
vars/main.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
# vim: set ts=2 sw=2:
|
Loading…
Reference in New Issue
Block a user