Getting started

Example inventory

The debops.dpkg_cleanup role is not designed to be used directly. It should be imported into other Ansible roles with custom configuration for each (see below). Alternatively, it can be included in the playbooks of other Ansible roles.

Example playbook

The debops.dpkg_cleanup role does not have it's own playbook. The role is designed to be used by other Ansible roles via the import_role Ansible module, usually at the end of the task list of a given role.

In the defaults/main.yml file of the example application role, add:

  - name: 'application'
      - '/path/to/custom/file'
      - '/path/to/other/file'
      - 'other-service'

In the tasks/main.yml file of the application role, add:

- import_role:
    name: 'dpkg_cleanup'
      - '{{ application__dpkg_cleanup__dependent_packages }}'
  when: application__deploy_state != 'absent'
  tags: [ 'role::dpkg_cleanup', 'skip::dpkg_cleanup',
          'role::application:dpkg_cleanup' ]

This configuration will ensure that the users can modify the list of files or directories to manipulate through the Ansible inventory, if necessary.


Keep in mind that if the debops.dpkg_cleanup role is used via the import_role Ansible module in multiple roles, due to the behaviour of this Ansible module each such instance needs to have its own dpkg_cleanup__dependent_packages variable definition. Otherwise the last instance of the role preprocessed by Ansible will define this variable for each instance without it.