-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Christian Berendt <[email protected]>
- Loading branch information
Showing
14 changed files
with
181 additions
and
0 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
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,15 @@ | ||
--- | ||
- name: Ensure docker | ||
ansible.builtin.include_role: | ||
name: docker | ||
vars: | ||
docker_user: zuul | ||
docker_group: zuul | ||
docker_python_install: false | ||
|
||
- name: Ensure docker-compose | ||
ansible.builtin.include_role: | ||
name: osism.commons.docker_compose | ||
vars: | ||
docker_compose_service_user: zuul | ||
docker_compose_service_group: zuul |
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,25 @@ | ||
from .util.util import get_ansible, get_variable | ||
|
||
testinfra_runner, testinfra_hosts = get_ansible() | ||
|
||
|
||
def test_dnsmasq_directories(host): | ||
directories = [ | ||
get_variable(host, "dnsmasq_docker_compose_directory"), | ||
get_variable(host, "dnsmasq_configuration_directory"), | ||
] | ||
|
||
for d in directories: | ||
f = host.file(d) | ||
assert f.exists | ||
assert f.is_directory | ||
assert f.mode == 0o750 | ||
assert f.user == get_variable(host, "operator_user") | ||
assert f.group == get_variable(host, "operator_group") | ||
|
||
|
||
def test_dnsmasq_service(host): | ||
service = host.service(get_variable(host, "dnsmasq_service_name")) | ||
|
||
assert service.is_running | ||
assert service.is_enabled |
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,3 @@ | ||
--- | ||
operator_user: zuul | ||
operator_group: zuul |
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 @@ | ||
--- |
Empty file.
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,26 @@ | ||
--- | ||
########################## | ||
# operator | ||
|
||
operator_user: dragon | ||
operator_group: "{{ operator_user }}" | ||
|
||
########################## | ||
# dnsmasq | ||
|
||
dnsmasq_configuration_directory: /opt/dnsmasq/configuration | ||
dnsmasq_docker_compose_directory: /opt/dnsmasq | ||
|
||
dnsmasq_service_name: "docker-compose@dnsmasq" | ||
|
||
dnsmasq_container_name: dnsmasq | ||
|
||
dnsmasq_interface: "{{ ansible_default_ipv4.interface }}" | ||
dnsmasq_dhcp_range: "192.168.42.100,192.168.42.200,3h" | ||
dnsmasq_dhcp_hosts: | ||
- aa:bb:cc:dd:ee:ff,testbed-manager,192.168.42.10 | ||
|
||
dnsmasq_docker_registry: quay.io | ||
# renovate: datasource=docker depName=quay.io/osism/dnsmasq-osism | ||
dnsmasq_tag: '2.90' | ||
dnsmasq_image: "{{ dnsmasq_docker_registry }}/osism/dnsmasq-osism:{{ dnsmasq_tag }}" |
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,10 @@ | ||
--- | ||
- name: Restart dnsmasq service | ||
become: true | ||
ansible.builtin.service: | ||
name: "{{ dnsmasq_service_name }}" | ||
state: restarted | ||
register: result | ||
until: result["status"]["ActiveState"] == "active" | ||
retries: 10 | ||
delay: 20 |
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,22 @@ | ||
--- | ||
galaxy_info: | ||
author: Christian Berendt | ||
description: Role osism.services.dnsmasq | ||
company: OSISM GmbH | ||
license: Apache License 2.0 | ||
min_ansible_version: 2.16.0 | ||
platforms: | ||
- name: Ubuntu | ||
versions: | ||
- jammy | ||
- noble | ||
- name: Debian | ||
versions: | ||
- bookworm | ||
- name: EL | ||
versions: | ||
- "9" | ||
galaxy_tags: | ||
- osism | ||
- system | ||
dependencies: [] |
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,22 @@ | ||
--- | ||
- name: Create required directories | ||
become: true | ||
ansible.builtin.file: | ||
path: "{{ item }}" | ||
state: directory | ||
owner: "{{ operator_user }}" | ||
group: "{{ operator_group }}" | ||
mode: 0750 | ||
loop: | ||
- "{{ dnsmasq_docker_compose_directory }}" | ||
- "{{ dnsmasq_configuration_directory }}" | ||
|
||
- name: Copy configuration files | ||
ansible.builtin.template: | ||
src: "{{ item }}.j2" | ||
dest: "{{ dnsmasq_configuration_directory }}/{{ item }}" | ||
mode: 0644 | ||
owner: "{{ operator_user }}" | ||
group: "{{ operator_group }}" | ||
loop: | ||
- dnsmasq.conf |
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 @@ | ||
--- | ||
- name: Include config tasks | ||
ansible.builtin.include_tasks: config.yml | ||
tags: config | ||
|
||
- name: Include service tasks | ||
ansible.builtin.include_tasks: service.yml | ||
tags: service |
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,20 @@ | ||
--- | ||
- name: Copy docker-compose.yml file | ||
ansible.builtin.template: | ||
src: docker-compose.yml.j2 | ||
dest: "{{ dnsmasq_docker_compose_directory }}/docker-compose.yml" | ||
owner: "{{ operator_user }}" | ||
group: "{{ operator_group }}" | ||
mode: 0640 | ||
notify: Restart dnsmasq service | ||
|
||
- name: Manage dnsmasq service | ||
become: true | ||
ansible.builtin.service: | ||
name: "{{ dnsmasq_service_name }}" | ||
state: started | ||
enabled: true | ||
register: result | ||
until: result["status"]["ActiveState"] == "active" | ||
retries: 10 | ||
delay: 20 |
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,6 @@ | ||
port=0 | ||
interface={{ dnsmasq_interface }} | ||
dhcp-range={{ dnsmasq_dhcp_range }} | ||
{% for dhcp_host in dnsmasq_dhcp_hosts %} | ||
dhcp-host={{ dhcp_host }} | ||
{% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
services: | ||
dnsmasq: | ||
image: "{{ dnsmasq_image }}" | ||
container_name: "{{ dnsmasq_container_name }}" | ||
restart: unless-stopped | ||
network_mode: host | ||
cap_add: | ||
- NET_ADMIN | ||
volumes: | ||
- "/etc/hosts:/etc/hosts:ro" | ||
- "{{ dnsmasq_configuration_directory }}/dnsmasq.conf:/etc/dnsmasq.conf:ro" |