cans.package-install
cans.package-install
Simple Ansible Role that installs a given list of Debian packages
(.deb).
The intent of this role is not to come with all the bells and whistles. It is more a minimalistic, but efficient and reusable, package installation method. It is basically a procedure that, when given a list of packages, installs them.
Requirements
This role has no particular pre-requisite. But is assumes the target server(s) use the Debian distribution or a derivative.
Role Variables
All variables in this role are namespaced using the pkginstall_ prefix.
This role also defines variables for its internal use. Those are prefixed
with _pkginstall_. You should not use those variables.
Input variables
For this roles to perform any task, you must define either or both of the
pkginstall_packages_absent and `pkginstall_packages_present variables.
pkginstall_packages: DEPRECATED Usepkginstall_package_presentinstead (default:[]);pkginstall_packages_present: a list of package names to ensure are installed on the target host(s) (default:[]);pkginstall_packages_absent: a list of package names to ensure are not installed on the target host(s) (default:[]);
Defaults
pkginstall_apt_package_list_cache_directory: path to the directory that stores available package lists and packages content lists. This variable is only required if you setpkginstall_cache_purgetotrue(see below). It is very unlikely you would ever need to change this. (default:"/var/lib/apt/lists")pkginstall_cache_ttl: package cache validity duration, in seconds (default: 3600)pkginstall_cache_update: whether to update the package cache or not before installing packages (default:true)pkginstall_purge: when removing packages, also remove their configuration files (default:true);pkginstall_recommended: whether to install recommended packages alongside the packages explicitly listed for installation (default:false).pkginstall_update_cache: DEPRECATED usepkginstall_cache_updateinstead (default:true)
Dependencies
This role has no formal dependencies. But it requires from you to
override the pkginstall_packages variable to actually perform
anything (cf. example playbook below).
You may also be interested in using the cans.package-source role in
conjunction with this one, to add extra package repositories to those
already known by APT.
Example Playbooks
Assume you have two roles, first_role and second_roles, each of
which defines a variable that contains a list of packages to install,
let say first_role_packages and second_role_packages, respectively.
You can then, to use this role, start by assigning the
pkg_install_packages variable with the concatenation of both list.
Then just call the role.
- hosts: servers
vars:
pkginstall_packages: "{{ first_role_packages + second_role_packages }}"
roles:
- role: cans.package-install
- role: first_role
- role: second_role
If for some reason you cannot install all the packages at once (e.g.
because first_role installs or configures somethings required before being
able to install the packages required by second_role:
- hosts: servers
roles:
- role: cans.package-install
pkginstall_packages: "{{ first_role_packages }}"
- role: first_role
- role: cans.package-install
pkginstall_packages: "{{ second_role_packages }}"
- role: second_role
The above examples assume Ansible connects to the target servers with an
identity that has sufficient privileges to install packages. If not you
may need to use either or both of the remote_user and become keywords:
- hosts: servers
remote_user: "privileged-user"
vars:
pkginstall_packages: "{{ first_role_packages + second_role_packages }}"
roles:
- role: cans.package-install
become: yes
- role: first_role
- role: second_role
License
GPLv2
Author Information
Copyright © 2017-2018, Nicolas CANIART.
Simple Ansible Role that installs a given list of Debian packages (`.deb`).
ansible-galaxy install cans.package-install