Skip to content

Commit

Permalink
adds networkd role
Browse files Browse the repository at this point in the history
  • Loading branch information
wookietreiber committed Nov 21, 2024
1 parent 3522742 commit 21114d6
Show file tree
Hide file tree
Showing 10 changed files with 537 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/molecule-networkd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---

name: molecule-networkd

on:
pull_request:
paths:
- .config/molecule
- .github/workflows/molecule-networkd.yml
- roles/systemd_networkd
push:
branches:
- main
- wip/next
paths:
- .config/molecule
- .github/workflows/molecule-networkd.yml
- roles/systemd_networkd

jobs:

molecule:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
distro:
- archlinux
scenario:
- default
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- run: pip3 install ansible molecule molecule-plugins[docker] docker
- run: ansible --version
- run: molecule --version
- run: molecule test -p ${{ matrix.distro }} -s ${{ matrix.scenario }}
working-directory: ./roles/systemd_networkd
env:
ANSIBLE_DIFF_ALWAYS: 'True'
PY_COLORS: '1'

...
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Ansible Collection - idiv_biodiversity.systemd

- [idiv_biodiversity.systemd.systemd_journald](roles/systemd_journald/README.md)
- [idiv_biodiversity.systemd.systemd_networkd](roles/systemd_networkd/README.md)
119 changes: 119 additions & 0 deletions roles/systemd_networkd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
Ansible Role: systemd_networkd
==============================

An Ansible role that configures **systemd-networkd**.

Table of Contents
-----------------

<!-- toc -->

- [Role Variables](#role-variables)
- [Dependencies](#dependencies)
- [Example Playbook](#example-playbook)
* [Top-Level Playbook](#top-level-playbook)
* [Role Dependency](#role-dependency)

<!-- tocstop -->

Role Variables
--------------

For a detailed description see `man 5 systemd.network`.

**Note:** This role doesn't aim to be 100% complete at all times. When new
variables are introduced and you need them feel free to contribute.

```yml
---
# host_vars/my-client/vars.yml

systemd_networkd_networks:

- name: 20-wired-static
match:
name: en*
network:
address: a.b.c.d/24
gateway: a.b.c.x
dns:
- a.b.c.y
- a.b.c.z
domains:
- example.com
llmnr: 'no'
multicast_dns: 'no'
ntp:
- 1.ntp.example.com
- 2.ntp.example.com
- 3.ntp.example.com
- 4.ntp.example.com

- name: 50-wireless
match:
name: w*
network:
dhcp: ipv4
link_local_addressing: ipv4
dhcp:
route_metric: 20

...
```


Dependencies
------------

```yml
---

# requirements.yml

collections:

- name: idiv_biodiversity.systemd
version: X.Y.Z

...
```


Example Playbook
----------------

### Top-Level Playbook

Write a top-level playbook:

```yml
---

- name: head server
hosts: head

roles:
- role: idiv_biodiversity.systemd.systemd_networkd
tags:
- systemd
- systemd-networkd

...
```

### Role Dependency

Define the role dependency in `meta/main.yml`:

```yml
---

dependencies:

- role: idiv_biodiversity.systemd.systemd_networkd
tags:
- systemd
- systemd-networkd

...
```
138 changes: 138 additions & 0 deletions roles/systemd_networkd/meta/argument_specs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
---

argument_specs:
main:
options:

systemd_networkd_networks:
type: list
elements: dict
options:
name:
type: str
match:
type: dict
options:
name:
type: str
network:
type: dict
options:
address:
type: str
dhcp:
type: str
gateway:
type: str
dns:
type: list
elements: str
domains:
type: list
elements: str
link_local_addressing:
type: str
llmnr:
type: str
multicast_dns:
type: str
ntp:
type: list
elements: str
dhcp:
type: dict
options:
route_metric:
type: int

systemd_journald_audit:
type: bool

systemd_journald_compress:
type: bool

systemd_journald_forwardtoconsole:
type: bool

systemd_journald_forwardtokmsg:
type: bool

systemd_journald_forwardtosyslog:
type: bool

systemd_journald_forwardtowall:
type: bool

systemd_journald_linemax:
type: str

systemd_journald_maxfilesec:
type: str

systemd_journald_maxlevelconsole:
type: str

systemd_journald_maxlevelkmsg:
type: str

systemd_journald_maxlevelstore:
type: str

systemd_journald_maxlevelsyslog:
type: str

systemd_journald_maxlevelwall:
type: str

systemd_journald_maxretentionsec:
type: str

systemd_journald_ratelimitburst:
type: str

systemd_journald_ratelimitintervalsec:
type: str

systemd_journald_readkmsg:
type: bool

systemd_journald_runtimekeepfree:
type: str

systemd_journald_runtimemaxfiles:
type: str

systemd_journald_runtimemaxfilesize:
type: str

systemd_journald_runtimemaxuse:
type: str

systemd_journald_seal:
type: bool

systemd_journald_splitmode:
type: str

systemd_journald_storage:
type: str

systemd_journald_syncintervalsec:
type: str

systemd_journald_systemkeepfree:
type: str

systemd_journald_systemmaxfiles:
type: str

systemd_journald_systemmaxfilesize:
type: str

systemd_journald_systemmaxuse:
type: str

systemd_journald_ttypath:
type: str

...
20 changes: 20 additions & 0 deletions roles/systemd_networkd/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---

galaxy_info:
author: Christian Krause
description: install and configure systemd-networkd
company: German Centre for Integrative Biodiversity Research (iDiv)
license: MIT
min_ansible_version: '2.9'

platforms:

- name: ArchLinux
versions:
- all

galaxy_tags:
- systemd
- networkd

...
24 changes: 24 additions & 0 deletions roles/systemd_networkd/molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---

- name: converge
hosts: all

pre_tasks:

- name: update package cache
ansible.builtin.package:
update_cache: yes
become: yes
changed_when: no
register: __update_package_cache
until: __update_package_cache is success
retries: 10
delay: 2

tasks:

- name: include the role
ansible.builtin.include_role:
name: idiv_biodiversity.systemd.systemd_networkd

...
3 changes: 3 additions & 0 deletions roles/systemd_networkd/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

...
Loading

0 comments on commit 21114d6

Please sign in to comment.