ctucx.git: ansible-configs

My personal ansible roles and playbooks [deprecated in favor of nixos]

commit 10692241c6c498013d67cb1cd4c886be58ed3dcc
parent f520675df4837adffa67935775167a66585ca023
Author: Leah (ctucx) <leah@ctu.cx>
Date: Wed, 3 Feb 2021 18:36:13 +0100

move systemd-networkd role into submodule
15 files changed, 6 insertions(+), 265 deletions(-)
diff --git a/.gitmodules b/.gitmodules
@@ -1,3 +1,6 @@
 [submodule "roles/systemd-timers"]
 	path = roles/systemd-timers
 	url = https://github.com/vlcty/ansible-systemd-timers
+[submodule "roles/systemd-networkd"]
+	path = roles/systemd-networkd
+	url = https://github.com/KawaiDesu/ansible-networkd
diff --git a/playbook.yml b/playbook.yml
@@ -81,7 +81,7 @@
   roles:
     - role: common            # supports: alpine, arch
       tags: common
-    - role: kawaidesu.ansible_networkd
+    - role: systemd-networkd
       tags: systemd-networkd
     - role: files             # supports: alpine, arch
       tags: files

@@ -100,7 +100,7 @@
       tags: files
     - role: systemd-timers
       tags: timers
-    - role: kawaidesu.ansible_networkd
+    - role: systemd-networkd
       tags: systemd-networkd
     - role: acme-redirect
       tags: acme-redirect
diff --git a/roles/kawaidesu.ansible_networkd/CHANGELOG.md b/roles/kawaidesu.ansible_networkd/CHANGELOG.md
@@ -1,13 +0,0 @@
-# Changelog
-All notable changes to this project will be documented in this file.
-
-The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
-and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-
-## [0.1.1] - 2020-06-04
-### Fixed
-- Most ansible-lint warnings from galaxy.ansible.com
-    
-## [0.1.0] - 2020-06-04
-### Added
-- Inital release
diff --git a/roles/kawaidesu.ansible_networkd/LICENSE b/roles/kawaidesu.ansible_networkd/LICENSE
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2020 Oleg "Zmey!" Vasiliev
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/roles/kawaidesu.ansible_networkd/README.md b/roles/kawaidesu.ansible_networkd/README.md
@@ -1,74 +0,0 @@
-networkd 
-=========
-
-An Ansible role for configuring systemd-networkd.
-
-This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-
-Requirements
-------------
-
-This role assumes that networkd is already present in the system. So it should be suitable for any distro with networkd.
-
-Role Variables
---------------
-
-Example configuration. Follow networkd documentation to construct yours.
-```yaml
-networkd:
- link:
-     # This is file name
-   - name: eth0
-     # This is prefix for file. This results in following file name: 50-eth0.link
-     priority: 50
-     content:
-       - Match:
-         - MACAddress: "aa:bb:cc:dd:ee:ff"
-       - Link:
-         - Name: eth0
- netdev:
-   - name: br0
-     priority: 50
-     content:
-       - NetDev:
-         - Name: br0
-         - Kind: bridge
- network:
-   - name: eth0
-     priority: 50
-     content:
-       - Match:
-         - Name: eth0
-       - Network:
-         - DHCP: ipv4
-         - LinkLocalAddressing: no
-         - LLDP: yes
-       - DHCPv4:
-         - UseHostname: no
-         - Hostname: gimme-some-addr
-         - UseMTU: yes
-   - name: br0_slaves
-     priority: 50
-     content:
-       - Match:
-         - MACAddress: "11:bb:cc:dd:ee:ff 22:bb:cc:dd:ee:ff"
-       - Network:
-         - Bridge: br0
-```
-
-What to do on configuration changes. Could be "restart", "reload" or "nothing". Variable is mandatory.
-```yaml
-networkd_apply_action: "restart"
-```
-
-Custom content for `/etc/resolv.conf`. Every element in list is string in file. Variable is optional.
-```yaml
-networkd_resolv_conf_content:
-  - nameserver 1.1.1.1
-  - nameserver 8.8.8.8
-```
-
-License
--------
-
-MIT
diff --git a/roles/kawaidesu.ansible_networkd/defaults/main.yml b/roles/kawaidesu.ansible_networkd/defaults/main.yml
@@ -1,6 +0,0 @@
----
-
-networkd:
-
-# Could be "restart", "reload" or "nothing"
-networkd_apply_action: "restart"
diff --git a/roles/kawaidesu.ansible_networkd/handlers/main.yml b/roles/kawaidesu.ansible_networkd/handlers/main.yml
@@ -1,17 +0,0 @@
----
-
-- name: networkd | Do restart
-  systemd:
-    name: systemd-networkd
-    state: restarted
-
-# From man:
-# Reload .netdev and .network files. If a new .netdev file is found, then the corresponding netdev is created.
-# Note that even if an existing .netdev is modified or removed, systemd-networkd does not update or remove the netdev.
-# If a new, modified or removed .network file is found, then all interfaces which match the file are reconfigured.
-- name: networkd | Do reload
-  shell: networkctl reload
-
-- name: networkd | Do nothing
-  debug:
-    msg: "Not applying new configuration due to selected action."
diff --git a/roles/kawaidesu.ansible_networkd/meta/.galaxy_install_info b/roles/kawaidesu.ansible_networkd/meta/.galaxy_install_info
@@ -1,2 +0,0 @@
-install_date: Wed Dec  9 09:17:04 2020
-version: 0.1.1
diff --git a/roles/kawaidesu.ansible_networkd/meta/main.yml b/roles/kawaidesu.ansible_networkd/meta/main.yml
@@ -1,30 +0,0 @@
----
-galaxy_info:
-  author: 'Oleg "Zmey!" Vasiliev'
-  description: An Ansible role for configuring systemd-networkd
-
-  license: MIT
-
-  min_ansible_version: 2.4
-
-  # Totally not a full list...
-  platforms:
-    - name: Archlinux
-      versions: all
-    - name: Ubuntu
-      versions:
-        - xenial
-        - boinic
-        - focal
-    - name: Debian
-      versions:
-        - jessie
-        - stretch
-        - buster
-
-  galaxy_tags:
-    - networking
-    - networkd
-    - systemd
-
-dependencies: []
diff --git a/roles/kawaidesu.ansible_networkd/tasks/deploy_configs.yml b/roles/kawaidesu.ansible_networkd/tasks/deploy_configs.yml
@@ -1,34 +0,0 @@
----
-
-- name: networkd | Deploy .link configs
-  template:
-    src: networkd.j2
-    dest: "/etc/systemd/network/{{ item.priority }}-{{ item.name }}.link"
-    mode: 0644
-    owner: root
-    group: root
-  with_items: "{{ networkd.link | default([]) }}"
-  register: networkd_deployed_link
-  notify: networkd | Do {{ networkd_apply_action }}
-
-- name: networkd | Deploy .netdev configs
-  template:
-    src: networkd.j2
-    dest: "/etc/systemd/network/{{ item.priority }}-{{ item.name }}.netdev"
-    mode: 0644
-    owner: root
-    group: root
-  with_items: "{{ networkd.netdev | default([]) }}"
-  register: networkd_deployed_netdev
-  notify: networkd | Do {{ networkd_apply_action }}
-
-- name: networkd | Deploy .network configs
-  template:
-    src: networkd.j2
-    dest: "/etc/systemd/network/{{ item.priority }}-{{ item.name }}.network"
-    mode: 0644
-    owner: root
-    group: root
-  with_items: "{{ networkd.network | default([]) }}"
-  register: networkd_deployed_network
-  notify: networkd | Do {{ networkd_apply_action }}
diff --git a/roles/kawaidesu.ansible_networkd/tasks/main.yml b/roles/kawaidesu.ansible_networkd/tasks/main.yml
@@ -1,30 +0,0 @@
----
-
-- name: Check role vars
-  assert:
-    that:
-      - networkd_apply_action == "restart" or networkd_apply_action == "reload" or networkd_apply_action == "nothing"
-    fail_msg: 'networkd_apply_action shoud be "restart", "reload" or "nothing"'
-    quiet: yes
-
-- import_tasks: deploy_configs.yml
-
-- import_tasks: remove_unmanaged.yml
-
-- name: networkd | Deploy resolv.conf
-  template:
-    src: resolv.conf.j2
-    dest: /etc/resolv.conf
-    mode: 0644
-    owner: root
-    group: root
-  when: networkd_resolv_conf_content is defined
-
-- name: networkd | Enable and start service
-  systemd:
-    name: systemd-networkd
-    state: started
-    enabled: yes
-
-- name: networkd | Run handlers now
-  meta: flush_handlers
diff --git a/roles/kawaidesu.ansible_networkd/tasks/remove_unmanaged.yml b/roles/kawaidesu.ansible_networkd/tasks/remove_unmanaged.yml
@@ -1,20 +0,0 @@
----
-- name: networkd | Collect file list in network dir
-  find:
-    path: /etc/systemd/network
-    hidden: yes
-  register: networkd_found_files
-  check_mode: no
-  changed_when: false
-
-- name: networkd | Remove unmanaged files
-  file:
-    path: "/etc/systemd/network/{{ item.path | basename }}"
-    state: absent
-  with_items:
-   - "{{ networkd_found_files.files }}"
-  when:
-    - (item.path) not in ( networkd_deployed_link | json_query('results[].invocation.module_args.dest') | default([]) )
-    - (item.path) not in ( networkd_deployed_netdev | json_query('results[].invocation.module_args.dest') | default([]) )
-    - (item.path) not in ( networkd_deployed_network | json_query('results[].invocation.module_args.dest') | default([]) )
-  notify: networkd | Do {{ networkd_apply_action }}
diff --git a/roles/kawaidesu.ansible_networkd/templates/networkd.j2 b/roles/kawaidesu.ansible_networkd/templates/networkd.j2
@@ -1,12 +0,0 @@
-# {{ ansible_managed }}
-{% for section in item.content %}
-{% for section_name, section_params in section.items() %}
-
-[{{ section_name }}]
-{% for item in section_params %}
-{% for key, value in item.items() %}
-{{ key }}={{ value }}
-{% endfor %}
-{% endfor %}
-{% endfor %}
-{% endfor %}
diff --git a/roles/kawaidesu.ansible_networkd/templates/resolv.conf.j2 b/roles/kawaidesu.ansible_networkd/templates/resolv.conf.j2
@@ -1,4 +0,0 @@
-# {{ ansible_managed }}
-{% for item in networkd_resolv_conf_content %}
-{{ item }}
-{% endfor %}
diff --git a/roles/systemd-networkd b/roles/systemd-networkd
@@ -0,0 +1 @@
+Subproject commit 279bff42a8b416db18ed837c83a2769014306157