DEBOPS.DEBOPS_LEGACY(5)

NAME
debops.debops_legacy - Clean up legacy content using Ansible

SYNOPSIS

debops run service/debops_legacy [--limit group,host,...] [--diff] [--check] [--tags tag1,tag2,...] [--skip-tags tag1,tag2,...] [<ansible-playbook options>] ...

DESCRIPTION

The debops.debops_legacy Ansible role can be used to clean up legacy files, directories, APT packages or dpkg-divert diversions created by DebOps but no longer used.

The role is not included in the main DebOps playbook to not cause data destruction by mistake. You are advised to use it with caution - it will destroy data on your DebOps hosts. To check the changes that will be done before implementing them, you can run the role against DebOps hosts with:

debops run service/debops_legacy -l <host> --diff --check

Any changes that the role will create on the hosts can be overridden via the Ansible inventory if needed.

GETTING STARTED

  Example inventory

The debops.debops_legacy role doesn't need to be enabled in Ansible inventory, since its playbook by default works against the hosts in the [debops_all_hosts] Ansible inventory group. However the role is not included in the site.yml playbook and needs to be executed specifically by the system administrator to perform work.

  Example playbook

If you are using this role without DebOps, here's an example Ansible playbook that uses the debops.debops_legacy role:

---
- name: Clean up legacy configuration
  collections: [ 'debops.debops', 'debops.roles01',
                 'debops.roles02', 'debops.roles03' ]
  hosts: [ 'debops_all_hosts' ]
  become: True
  environment: '{{ inventory__environment | d({})
                   | combine(inventory__group_environment | d({}))
                   | combine(inventory__host_environment  | d({})) }}'
  roles:
    - role: debops_legacy
      tags: [ 'role::debops_legacy', 'skip::debops_legacy' ]

  Ansible tags

You can use Ansible --tags or --skip-tags parameters to limit what tasks are performed during Ansible run. This can be used after a host was first configured to speed up playbook execution, when you are sure that most of the configuration is already in the desired state.

Available role tags:

role::debops_legacy
    Main role tag, should be used in the playbook to execute all of the role tasks as well as role dependencies.

DEFAULT VARIABLE DETAILS

Some of debops.debops_legacy default variables have more extensive configuration than simple strings or lists, here you can find documentation and examples for them.

  debops_legacy__remove_diversions

The debops_legacy__remove_*_diversions variables define the dpkg-divert diversions that will be removed by the role. The existing files will be deleted and the original files diverted by DebOps will be moved back into place.

The variables are list with YAML dictionaries, each dictionary defines one file with specific parameters:

name
    Required. Absolute path of the file that will be reverted. This parameter is used as a key for merging different configuration entries together.

diversion
    Optional. Absolute path of the diverted file to revert into its original place. If not specified, the filename is defined as:

    {{ item.name }}.dpkg-divert

state
    Optional. If not specified or present, the existing diversion will be kept in place. If absent, the diversion will be removed.

    If ignore, a given configuration entry will not be evaluated by the role during execution, allowing conditional activation of the tasks.

  Examples

Remove existing diversion of a configuration file:

debops_legacy__remove_diversions:
  - name: '/etc/default/application'
    state: 'absent'

  debops_legacy__remove_packages

The debops_legacy__remove_*_packages variables define the APT packages which should be removed by the role. The variables are list of YAML entries, each entry defines one APT package to remove using specific parameters:

name
    Required. Name of the APT package to remove.

state
    Optional. If not specified or present, the existing APT package will be kept in place, or installed if it's not present. If absent, existing APT package will be removed.

    If ignore, a given configuration entry will not be evaluated by the role during execution, allowing conditional activation of the task.

  Examples

Remove existing package conditionally, else leave the existing state (installed/uninstalled) as is:

debops_legacy__remove_packages:
  - name: 'application'
    state: '{{ "absent"
               if (ansible_hostname == "example")
               else "ignore" }}'

  debops_legacy__remove_files

The debops_legacy__remove_*_files variables define the files or directories which should be removed by the role. The variables are list of YAML entries, each entry defines one file or directory to remove using specific parameters:

name
    Required. Absolute path of the file or directory to remove.

state
    Optional. If not specified or present, the existing file will be left in place. Non-existent files or directories will result in an error. If absent, existing file or directory will be removed.

    If ignore, a given configuration entry will not be evaluated by the role during execution, allowing conditional activation of the task.

  Examples

Remove existing file conditionally based on Ansible facts:

debops_legacy__remove_files:
  - name: '/etc/default/application'
    state: '{{ "absent"
               if (ansible_hostname == "example")
               else "ignore" }}'

AUTHOR
Maciej Delmanowski

COPYRIGHT
2014-2024, Maciej Delmanowski, Nick Janetakis, Robin Schneider and others