generated from linux-system-roles/template
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: proper cleanup for networks; ensure cleanup of resources
Cause: The code was not managing network systemd quadlet units. Consequence: Network systemd quadlet units were not being stopped and disabled. Subsequent runs would fail due to the network units not being cleaned up properly. Fix: The role manages network systemd quadlet units, including stopping and removing. Result: Systemd quadlet network units are properly cleaned up. In addition - improve the removal of all types of quadlet resources, and include code which can be used to test and debug quadlet resource removal.
- Loading branch information
Showing
12 changed files
with
321 additions
and
58 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
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
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
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,57 @@ | ||
--- | ||
# Input: | ||
# * __podman_quadlet_file - path to quadlet file to parse | ||
# Output: | ||
# * __podman_quadlet_parsed - dict | ||
- name: Slurp quadlet file | ||
slurp: | ||
path: "{{ __podman_quadlet_file }}" | ||
register: __podman_quadlet_raw | ||
no_log: true | ||
|
||
- name: Parse quadlet file | ||
set_fact: | ||
__podman_quadlet_parsed: |- | ||
{% set rv = {} %} | ||
{% set section = ["DEFAULT"] %} | ||
{% for line in __val %} | ||
{% if line.startswith("[") %} | ||
{% set val = line.replace("[", "").replace("]", "") %} | ||
{% set _ = section.__setitem__(0, val) %} | ||
{% else %} | ||
{% set ary = line.split("=", 1) %} | ||
{% set key = ary[0] %} | ||
{% set val = ary[1] %} | ||
{% if key in rv.get(section[0], {}) %} | ||
{% set curval = rv[section[0]][key] %} | ||
{% if curval is string %} | ||
{% set newary = [curval, val] %} | ||
{% set _ = rv[section[0]].__setitem__(key, newary) %} | ||
{% else %} | ||
{% set _ = rv[section[0]][key].append(val) %} | ||
{% endif %} | ||
{% else %} | ||
{% set _ = rv.setdefault(section[0], {}).__setitem__(key, val) %} | ||
{% endif %} | ||
{% endif %} | ||
{% endfor %} | ||
{{ rv }} | ||
vars: | ||
__val: "{{ (__podman_quadlet_raw.content | b64decode).split('\n') | | ||
select | reject('match', '#') | list }}" | ||
when: __podman_service_name | length > 0 | ||
no_log: true | ||
|
||
- name: Parse quadlet yaml file | ||
set_fact: | ||
__podman_quadlet_parsed: "{{ __podman_quadlet_raw.content | b64decode | | ||
from_yaml_all }}" | ||
when: | ||
- __podman_service_name | length == 0 | ||
- __podman_quadlet_file.endswith(".yml") or | ||
__podman_quadlet_file.endswith(".yaml") | ||
no_log: true | ||
|
||
- name: Reset raw variable | ||
set_fact: | ||
__podman_quadlet_raw: null |
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
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
Oops, something went wrong.