Vendor Galaxy Roles and Collections
This commit is contained in:
parent
c1e1897cda
commit
2aed20393f
3553 changed files with 387444 additions and 2 deletions
17
ansible_collections/debops/debops/roles/resources/COPYRIGHT
Normal file
17
ansible_collections/debops/debops/roles/resources/COPYRIGHT
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
debops.resources - Manage custom file resources through Ansible inventory
|
||||
|
||||
Copyright (C) 2016-2019 Maciej Delmanowski <drybjed@gmail.com>
|
||||
Copyright (C) 2016-2019 DebOps <https://debops.org/>
|
||||
SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program. If not, see https://www.gnu.org/licenses/
|
||||
|
|
@ -0,0 +1,440 @@
|
|||
---
|
||||
# .. vim: foldmarker=[[[,]]]:foldmethod=marker
|
||||
|
||||
# .. Copyright (C) 2016-2019 Maciej Delmanowski <drybjed@gmail.com>
|
||||
# .. Copyright (C) 2016-2019 DebOps <https://debops.org/>
|
||||
# .. SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
# .. _resources__ref_defaults:
|
||||
|
||||
# debops.resources default variables [[[
|
||||
# ======================================
|
||||
|
||||
# .. contents:: Sections
|
||||
# :local:
|
||||
#
|
||||
# .. include:: ../../../../includes/global.rst
|
||||
|
||||
|
||||
# Role configuration [[[
|
||||
# ----------------------
|
||||
|
||||
# .. envvar:: resources__enabled [[[
|
||||
#
|
||||
# Enable or disable management of custom resources.
|
||||
resources__enabled: True
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__src [[[
|
||||
#
|
||||
# Absolute path to the directory on Ansible Controller where custom resources
|
||||
# can be found. You need to create this directory manually.
|
||||
#
|
||||
# By default, path is relative to the Ansible inventory.
|
||||
resources__src: '{{ inventory_dir | realpath + "/../resources/" }}'
|
||||
# ]]]
|
||||
# .. envvar:: resources__time_format [[[
|
||||
#
|
||||
# Time format to be used for the `Ansible ansible.builtin.file module`_.
|
||||
# This is used for example when the ``access_time`` is specified.
|
||||
# It is set here to `ISO 8601`_ because the Ansible
|
||||
# default format is hardly human readable
|
||||
# (without separators like ``-`` and ``:``).
|
||||
# Example: ``2023-05-23T23:42:42``
|
||||
resources__time_format: '%Y-%m-%dT%H:%M:%S'
|
||||
# ]]]
|
||||
# ]]]
|
||||
# Manage parent directories [[[
|
||||
# -----------------------------
|
||||
|
||||
# This section allows to configure the behavior for non existing parent
|
||||
# directories for destination file paths.
|
||||
#
|
||||
# This applies to the following sections:
|
||||
#
|
||||
# - `Manage custom remote resources`_
|
||||
# - `Manage custom archives`_
|
||||
# - `Manage custom files`_
|
||||
#
|
||||
|
||||
# .. envvar:: resources__parent_dirs_create [[[
|
||||
#
|
||||
# Should the parent directories be created by the role? Not creating it will
|
||||
# cause an Ansible run time error when the directory does not exist.
|
||||
# The global setting can be overwritten for individual items using
|
||||
# ``item.parent_dirs_create``.
|
||||
resources__parent_dirs_create: True
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__parent_dirs_recurse [[[
|
||||
#
|
||||
# Recursively set the specified file attributes of parent directories when
|
||||
# creating them.
|
||||
# The global setting can be overwritten for individual items using
|
||||
# ``item.parent_dirs_recurse``.
|
||||
resources__parent_dirs_recurse: True
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__parent_dirs_owner [[[
|
||||
#
|
||||
# Unix system user who owns the parent directory.
|
||||
# See also :envvar:`resources__parent_dirs_recurse`.
|
||||
# The global setting can be overwritten for individual items using
|
||||
# ``item.parent_dirs_owner``.
|
||||
resources__parent_dirs_owner: '{{ omit }}'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__parent_dirs_group [[[
|
||||
#
|
||||
# Unix system group of the parent directory.
|
||||
# See also :envvar:`resources__parent_dirs_recurse`.
|
||||
# The global setting can be overwritten for individual items using
|
||||
# ``item.parent_dirs_group``.
|
||||
resources__parent_dirs_group: '{{ omit }}'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__parent_dirs_mode [[[
|
||||
#
|
||||
# Unix permissions of the parent directory.
|
||||
# See also :envvar:`resources__parent_dirs_recurse`.
|
||||
# The global setting can be overwritten for individual items using
|
||||
# ``item.parent_dirs_mode``.
|
||||
resources__parent_dirs_mode: '{{ omit }}'
|
||||
# ]]]
|
||||
# ]]]
|
||||
# Manage custom templates [[[
|
||||
# ---------------------------
|
||||
|
||||
# These variables define how the role will manage custom templates on remote
|
||||
# hosts. See :ref:`resources__ref_templates` for more details.
|
||||
|
||||
# .. envvar:: resources__templates [[[
|
||||
#
|
||||
# Directory which contains templates that should be generated on all hosts in
|
||||
# the Ansible inventory.
|
||||
resources__templates: [ '{{ resources__src + "templates/by-group/all" }}' ]
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__group_templates [[[
|
||||
#
|
||||
# List of paths containing the directories of all the groups the current host is in, based on the content of ``group_names``.
|
||||
# See `Ansible - Playbooks Variables <https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#accessing-information-about-other-hosts-with-magic-variables>`_.
|
||||
#
|
||||
# For example if the host ``debian1`` is member of ``group-name1`` and ``group-name2``
|
||||
# `debops.resources` will then search all template files inside the directories placed here: :file:`ansible/resources/templates/by-group/`.
|
||||
# Resulting in: ``[ "ansible/resources/templates/by-group/group-name1", "ansible/resources/templates/by-group/group-name2" ]``.
|
||||
#
|
||||
# Read the documentation about :ref:`resources__ref_templates` for more details on templating with `debops.resources`.
|
||||
resources__group_templates: '{{ group_names | map("regex_replace", "^(.*)$", resources__src + "templates/by-group/\1") | list }}'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__host_templates [[[
|
||||
#
|
||||
# Directory which contains templates that should be generated on specific hosts
|
||||
# in the Ansible inventory.
|
||||
resources__host_templates: [ '{{ resources__src + "templates/by-host/" + inventory_hostname }}' ]
|
||||
# ]]]
|
||||
# ]]]
|
||||
# Manage custom paths [[[
|
||||
# -----------------------
|
||||
|
||||
# These lists allow you to manage file and directory paths on remote hosts
|
||||
# using `Ansible ansible.builtin.file module`_. By default role treats specified
|
||||
# paths as directory names which should be present on the remote host. You can
|
||||
# use all parameters supported by the `Ansible ansible.builtin.file module`_.
|
||||
#
|
||||
# See :ref:`resources__ref_paths` for more details.
|
||||
|
||||
# .. envvar:: resources__paths [[[
|
||||
#
|
||||
# Paths managed on all hosts in Ansible inventory.
|
||||
resources__paths: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__group_paths [[[
|
||||
#
|
||||
# Paths managed on hosts in a specific group in Ansible inventory.
|
||||
resources__group_paths: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__host_paths [[[
|
||||
#
|
||||
# Paths managed on specific hosts in Ansible inventory.
|
||||
resources__host_paths: []
|
||||
# ]]]
|
||||
# ]]]
|
||||
# Manage git repositories [[[
|
||||
# ---------------------------
|
||||
|
||||
# These lists allow you to manage :command:`git` repositories on remote hosts
|
||||
# using the `Ansible ansible.builtin.git module`_. See
|
||||
# :ref:`resources__ref_repositories` for more details.
|
||||
|
||||
# .. envvar:: resources__repositories [[[
|
||||
#
|
||||
# Manage :command:`git` repositories on all hosts in the Ansible inventory.
|
||||
resources__repositories: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__group_repositories [[[
|
||||
#
|
||||
# Manage :command:`git` repositories on hosts in a specific Ansible inventory
|
||||
# group.
|
||||
resources__group_repositories: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__host_repositories [[[
|
||||
#
|
||||
# Manage :command:`git` repositories on specific hosts in the Ansible
|
||||
# inventory.
|
||||
resources__host_repositories: []
|
||||
# ]]]
|
||||
# ]]]
|
||||
# Manage custom remote resources [[[
|
||||
# ----------------------------------
|
||||
|
||||
# These lists allow you to specify remote resources to download to the hosts
|
||||
# using the `Ansible ansible.builtin.get_url module`. You can download files
|
||||
# over HTTP, HTTPS, FTP and use all options supported by this module.
|
||||
#
|
||||
# See :ref:`resources__ref_urls` for more details.
|
||||
|
||||
# .. envvar:: resources__urls [[[
|
||||
#
|
||||
# Manage online resources on all hosts in Ansible inventory.
|
||||
resources__urls: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__group_urls [[[
|
||||
#
|
||||
# Manage online resources on hosts in a specific group in Ansible inventory.
|
||||
resources__group_urls: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__host_urls [[[
|
||||
#
|
||||
# Manage online resources on specific hosts in Ansible inventory.
|
||||
resources__host_urls: []
|
||||
# ]]]
|
||||
# ]]]
|
||||
# Manage custom archives [[[
|
||||
# --------------------------
|
||||
|
||||
# These lists allow you to unpack archives stored on Ansible Controller to
|
||||
# remote hosts using the `Ansible ansible.builtin.unarchive module`_. You can
|
||||
# use all of the parameters supported by this module.
|
||||
#
|
||||
# See :ref:`resources__ref_archives` for more details.
|
||||
|
||||
# .. envvar:: resources__archives [[[
|
||||
#
|
||||
# Manage archives on all hosts in Ansible inventory.
|
||||
resources__archives: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__group_archives [[[
|
||||
#
|
||||
# Manage archives on hosts in specific group in Ansible inventory.
|
||||
resources__group_archives: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__host_archives [[[
|
||||
#
|
||||
# Manage archives on specific hosts in Ansible inventory.
|
||||
resources__host_archives: []
|
||||
# ]]]
|
||||
# ]]]
|
||||
# Manage custom files [[[
|
||||
# -----------------------
|
||||
|
||||
# These lists allow you to manage file contents on remote hosts, either by
|
||||
# copying files from the Ansible Controller, or providing the contents directly in
|
||||
# Ansible inventory. You can use all parameters supported by the
|
||||
# `Ansible ansible.builtin.copy module`_.
|
||||
#
|
||||
# See :ref:`resources__ref_files` for more details.
|
||||
|
||||
# .. envvar:: resources__files [[[
|
||||
#
|
||||
# Manage file contents on all hosts in Ansible inventory.
|
||||
resources__files: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__group_files [[[
|
||||
#
|
||||
# Manage file contents on hosts in a specific group in Ansible inventory.
|
||||
resources__group_files: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__host_files [[[
|
||||
#
|
||||
# Manage file contents on specific hosts in Ansible inventory.
|
||||
resources__host_files: []
|
||||
# ]]]
|
||||
# ]]]
|
||||
# Manage pip and virtual environments [[[
|
||||
# ---------------------------------------
|
||||
|
||||
# These lists allow you to manage Python library dependencies. See
|
||||
# :ref:`resources__ref_pip` documentation for more details.
|
||||
|
||||
# .. envvar:: resources__pip [[[
|
||||
#
|
||||
# Manage Python library dependencies on all hosts in Ansible inventory.
|
||||
resources__pip: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__group_pip [[[
|
||||
#
|
||||
# Manage Python library dependencies on hosts in a specific group in Ansible inventory.
|
||||
resources__group_pip: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__host_pip [[[
|
||||
#
|
||||
# Manage Python library dependencies on specific hosts in Ansible inventory.
|
||||
resources__host_pip: []
|
||||
# ]]]
|
||||
# ]]]
|
||||
# Manage file capabilities [[[
|
||||
# ----------------------------
|
||||
|
||||
# These lists allow you to manipulate file privileges using the Linux
|
||||
# :manpage:`capabilities(7)` system.
|
||||
# You can use all parameters supported by the
|
||||
# `Ansible community.general.capabilities module`_.
|
||||
#
|
||||
# See :ref:`resources__ref_capabilities` for more details.
|
||||
|
||||
# .. envvar:: resources__file_capabilities [[[
|
||||
#
|
||||
# Manage file capabilities on all hosts in Ansible inventory.
|
||||
resources__file_capabilities: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__group_file_capabilities [[[
|
||||
#
|
||||
# Manage file capabilities on hosts in a specific group in Ansible inventory.
|
||||
resources__group_file_capabilities: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__host_file_capabilities [[[
|
||||
#
|
||||
# Manage file capabilities on specific hosts in Ansible inventory.
|
||||
resources__host_file_capabilities: []
|
||||
# ]]]
|
||||
# .. envvar:: resources__combined_file_capabilities [[[
|
||||
#
|
||||
# Variable which combines all other file capabilities variables and is used in
|
||||
# the role tasks.
|
||||
resources__combined_file_capabilities: '{{ resources__file_capabilities
|
||||
+ resources__group_file_capabilities
|
||||
+ resources__host_file_capabilities }}'
|
||||
# ]]]
|
||||
# ]]]
|
||||
# Manage custom delayed paths [[[
|
||||
# -------------------------------
|
||||
|
||||
# These lists allow you to manage file and directory paths on remote hosts
|
||||
# using the `Ansible ansible.builtin.file module`_.
|
||||
# The lists can be used exactly the same as
|
||||
# :regexp:`resources__(?:group_|host_)?paths` from the `Manage custom paths`_ section.
|
||||
# The only difference is that the custom delayed paths are handled after all
|
||||
# non delayed resources.
|
||||
# This allows to create symbolic links to files provided by
|
||||
# :regexp:`resources__(?:group_|host_)?files` for example.
|
||||
#
|
||||
# See :ref:`resources__ref_paths` for more details.
|
||||
|
||||
# .. envvar:: resources__delayed_paths [[[
|
||||
#
|
||||
# Paths managed on all hosts in Ansible inventory.
|
||||
resources__delayed_paths: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__group_delayed_paths [[[
|
||||
#
|
||||
# Paths managed on hosts in a specific group in Ansible inventory.
|
||||
resources__group_delayed_paths: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__host_delayed_paths [[[
|
||||
#
|
||||
# Paths managed on specific hosts in Ansible inventory.
|
||||
resources__host_delayed_paths: []
|
||||
# ]]]
|
||||
# ]]]
|
||||
# Custom shell commands [[[
|
||||
# -------------------------
|
||||
|
||||
# The variables below let you define shell commands (or even small shell
|
||||
# scripts) to execute on the remote hosts as the ``root`` UNIX account. You
|
||||
# need to ensure idempotency by yourself. This is not a replacement for
|
||||
# a normal Ansible role.
|
||||
#
|
||||
# See :ref:`resources__ref_commands` for more details.
|
||||
|
||||
# .. envvar:: resources__commands [[[
|
||||
#
|
||||
# List of shell commands which should be executed on all hosts in the Ansible
|
||||
# inventory.
|
||||
resources__commands: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__group_commands [[[
|
||||
#
|
||||
# List of shell commands which should be executed on hosts in a specific
|
||||
# Ansible inventory group.
|
||||
resources__group_commands: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__host_commands [[[
|
||||
#
|
||||
# List of shell commands which should be executed on specific hosts in the
|
||||
# Ansible inventory.
|
||||
resources__host_commands: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__combined_commands [[[
|
||||
#
|
||||
# Variable which combines all other shell command variables and is used in the
|
||||
# role tasks.
|
||||
resources__combined_commands: '{{ resources__commands
|
||||
+ resources__group_commands
|
||||
+ resources__host_commands }}'
|
||||
# ]]]
|
||||
# String replacement management [[[
|
||||
# ---------------------------------
|
||||
|
||||
# The variables below let you define string replacement in files.
|
||||
|
||||
# .. envvar:: resources__replacements [[[
|
||||
#
|
||||
# List of replacements which should be executed on all hosts in the
|
||||
# Ansible inventory.
|
||||
resources__replacements: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__group_replacements [[[
|
||||
#
|
||||
# List of replacements which should be executed on hosts in a
|
||||
# specific Ansible inventory group.
|
||||
resources__group_replacements: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__host_replacements [[[
|
||||
#
|
||||
# List of replacements which should be executed on specific hosts
|
||||
# in the Ansible inventory.
|
||||
resources__host_replacements: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: resources__combined_replacements[[[
|
||||
#
|
||||
# Variable which combines all other line replacements variables and
|
||||
# is used in the role tasks.
|
||||
resources__combined_replacements: '{{ resources__replacements
|
||||
+ resources__group_replacements
|
||||
+ resources__host_replacements }}'
|
||||
# ]]]
|
||||
# ]]]
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
---
|
||||
# Copyright (C) 2016-2019 Maciej Delmanowski <drybjed@gmail.com>
|
||||
# Copyright (C) 2016-2019 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: 'Maciej Delmanowski'
|
||||
description: 'Manage custom file resources through Ansible inventory'
|
||||
company: 'DebOps'
|
||||
license: 'GPL-3.0-only'
|
||||
min_ansible_version: '2.0.0'
|
||||
|
||||
platforms:
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- all
|
||||
- name: GenericLinux
|
||||
versions:
|
||||
- all
|
||||
- name: Debian
|
||||
versions:
|
||||
- all
|
||||
|
||||
galaxy_tags:
|
||||
- files
|
||||
- directories
|
||||
- urls
|
||||
- paths
|
||||
- archives
|
||||
- repositories
|
||||
370
ansible_collections/debops/debops/roles/resources/tasks/main.yml
Normal file
370
ansible_collections/debops/debops/roles/resources/tasks/main.yml
Normal file
|
|
@ -0,0 +1,370 @@
|
|||
---
|
||||
# .. vim: foldmarker=[[[,]]]:foldmethod=marker
|
||||
|
||||
# Copyright (C) 2016-2019 Maciej Delmanowski <drybjed@gmail.com>
|
||||
# Copyright (C) 2016-2019 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
- name: Import custom Ansible plugins
|
||||
ansible.builtin.import_role:
|
||||
name: 'ansible_plugins'
|
||||
|
||||
- name: Import DebOps secret role
|
||||
ansible.builtin.import_role:
|
||||
name: 'secret'
|
||||
|
||||
# DebOps pre-hook [[[1
|
||||
- name: Pre hooks
|
||||
ansible.builtin.include_tasks: '{{ lookup("debops.debops.task_src", "resources/pre_main.yml") }}'
|
||||
|
||||
# Manage git repositories [[[1
|
||||
- name: Manage git repositories
|
||||
ansible.builtin.git:
|
||||
repo: '{{ item.repo | d(item.url | d(item.src)) }}'
|
||||
dest: '{{ item.dest | d(item.name | d(item.path)) }}'
|
||||
accept_hostkey: '{{ item.accept_hostkey | d(omit) }}'
|
||||
bare: '{{ item.bare | d(omit) }}'
|
||||
clone: '{{ item.clone | d(omit) }}'
|
||||
depth: '{{ item.depth | d(omit) }}'
|
||||
executable: '{{ item.executable | d(omit) }}'
|
||||
force: '{{ item.force | d(omit) }}'
|
||||
key_file: '{{ item.key_file | d(omit) }}'
|
||||
recursive: '{{ item.recursive | d(omit) }}'
|
||||
reference: '{{ item.reference | d(omit) }}'
|
||||
refspec: '{{ item.refspec | d(omit) }}'
|
||||
remote: '{{ item.remote | d(omit) }}'
|
||||
ssh_opts: '{{ item.ssh_opts | d(omit) }}'
|
||||
track_submodules: '{{ item.track_submodules | d(omit) }}'
|
||||
umask: '{{ item.umask | d(omit) }}'
|
||||
update: '{{ item["_update"] | d(omit) }}'
|
||||
verify_commit: '{{ item.verify_commit | d(omit) }}'
|
||||
version: '{{ item.version | d(omit) }}'
|
||||
become: True
|
||||
become_user: '{{ item.owner | d("root") }}'
|
||||
loop: '{{ q("flattened", resources__repositories
|
||||
+ resources__group_repositories
|
||||
+ resources__host_repositories) }}'
|
||||
when: (resources__enabled | bool and (item.repo | d() or item.url | d() or item.src | d()) and
|
||||
(item.dest | d() or item.name | d() or item.path | d()))
|
||||
tags: [ 'role::resources:repositories' ]
|
||||
|
||||
# Manage custom templates [[[1
|
||||
- name: Ensure that template directories exist
|
||||
ansible.builtin.file:
|
||||
path: '/{{ item.path }}'
|
||||
mode: '{{ item.mode }}'
|
||||
state: 'directory'
|
||||
with_community.general.filetree: '{{ (resources__host_templates
|
||||
+ resources__group_templates
|
||||
+ resources__templates) | flatten }}'
|
||||
when: item.state == 'directory'
|
||||
|
||||
- name: Generate custom templates
|
||||
ansible.builtin.template:
|
||||
src: '{{ item.src }}'
|
||||
dest: '/{{ item.path }}'
|
||||
mode: '{{ item.mode }}'
|
||||
with_community.general.filetree: '{{ (resources__host_templates
|
||||
+ resources__group_templates
|
||||
+ resources__templates) | flatten }}'
|
||||
when: item.state == 'file'
|
||||
|
||||
- name: Recreate custom symlinks
|
||||
ansible.builtin.file:
|
||||
src: '{{ item.src }}'
|
||||
dest: '/{{ item.path }}'
|
||||
mode: '{{ item.mode }}'
|
||||
state: 'link'
|
||||
force: True
|
||||
with_community.general.filetree: '{{ (resources__host_templates
|
||||
+ resources__group_templates
|
||||
+ resources__templates) | flatten }}'
|
||||
when: item.state == 'link'
|
||||
|
||||
# Manage custom paths [[[1
|
||||
- name: Manage paths on remote hosts
|
||||
ansible.builtin.file:
|
||||
path: '{{ (item.path | d(item.dest | d(item.name))) | d(item) }}'
|
||||
state: '{{ item.state | d("directory") }}'
|
||||
owner: '{{ item.owner | d(omit) }}'
|
||||
group: '{{ item.group | d(omit) }}'
|
||||
mode: '{{ item.mode | d(omit) }}'
|
||||
selevel: '{{ item.selevel | d(omit) }}'
|
||||
serole: '{{ item.serole | d(omit) }}'
|
||||
setype: '{{ item.setype | d(omit) }}'
|
||||
seuser: '{{ item.seuser | d(omit) }}'
|
||||
follow: '{{ item.follow | d(omit) }}'
|
||||
force: '{{ item.force | d(omit) }}'
|
||||
src: '{{ item.src | d(omit) }}'
|
||||
recurse: '{{ item.recurse | d(omit) }}'
|
||||
attributes: '{{ item.attributes | d(omit) }}'
|
||||
access_time: '{{ item.access_time | d(omit) }}'
|
||||
access_time_format: '{{ item.access_time_format | d(resources__time_format) }}'
|
||||
modification_time: '{{ item.modification_time | d(omit) }}'
|
||||
modification_time_format: '{{ item.modification_time_format | d(resources__time_format) }}'
|
||||
loop: '{{ q("flattened", resources__paths
|
||||
+ resources__group_paths
|
||||
+ resources__host_paths) }}'
|
||||
when: (resources__enabled | bool and
|
||||
((item.path | d() or item.dest | d() or item.name | d()) or item))
|
||||
tags: [ 'role::resources:paths' ]
|
||||
|
||||
# Create parent directories [[[1
|
||||
- name: Ensure that parent directories exist
|
||||
ansible.builtin.file:
|
||||
path: '{{ (item.dest | d(item.name | d(item.path))) | dirname }}'
|
||||
state: 'directory'
|
||||
recurse: '{{ item.parent_dirs_recurse | d(resources__parent_dirs_recurse) }}'
|
||||
owner: '{{ item.parent_dirs_owner | d(resources__parent_dirs_owner) }}'
|
||||
group: '{{ item.parent_dirs_group | d(resources__parent_dirs_group) }}'
|
||||
mode: '{{ item.parent_dirs_mode | d(resources__parent_dirs_mode) }}'
|
||||
when: (resources__enabled | bool and
|
||||
(item.parent_dirs_create | d(resources__parent_dirs_create) | bool) and
|
||||
item.state | d("present") != 'absent')
|
||||
loop: '{{ q("flattened", resources__urls
|
||||
+ resources__group_urls
|
||||
+ resources__host_urls
|
||||
+ resources__archives
|
||||
+ resources__group_archives
|
||||
+ resources__host_archives
|
||||
+ resources__files
|
||||
+ resources__group_files
|
||||
+ resources__host_files) }}'
|
||||
tags: [ 'role::resources:urls', 'role::resources:archives', 'role::resources:files' ]
|
||||
|
||||
# Manage custom remote resources [[[1
|
||||
- name: Download online resources to remote hosts
|
||||
ansible.builtin.get_url: # noqa args[module]
|
||||
url: '{{ item.url | d(item.src) }}'
|
||||
dest: '{{ item.dest | d(item.name | d(item.path)) }}'
|
||||
owner: '{{ item.owner | d(omit) }}'
|
||||
group: '{{ item.group | d(omit) }}'
|
||||
mode: '{{ item.mode | d(omit) }}'
|
||||
checksum: '{{ item.checksum | d(omit) }}'
|
||||
force: '{{ item.force | d(omit) }}'
|
||||
force_basic_auth: '{{ item.force_basic_auth | d(omit) }}'
|
||||
headers: '{{ item.headers | d(omit) }}'
|
||||
sha256sum: '{{ item.sha256sum | d(omit) }}'
|
||||
timeout: '{{ item.timeout | d(omit) }}'
|
||||
url_password: '{{ item.url_password | d(omit) }}'
|
||||
url_username: '{{ item.url_username | d(omit) }}'
|
||||
use_proxy: '{{ item.use_proxy | d(omit) }}'
|
||||
validate_certs: '{{ item.validate_certs | d(omit) }}'
|
||||
loop: '{{ q("flattened", resources__urls
|
||||
+ resources__group_urls
|
||||
+ resources__host_urls) }}'
|
||||
when: (resources__enabled | bool and (item.url | d() or item.src | d()) and
|
||||
(item.dest | d() or item.name | d() or item.path | d()))
|
||||
no_log: '{{ debops__no_log | d(True if item.url_password | d() else omit) }}'
|
||||
tags: [ 'role::resources:urls' ]
|
||||
|
||||
# Manage custom archives [[[1
|
||||
- name: Unpack archives to remote hosts
|
||||
ansible.builtin.unarchive:
|
||||
src: '{{ item.src }}'
|
||||
dest: '{{ item.dest | d(item.name | d(item.path)) }}'
|
||||
owner: '{{ item.owner | d(omit) }}'
|
||||
group: '{{ item.group | d(omit) }}'
|
||||
mode: '{{ item.mode | d(omit) }}'
|
||||
selevel: '{{ item.selevel | d(omit) }}'
|
||||
serole: '{{ item.serole | d(omit) }}'
|
||||
setype: '{{ item.setype | d(omit) }}'
|
||||
seuser: '{{ item.seuser | d(omit) }}'
|
||||
creates: '{{ item.creates | d(omit) }}'
|
||||
exclude: '{{ item.exclude | d(omit) }}'
|
||||
keep_newer: '{{ item.keep_newer | d(omit) }}'
|
||||
extra_opts: '{{ item.extra_opts | d(omit) }}'
|
||||
attributes: '{{ item.attributes | d(omit) }}'
|
||||
list_files: '{{ item.list_files | d(omit) }}'
|
||||
remote_src: '{{ item.remote_src | d(omit) }}'
|
||||
unsafe_writes: '{{ item.unsafe_writes | d(omit) }}'
|
||||
validate_certs: '{{ item.validate_certs | d(omit) }}'
|
||||
loop: '{{ q("flattened", resources__archives
|
||||
+ resources__group_archives
|
||||
+ resources__host_archives) }}'
|
||||
when: (resources__enabled | bool and item.src | d() and
|
||||
(item.dest | d() or item.name | d() or item.path | d()))
|
||||
tags: [ 'role::resources:archives' ]
|
||||
|
||||
# Manage custom files [[[1
|
||||
|
||||
- name: Delete files on remote hosts
|
||||
ansible.builtin.file:
|
||||
path: '{{ item.dest | d(item.path | d(item.name)) }}'
|
||||
state: 'absent'
|
||||
loop: '{{ q("flattened", resources__files
|
||||
+ resources__group_files
|
||||
+ resources__host_files) }}'
|
||||
when: (resources__enabled | bool and
|
||||
(item.dest | d() or item.path | d() or item.name | d()) and
|
||||
(item.state | d('present') == 'absent'))
|
||||
tags: [ 'role::resources:files' ]
|
||||
|
||||
- name: Copy files to remote hosts
|
||||
ansible.builtin.copy:
|
||||
dest: '{{ item.dest | d(item.path | d(item.name)) }}'
|
||||
src: '{{ item.src | d(omit) }}'
|
||||
content: '{{ item.content | d(omit) }}'
|
||||
owner: '{{ item.owner | d(omit) }}'
|
||||
group: '{{ item.group | d(omit) }}'
|
||||
mode: '{{ item.mode | d(omit) }}'
|
||||
selevel: '{{ item.selevel | d(omit) }}'
|
||||
serole: '{{ item.serole | d(omit) }}'
|
||||
setype: '{{ item.setype | d(omit) }}'
|
||||
seuser: '{{ item.seuser | d(omit) }}'
|
||||
follow: '{{ item.follow | d(omit) }}'
|
||||
force: '{{ item.force | d(omit) }}'
|
||||
backup: '{{ item.backup | d(omit) }}'
|
||||
validate: '{{ item.validate | d(omit) }}'
|
||||
remote_src: '{{ item.remote_src | d(omit) }}'
|
||||
directory_mode: '{{ item.directory_mode | d(omit) }}'
|
||||
loop: '{{ q("flattened", resources__files
|
||||
+ resources__group_files
|
||||
+ resources__host_files) }}'
|
||||
when: (resources__enabled | bool and
|
||||
(item.src | d() or item.content is defined) and
|
||||
(item.dest | d() or item.path | d() or item.name | d()) and
|
||||
(item.state | d('present') != 'absent'))
|
||||
tags: [ 'role::resources:files' ]
|
||||
|
||||
- name: Manage virtual environments
|
||||
ansible.builtin.pip:
|
||||
chdir: '{{ item.chdir | d(omit) }}'
|
||||
editable: '{{ item.editable | d(omit) }}'
|
||||
executable: '{{ item.executable | d(omit) }}'
|
||||
extra_args: '{{ item.extra_args | d(omit) }}'
|
||||
name: '{{ item.name | d(omit) }}'
|
||||
requirements: '{{ item.requirements | d(omit) }}'
|
||||
state: '{{ item.state | d(omit) }}'
|
||||
umask: '{{ item.umask | d(omit) }}'
|
||||
version: '{{ item.version | d(omit) }}'
|
||||
virtualenv: '{{ item.virtualenv | d(omit) }}'
|
||||
virtualenv_command: '{{ item.virtualenv_command | d(omit) }}'
|
||||
virtualenv_python: '{{ item.virtualenv_python | d(omit) }}'
|
||||
virtualenv_site_packages: '{{ item.virtualenv_site_packages | d(omit) }}'
|
||||
loop: '{{ q("flattened", resources__pip
|
||||
+ resources__group_pip
|
||||
+ resources__host_pip) }}'
|
||||
become: True
|
||||
become_user: '{{ item.owner | d("root") }}'
|
||||
when: (resources__enabled | bool and
|
||||
(item.name | d() or item.requirements is defined) and
|
||||
(item.state | d('present') != 'absent'))
|
||||
tags: [ 'role::resources:pip' ]
|
||||
|
||||
- name: Manage replacements inside files
|
||||
ansible.builtin.replace:
|
||||
dest: '{{ item.dest | d(item.name | d(item.path)) }}'
|
||||
after: '{{ item.after | d(omit) }}'
|
||||
attributes: '{{ item.attributes | d(item.attr | d(omit)) }}'
|
||||
backup: '{{ item.backup | d(omit) }}'
|
||||
before: '{{ item.before | d(omit) }}'
|
||||
encoding: '{{ item.encoding | d(omit) }}'
|
||||
group: '{{ item.group | d(omit) }}'
|
||||
mode: '{{ item.mode | d(omit) }}'
|
||||
others: '{{ item.others | d(omit) }}'
|
||||
owner: '{{ item.owner | d(omit) }}'
|
||||
regexp: '{{ item.regexp | d(omit) }}'
|
||||
replace: '{{ item.replace | d(omit) }}'
|
||||
selevel: '{{ item.selevel | d(omit) }}'
|
||||
serole: '{{ item.serole | d(omit) }}'
|
||||
setype: '{{ item.setype | d(omit) }}'
|
||||
seuser: '{{ item.seuser | d(omit) }}'
|
||||
unsafe_writes: '{{ item.unsafe_writes | d(omit) }}'
|
||||
validate: '{{ item.validate | d(omit) }}'
|
||||
loop: '{{ q("flattened", resources__replacements
|
||||
+ resources__group_replacements
|
||||
+ resources__host_replacements) }}'
|
||||
when: (resources__enabled | bool and item.regexp | d() and
|
||||
(item.dest | d() or item.path | d() or item.name | d()))
|
||||
tags: [ 'role::resources:lineinfile' ]
|
||||
|
||||
# Manage ACLs [[[1
|
||||
- name: Set ACLs on remote hosts
|
||||
ansible.posix.acl:
|
||||
path: '{{ item.1.path | d(item.0.name) | d(item.0.dest) | d(item.0.path) }}'
|
||||
default: '{{ item.1.default | d(omit) }}'
|
||||
entity: '{{ item.1.entity | d(omit) }}'
|
||||
entry: '{{ item.1.entry | d(omit) }}'
|
||||
etype: '{{ item.1.etype | d(omit) }}'
|
||||
permissions: '{{ item.1.permissions | d(omit) }}'
|
||||
follow: '{{ item.1.follow | d(omit) }}'
|
||||
recursive: '{{ item.1.recursive | d(omit) }}'
|
||||
state: '{{ item.1.state | d("present") }}'
|
||||
loop: '{{ (lookup("flattened",
|
||||
resources__paths
|
||||
+ resources__group_paths
|
||||
+ resources__host_paths
|
||||
+ resources__repositories
|
||||
+ resources__group_repositories
|
||||
+ resources__host_repositories
|
||||
+ resources__urls
|
||||
+ resources__group_urls
|
||||
+ resources__host_urls
|
||||
+ resources__archives
|
||||
+ resources__group_archives
|
||||
+ resources__host_archives
|
||||
+ resources__files
|
||||
+ resources__group_files
|
||||
+ resources__host_files,
|
||||
wantlist=True))
|
||||
| selectattr("acl", "defined") | list
|
||||
| subelements("acl") }}'
|
||||
loop_control:
|
||||
label: '{{ {"name": (item.0.name | d(item.0.dest) | d(item.0.path)),
|
||||
"acl": item.1} }}'
|
||||
when: item.0.state | d('present') != 'absent'
|
||||
tags: [ 'role::resources:acl' ]
|
||||
|
||||
# Manage custom delayed paths [[[1
|
||||
- name: Manage delayed paths on remote hosts
|
||||
ansible.builtin.file:
|
||||
path: '{{ (item.path | d(item.dest | d(item.name))) | d(item) }}'
|
||||
state: '{{ item.state | d("directory") }}'
|
||||
owner: '{{ item.owner | d(omit) }}'
|
||||
group: '{{ item.group | d(omit) }}'
|
||||
mode: '{{ item.mode | d(omit) }}'
|
||||
selevel: '{{ item.selevel | d(omit) }}'
|
||||
serole: '{{ item.serole | d(omit) }}'
|
||||
setype: '{{ item.setype | d(omit) }}'
|
||||
seuser: '{{ item.seuser | d(omit) }}'
|
||||
follow: '{{ item.follow | d(omit) }}'
|
||||
force: '{{ item.force | d(omit) }}'
|
||||
src: '{{ item.src | d(omit) }}'
|
||||
recurse: '{{ item.recurse | d(omit) }}'
|
||||
attributes: '{{ item.attributes | d(omit) }}'
|
||||
access_time: '{{ item.access_time | d(omit) }}'
|
||||
access_time_format: '{{ item.access_time_format | d(resources__time_format) }}'
|
||||
modification_time: '{{ item.modification_time | d(omit) }}'
|
||||
modification_time_format: '{{ item.modification_time_format | d(resources__time_format) }}'
|
||||
loop: '{{ q("flattened", resources__delayed_paths
|
||||
+ resources__group_delayed_paths
|
||||
+ resources__host_delayed_paths) }}'
|
||||
when: (resources__enabled | bool and
|
||||
((item.path | d() or item.dest | d() or item.name | d()) or item))
|
||||
tags: [ 'role::resources:paths' ]
|
||||
|
||||
- name: Set custom file capabilities
|
||||
community.general.capabilities:
|
||||
path: '{{ item.path | d(item.name) }}'
|
||||
capability: '{{ item.capability }}'
|
||||
state: '{{ item.state | d("present") }}'
|
||||
loop: '{{ q("flattened", resources__combined_file_capabilities) }}'
|
||||
when: resources__enabled | bool
|
||||
tags: [ 'role::resources:capabilities' ]
|
||||
|
||||
# Execute custom shell commands [[[1
|
||||
# This is not an alternative to a fully-fledged Ansible role.
|
||||
- name: Execute shell commands
|
||||
ansible.builtin.include_tasks: 'shell_commands.yml'
|
||||
loop: '{{ q("flattened", resources__combined_commands) | debops.debops.parse_kv_items }}'
|
||||
loop_control:
|
||||
label: '{{ {"name": item.name} }}'
|
||||
when: resources__enabled | bool and
|
||||
item.name | d() and item.state | d('present') not in [ 'absent', 'ignore' ]
|
||||
no_log: '{{ debops__no_log | d(item.no_log) | d(False) }}'
|
||||
tags: [ 'role::resources:commands' ]
|
||||
|
||||
# DebOps post-hook [[[1
|
||||
- name: Post hooks
|
||||
ansible.builtin.include_tasks: '{{ lookup("debops.debops.task_src", "resources/post_main.yml") }}'
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
# Copyright (C) 2016-2019 Maciej Delmanowski <drybjed@gmail.com>
|
||||
# Copyright (C) 2016-2019 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
# Copyright (C) 2016-2019 Maciej Delmanowski <drybjed@gmail.com>
|
||||
# Copyright (C) 2016-2019 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
# Copyright (C) 2016-2019 Maciej Delmanowski <drybjed@gmail.com>
|
||||
# Copyright (C) 2016-2019 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
- name: '{{ item.name }}' # noqa name[casing]
|
||||
ansible.builtin.shell: '{{ item.script | d(item.shell | d(item.command)) }}' # noqa command-instead-of-shell
|
||||
args:
|
||||
chdir: '{{ item.chdir | d(omit) }}'
|
||||
creates: '{{ item.creates | d(omit) }}'
|
||||
removes: '{{ item.removes | d(omit) }}'
|
||||
executable: '{{ item.executable | d("bash") }}'
|
||||
when: item.name | d() and item.state not in ['absent', 'ignore']
|
||||
no_log: '{{ debops__no_log | d(item.no_log) | d(False) }}'
|
||||
tags: [ 'role::resources:commands' ]
|
||||
Loading…
Reference in a new issue