Vendor Galaxy Roles and Collections

This commit is contained in:
Stefan Bethke 2026-02-06 22:07:16 +01:00
commit 2aed20393f
3553 changed files with 387444 additions and 2 deletions

View file

@ -0,0 +1,19 @@
debops.persistent_paths - Ensure paths are stored on persistent storage
Copyright (C) 2016-2017 Robin Schneider <ypid@riseup.net>
Copyright (C) 2016-2017 DebOps <https://debops.org/>
SPDX-License-Identifier: GPL-3.0-only
This Ansible role is part of DebOps.
DebOps is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3, as
published by the Free Software Foundation.
DebOps is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DebOps. If not, see https://www.gnu.org/licenses/.

View file

@ -0,0 +1,110 @@
---
# .. vim: foldmarker=[[[,]]]:foldmethod=marker
# .. Copyright (C) 2016-2017 Robin Schneider <ypid@riseup.net>
# .. Copyright (C) 2016-2017 DebOps <https://debops.org/>
# .. SPDX-License-Identifier: GPL-3.0-only
# .. _persistent_paths__ref_defaults:
# debops.persistent_paths default variables [[[
# =============================================
# .. contents:: Sections
# :local:
#
# .. include:: ../../../../includes/global.rst
# .. include:: ../includes/role.rst
# Persistent paths [[[
# --------------------
# The following dictionary variables can be used to manage the persistence of paths.
# See :ref:`persistent_paths__ref_paths` for more details.
# .. envvar:: persistent_paths__paths [[[
#
# Dict for specifying persistent paths.
# This variable is intended to be used in Ansibles global inventory.
persistent_paths__paths: {}
# ]]]
# .. envvar:: persistent_paths__group_paths [[[
#
# Dict for specifying persistent paths.
# This variable is intended to be used in a host inventory group of Ansible
# (only one host group is supported).
persistent_paths__group_paths: {}
# ]]]
# .. envvar:: persistent_paths__host_paths [[[
#
# Dict for specifying persistent paths.
# This variable is intended to be used in the inventory of hosts.
persistent_paths__host_paths: {}
# ]]]
# .. envvar:: persistent_paths__dependent_paths [[[
#
# Dict for specifying persistent paths. This variable is intended for other Ansible
# roles to be used when using ``debops.persistent_paths`` as role dependency.
persistent_paths__dependent_paths: {}
# ]]]
# .. envvar:: persistent_paths__combined_paths [[[
#
# Combined dictionary of persistent paths as it is used by the role.
# This defines the order in which dictionary keys might "mask" previous once.
persistent_paths__combined_paths: '{{
persistent_paths__dependent_paths
| combine(persistent_paths__paths)
| combine(persistent_paths__group_paths)
| combine(persistent_paths__host_paths) }}'
# ]]]
# ]]]
# Qubes OS [[[
# ------------
# .. envvar:: persistent_paths__qubes_os_enabled [[[
#
# Should the role run Qubes OS specific tasks?
persistent_paths__qubes_os_enabled: '{{ True
if (ansible_virtualization_role == "guest" and
"qubes" in (ansible_kernel | lower))
else False }}'
# ]]]
# .. envvar:: persistent_paths__qubes_os_config_dir [[[
#
# Directory path where the role should maintain the configuration for
# bind-dirs.sh_.
persistent_paths__qubes_os_config_dir: '/rw/config/qubes-bind-dirs.d'
# ]]]
# .. envvar:: persistent_paths__qubes_os_storage_path [[[
#
# Persistent directory path where the files/directories are stored and from
# which these source paths are then bind mounted to their canonical/original
# location.
persistent_paths__qubes_os_storage_path: '/rw/bind-dirs'
# ]]]
# .. envvar:: persistent_paths__qubes_os_handler [[[
#
# File path to the executable bind-dirs.sh_ script.
persistent_paths__qubes_os_handler: '/usr/lib/qubes/bind-dirs.sh'
# ]]]
# .. envvar:: persistent_paths__qubes_os_default_persistent_paths [[[
#
# Paths which are persistent by default and should be filtered out/not handled
# by bind-dirs.sh_.
persistent_paths__qubes_os_default_persistent_paths:
- '/home'
- '/usr/local'
- '/var/spool/cron'
- '/rw'
# ]]]
# ]]]
# ]]]

View file

@ -0,0 +1,9 @@
---
# Copyright (C) 2016-2017 Robin Schneider <ypid@riseup.net>
# Copyright (C) 2016-2017 DebOps <https://debops.org/>
# SPDX-License-Identifier: GPL-3.0-only
- name: 'Run bind-dirs'
ansible.builtin.command: '{{ persistent_paths__qubes_os_handler }}'
register: persistent_paths__register_bind_dirs
changed_when: persistent_paths__register_bind_dirs.changed | bool

View file

@ -0,0 +1,33 @@
---
# Copyright (C) 2016-2017 Robin Schneider <ypid@riseup.net>
# Copyright (C) 2016-2022 DebOps <https://debops.org/>
# SPDX-License-Identifier: GPL-3.0-only
# Ensure that custom Ansible plugins and modules included in the main DebOps
# collection are available to roles in other collections.
collections: [ 'debops.debops' ]
dependencies: []
galaxy_info:
author: 'Robin Schneider'
description: 'Ensure paths are stored on persistent storage'
company: 'DebOps'
license: 'GPL-3.0-only'
min_ansible_version: '2.1.4'
platforms:
- name: 'Ubuntu'
versions: [ 'all' ]
- name: 'Debian'
versions: [ 'all' ]
galaxy_tags:
- persistent
- persistence
- qubesos
- templatebasedvm
- appvm

View file

@ -0,0 +1,65 @@
---
# vim: foldmarker=[[[,]]]:foldmethod=marker
# Copyright (C) 2016-2017 Robin Schneider <ypid@riseup.net>
# Copyright (C) 2016-2017 DebOps <https://debops.org/>
# SPDX-License-Identifier: GPL-3.0-only
- name: Import DebOps global handlers
ansible.builtin.import_role:
name: 'global_handlers'
- name: Configure QubesOS environment
when: persistent_paths__qubes_os_enabled | bool
tags: [ 'role::persistent_paths:qubes_os' ]
block:
- name: Ensure the qubes-bind-dirs.d directory does exist
ansible.builtin.file:
path: '{{ persistent_paths__qubes_os_config_dir }}'
state: 'directory'
owner: 'root'
group: 'root'
mode: '0750'
- name: Configuration persistent paths on Qubes OS
ansible.builtin.template:
src: 'rw/config/qubes-bind-dirs.d/default.conf.j2'
dest: '{{ persistent_paths__qubes_os_config_dir + "/" + item.key + ".conf" }}'
owner: 'root'
group: 'root'
mode: '0644'
when: (item.value.state | d("present") == "present")
with_dict: '{{ persistent_paths__combined_paths }}'
notify: [ 'Run bind-dirs' ]
- name: Remove configuration of persistent paths on Qubes OS
ansible.builtin.file:
path: '{{ persistent_paths__qubes_os_config_dir + "/" + item.key + ".conf" }}'
state: 'absent'
when: (item.value.state | d("present") == "absent")
with_dict: '{{ persistent_paths__combined_paths }}'
notify: [ 'Run bind-dirs' ]
# Ansible facts [[[
- name: Make sure Ansible fact directory exists
ansible.builtin.file:
path: '/etc/ansible/facts.d'
state: 'directory'
owner: 'root'
group: 'root'
mode: '0755'
- name: Create local facts of persistent_paths
ansible.builtin.template:
src: 'etc/ansible/facts.d/persistent_paths.fact.j2'
dest: '/etc/ansible/facts.d/persistent_paths.fact'
owner: 'root'
group: 'root'
mode: '0644'
notify: [ 'Refresh host facts' ]
tags: [ 'meta::facts' ]
- name: Reload facts if they were modified
ansible.builtin.meta: 'flush_handlers'
# ]]]

View file

@ -0,0 +1,16 @@
{# Copyright (C) 2016-2017 Robin Schneider <ypid@riseup.net>
# Copyright (C) 2016-2017 DebOps <https://debops.org/>
# SPDX-License-Identifier: GPL-3.0-only
#}
{# Use the generic versions where possible. The role might support multiple persistent storage providers. #}
{{ ({
"enabled": persistent_paths__qubes_os_enabled | bool,
"write_to_storage_path": persistent_paths__qubes_os_enabled | bool,
"storage_path": persistent_paths__qubes_os_storage_path | string,
"default_persistent_paths": persistent_paths__qubes_os_default_persistent_paths,
"qubes_os_enabled": persistent_paths__qubes_os_enabled | bool,
"qubes_os_config_dir": persistent_paths__qubes_os_config_dir | string,
"qubes_os_storage_path": persistent_paths__qubes_os_storage_path | string,
"qubes_os_handler": persistent_paths__qubes_os_handler | string,
"qubes_os_default_persistent_paths": persistent_paths__qubes_os_default_persistent_paths,
}) | to_nice_json }}

View file

@ -0,0 +1,25 @@
{# Copyright (C) 2016-2017 Robin Schneider <ypid@riseup.net>
# Copyright (C) 2016-2017 DebOps <https://debops.org/>
# SPDX-License-Identifier: GPL-3.0-only
#}
# {{ ansible_managed }}
{% if item.value.by_role | d() %}
# Managed by role: {{ item.value.by_role }}
{% endif %}
{% set persistent_paths__tpl_paths = [] %}
{% for path in item.value.paths %}
{% set include_path = { "include": True } %}
{% for filter_out_path in persistent_paths__qubes_os_default_persistent_paths %}
{% if path.startswith(filter_out_path) %}
{% set _ = include_path.update({ "include": False }) %}
{% endif %}
{% endfor %}
{% if include_path.include | bool %}
{% set _ = persistent_paths__tpl_paths.append(path) %}
{% endif %}
{% endfor %}
binds+=( {{ persistent_paths__tpl_paths | map("regex_replace", "^", "'") | map("regex_replace", "$", "'") | sort | join(" ") }} )
{# Does not work yet:
binds+=( {{ item.value.paths | map("quote") | join(" ") }} )
#}