package - Generic OS package manager

New in version 2.0.

Synopsis

  • Installs, upgrade and removes packages using the underlying OS package manager.
  • For Windows targets, use the win_package module instead.

Requirements (on host that executes module)

  • Whatever is required for the package plugins specific for each system.

Options

parameter required default choices comments
name
yes
Package name, or package specifier with version, like name-1.0.
Be aware that packages are not always named the same and this module will not 'translate' them per distro.
state
yes
Whether to install (present, or remove (absent) a package. Other states depend on the underlying package module, i.e latest.
use
no auto
The required package manager module to use (yum, apt, etc). The default 'auto' will use existing facts or try to autodetect it.
You should only use this field if the automatic selection is not working for some reason.

Examples

- name: install ntpdate
  package:
    name: ntpdate
    state: present

# This uses a variable as this changes per distribution.
- name: remove the apache package
  package:
    name: "{{ apache }}"
    state: absent

Notes

Note

  • This module actually calls the pertinent package modules for each system (apt, yum, etc).
  • For Windows targets, use the win_package module instead.

Status

This module is flagged as stableinterface which means that the maintainers for this module guarantee that no backward incompatible interface changes will be made.

Maintenance Info

For more information about Red Hat’s this support of this module, please refer to this knowledge base article<https://access.redhat.com/articles/rhel-top-support-policies>

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.4/package_module.html