-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
139 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
container: metalstack/metal-deployment-base:latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Test | ||
run: | | ||
make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.PHONY: test | ||
test: | ||
for file in $(shell find . -name test -type d); do python -m unittest discover -v -p '*_test.py' -s $$(dirname $$file); done | ||
|
||
.PHONY: test-local | ||
test-local: | ||
docker pull metalstack/metal-deployment-base:latest | ||
docker run --rm -it -v $(PWD):/work -w /work metalstack/metal-deployment-base:latest make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,24 @@ | ||
--- | ||
dhcp_net: | ||
dhcp_netmask: | ||
dhcp_range_min: | ||
dhcp_range_max: | ||
dhcp_server_ip: | ||
|
||
dhcp_dns_servers: | ||
- 1.1.1.1 | ||
- 8.8.8.8 | ||
dhcp_subnets: [] | ||
# examples: | ||
# - comment: "" | ||
# network: | ||
# netmask: | ||
# range: | ||
# begin: | ||
# end: | ||
# options: [] | ||
|
||
dhcp_listening_interfaces: | ||
- vlan4000 | ||
|
||
dhcp_default_lease_time: 172800 | ||
dhcp_max_lease_time: 345600 | ||
|
||
dhcp_global_options: [] | ||
# examples: | ||
# - default-url = "http://{{ ansible_host }}/onie-installer" | ||
# - ztp_provisioning_script_url code 239 = text | ||
# - ztp_provisioning_script_url "http://{{ ansible_host }}/ztp.sh" | ||
|
||
dhcp_service_name: "{{ 'dhcpd' if metal_stack_switch_os_is_cumulus | default(false) else 'isc-dhcp-server' }}" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,49 @@ | ||
--- | ||
- name: Gather switch facts | ||
switch_facts: | ||
|
||
- name: Check mandatory variables for this role are set | ||
assert: | ||
fail_msg: "not all mandatory variables given, check role documentation" | ||
quiet: yes | ||
that: | ||
- dhcp_net is defined | ||
- dhcp_netmask is not none | ||
- dhcp_server_ip is not none | ||
- dhcp_range_min is not none | ||
- dhcp_range_max is not none | ||
- dhcp_listening_interfaces | type_debug == "list" | ||
- item.network is defined | ||
- item.netmask is not none | ||
- item.range is not none | ||
- item.range.begin is not none | ||
- item.range.end is not none | ||
loop: "{{ dhcp_subnets }}" | ||
loop_control: | ||
label: "{{ item.network }}" | ||
|
||
- name: install isc-dhcp-server | ||
apt: | ||
name: | ||
- isc-dhcp-server | ||
update_cache : yes | ||
|
||
- name: render dhcpd conf | ||
template: | ||
src: dhcpd.conf.j2 | ||
dest: /etc/dhcp/dhcpd.conf | ||
notify: dhcpd restart | ||
register: _dhcpd_conf | ||
|
||
- name: render isc config for | ||
- name: render isc-dhcp-server config | ||
template: | ||
src: isc-dhcp-server.j2 | ||
dest: /etc/default/isc-dhcp-server | ||
notify: dhcpd restart | ||
register: _isc_dhcp_server | ||
|
||
- name: restart isc-dhcp-server on config change | ||
service: | ||
name: "{{ dhcp_service_name }}" | ||
enabled: true | ||
state: restarted | ||
when: _dhcpd_conf is changed or _isc_dhcp_server is changed | ||
|
||
- name: dhcpd enabled | ||
- name: ensure isc-dhcp-server is running | ||
service: | ||
name: dhcpd | ||
name: "{{ dhcp_service_name }}" | ||
enabled: true | ||
state: started |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
default-lease-time 600; | ||
max-lease-time 600; | ||
# indicate that the DHCP server should send DHCPNAK messages to misconfigured client | ||
authoritative; | ||
|
||
default-lease-time {{ dhcp_default_lease_time }}; | ||
max-lease-time {{ dhcp_max_lease_time }}; | ||
|
||
log-facility local7; | ||
|
||
subnet {{ dhcp_net }} netmask {{ dhcp_netmask }} { | ||
range {{ dhcp_range_min }} {{ dhcp_range_max }}; | ||
# Provide routers to set up default gateway for clients. | ||
option routers {{ dhcp_server_ip }}; | ||
# In case of Vagrant DNS must not be resolved via mgmt servers. | ||
# This is because the setup to provide e.g. metal images via mgmt servers exceeds resources in Vagrant case. | ||
option domain-name-servers {{ dhcp_dns_servers | join(', ') }}; | ||
{% for subnet in dhcp_subnets %} | ||
{% if subnet.comment | default("") %} | ||
# {{ subnet.comment }} | ||
{% endif %} | ||
subnet {{ subnet.network }} netmask {{ subnet.netmask }} { | ||
{% if subnet.range is defined %} | ||
range {{ subnet.range.begin }} {{ subnet.range.end }}; | ||
{% endif %} | ||
{% for option in subnet.options | default([]) %} | ||
option {{ option }}; | ||
{% endfor %} | ||
} | ||
{% endfor %} | ||
|
||
{% for option in dhcp_global_options %} | ||
option {{ option }}; | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters