diff options
author | René Moser <mail@renemoser.net> | 2018-04-06 10:58:51 +0200 |
---|---|---|
committer | Martin Krizek <martin.krizek@gmail.com> | 2018-04-06 10:58:51 +0200 |
commit | af3598343df28d4ce8b6ff647c4f64e6298b22de (patch) | |
tree | a1536d5b82e4d41e7c7a81555d0c57de1454ff54 | |
parent | fa8b0470390c2e2195c7104c3980737b719daee6 (diff) | |
download | ansible-af3598343df28d4ce8b6ff647c4f64e6298b22de.tar.gz |
doc: apt, yum: add example with package lists (#38333)
-rw-r--r-- | lib/ansible/modules/packaging/os/apt.py | 20 | ||||
-rw-r--r-- | lib/ansible/modules/packaging/os/yum.py | 10 |
2 files changed, 24 insertions, 6 deletions
diff --git a/lib/ansible/modules/packaging/os/apt.py b/lib/ansible/modules/packaging/os/apt.py index cabe2777d8..ec7edda796 100644 --- a/lib/ansible/modules/packaging/os/apt.py +++ b/lib/ansible/modules/packaging/os/apt.py @@ -141,23 +141,33 @@ EXAMPLES = ''' name: foo update_cache: yes -- name: Install apache service but avoid starting it immediately - apt: name=apache2 state=present +- name: Install apache httpd but avoid starting it immediately (state=present is optional) + apt: + name: apache2 + state: present environment: RUNLEVEL: 1 - name: Remove "foo" package - apt: name=foo state=absent + apt: + name: foo + state: absent - name: Install the package "foo" apt: name: foo - state: present + +- name: Install a list of packages + apt: + name: "{{ packages }}" + vars: + packages: + - foo + - foo-tools - name: Install the version '1.00' of package "foo" apt: name: foo=1.00 - state: present - name: Update the repository cache and update package "nginx" to latest version using default release squeeze-backport apt: diff --git a/lib/ansible/modules/packaging/os/yum.py b/lib/ansible/modules/packaging/os/yum.py index 814595061f..9c1f3602a6 100644 --- a/lib/ansible/modules/packaging/os/yum.py +++ b/lib/ansible/modules/packaging/os/yum.py @@ -25,7 +25,7 @@ description: options: name: description: - - A package name , or package specifier with version, like C(name-1.0). + - A package name or package specifier with version, like C(name-1.0). - If a previous version is specified, the task also needs to turn C(allow_downgrade) on. See the C(allow_downgrade) documentation for caveats with downgrading packages. - When using state=latest, this can be '*' which means run C(yum -y update). @@ -180,6 +180,14 @@ EXAMPLES = ''' name: httpd state: latest +- name: ensure a list of packages installed + yum: + name: "{{ packages }}" + vars: + packages: + - httpd + - httpd-tools + - name: remove the Apache package yum: name: httpd |