rcx_one.linkoverlay.linkoverlay (0.1.0) — module

Overlay a directory tree onto a base via symlinks

| "added in version" 0.1.0 of rcx_one.linkoverlay"

Authors: Eike (@E1k3)

Install collection

Install with ansible-galaxy collection install rcx_one.linkoverlay:==0.1.0


Add to requirements.yml

  collections:
    - name: rcx_one.linkoverlay
      version: 0.1.0

Description

This module creates and manages symlinks and directories to overlay one directory tree onto another.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Overlay dotfiles
  rcx_one.linkoverlay.linkoverlay:
    base_dir: /home/user/
    overlay_dir: /home/user/dotfiles
    backup_dir: /home/user/dotfile_backup
    conflict: replace

Inputs

    
base_dir:
    description:
    - The directory on the managed node where the overlay will be applied.
    - All symlinks pointing into C(overlay_dir) will be created in this directory.
    required: true
    type: path

collapse:
    default: true
    description:
    - Whether non-conflicting directory trees will be collapsed into a single symlink.
    - If enabled, will create symlinks to whole subtrees of the C(overlay_dir) if they
      dont conflict with the C(base_dir).
    - If disabled, will only create missing directories and symlinks to leaves of the
      C(overlay_dir) tree in the C(base_dir).
    required: false
    type: bool

conflict:
    choices:
    - error
    - keep
    - replace
    default: error
    description:
    - 'How files existing in both the C(base_dir) tree and the C(overlay_dir) tree will
      be handled:'
    - 'C(error): Will fail on conflict.'
    - 'C(keep): Will ignore overlay files and keep the base files.'
    - 'C(replace): Will replace original file with symlink to overlay.'
    - Symlinks pointing into C(overlay_dir) will always be replaced.
    required: false
    type: str

backup_dir:
    default: ''
    description:
    - Conflicting files will be backed up to this directory.
    - If conflict is not set to C(replace), this has no effect.
    - If not set, no backups will be made.
    - This path will be postfixed with the current timestamp to avoid overwriting existing
      backups.
    required: false
    type: path

overlay_dir:
    description:
    - The directory on the managed node where the overlay files reside.
    - All created symlinks will point into this directory.
    required: true
    type: path

warn_conflict:
    default: true
    description: Whether found conflicts will result in a warning.
    required: false
    type: bool

relative_links:
    default: true
    description: Whether relative or absolute symlinks will be created.
    required: false
    type: bool

Outputs

backed_up:
  description: Paths to backups of replaced files.
  returned: if backup_dir is specified
  sample:
  - /home/user/dotfile_backup/2022-10-15_00-25-21/.gitconfig
  - /home/user/dotfile_backup/2022-10-15_00-25-21/.config/alacritty.yml
  type: list
changed_stats:
  description: Paths that had their mode or owner changed.
  returned: always
  sample:
  - /home/user/.gitconfig
  type: list
created_links:
  description: Paths to newly created symlinks in the base directory.
  returned: always
  sample:
  - /home/user/.bashrc
  - /home/user/.gitconfig
  - /home/user/.config/alacritty.yml
  type: list
removed_trees:
  description: Root paths of removed directory trees and files.
  returned: always
  sample:
  - /home/user/.gitconfig
  - /home/user/.config/alacritty.yml
  type: list