| 1 |
# -*- coding: utf-8 -*- |
| 2 |
|
| 3 |
# (c) 2015, Ansible Project |
| 4 |
# |
| 5 |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 6 |
|
| 7 |
from __future__ import annotations |
| 8 |
|
| 9 |
|
| 10 |
DOCUMENTATION = """ |
| 11 |
--- |
| 12 |
module: package |
| 13 |
version_added: 2.0 |
| 14 |
author: |
| 15 |
- Ansible Core Team |
| 16 |
short_description: Generic OS package manager |
| 17 |
description: |
| 18 |
- This modules manages packages on a target without specifying a package manager module (like M(ansible.builtin.dnf), M(ansible.builtin.apt), ...). |
| 19 |
It is convenient to use in an heterogeneous environment of machines without having to create a specific task for |
| 20 |
each package manager. M(ansible.builtin.package) calls behind the module for the package manager used by the operating system |
| 21 |
discovered by the module M(ansible.builtin.setup). If M(ansible.builtin.setup) was not yet run, M(ansible.builtin.package) will run it. |
| 22 |
- This module acts as a proxy to the underlying package manager module. While all arguments will be passed to the |
| 23 |
underlying module, not all modules support the same arguments. This documentation only covers the minimum intersection |
| 24 |
of module arguments that all packaging modules support. |
| 25 |
- For Windows targets, use the M(ansible.windows.win_package) module instead. |
| 26 |
options: |
| 27 |
name: |
| 28 |
description: |
| 29 |
- Package name, or package specifier with version. |
| 30 |
- Syntax varies with package manager. For example V(name-1.0) or V(name=1.0). |
| 31 |
- Package names also vary with package manager; this module will not "translate" them per distribution. For example V(libyaml-dev), V(libyaml-devel). |
| 32 |
- To operate on several packages this can accept a comma separated string of packages or a list of packages, depending on the underlying package manager. |
| 33 |
required: true |
| 34 |
state: |
| 35 |
description: |
| 36 |
- Whether to install (V(present)), or remove (V(absent)) a package. |
| 37 |
- You can use other states like V(latest) ONLY if they are supported by the underlying package module(s) executed. |
| 38 |
required: true |
| 39 |
use: |
| 40 |
description: |
| 41 |
- The required package manager module to use (V(dnf), V(apt), and so on). The default V(auto) will use existing facts or try to auto-detect it. |
| 42 |
- You should only use this field if the automatic selection is not working for some reason. |
| 43 |
- Since version 2.17 you can use the C(ansible_package_use) variable to override the automatic detection, but this option still takes precedence. |
| 44 |
default: auto |
| 45 |
requirements: |
| 46 |
- Whatever is required for the package plugins specific for each system. |
| 47 |
extends_documentation_fragment: |
| 48 |
- action_common_attributes |
| 49 |
- action_common_attributes.flow |
| 50 |
attributes: |
| 51 |
action: |
| 52 |
support: full |
| 53 |
async: |
| 54 |
support: full |
| 55 |
bypass_host_loop: |
| 56 |
support: none |
| 57 |
check_mode: |
| 58 |
details: support depends on the underlying plugin invoked |
| 59 |
support: N/A |
| 60 |
diff_mode: |
| 61 |
details: support depends on the underlying plugin invoked |
| 62 |
support: N/A |
| 63 |
platform: |
| 64 |
details: The support depends on the availability for the specific plugin for each platform and if fact gathering is able to detect it |
| 65 |
platforms: all |
| 66 |
notes: |
| 67 |
- While M(ansible.builtin.package) abstracts package managers to ease dealing with multiple distributions, package name often differs for the same software. |
| 68 |
|
| 69 |
""" |
| 70 |
EXAMPLES = """ |
| 71 |
- name: Install ntpdate |
| 72 |
ansible.builtin.package: |
| 73 |
name: ntpdate |
| 74 |
state: present |
| 75 |
|
| 76 |
# This uses a variable as this changes per distribution. |
| 77 |
- name: Remove the apache package |
| 78 |
ansible.builtin.package: |
| 79 |
name: "{{ apache }}" |
| 80 |
state: absent |
| 81 |
|
| 82 |
- name: Install the latest version of Apache and MariaDB |
| 83 |
ansible.builtin.package: |
| 84 |
name: |
| 85 |
- httpd |
| 86 |
- mariadb-server |
| 87 |
state: latest |
| 88 |
|
| 89 |
- name: Use the dnf package manager to install httpd |
| 90 |
ansible.builtin.package: |
| 91 |
name: httpd |
| 92 |
state: present |
| 93 |
use: dnf |
| 94 |
""" |