Skip to content

Commit

Permalink
doc: apt, yum: add example with package lists (ansible#38333)
Browse files Browse the repository at this point in the history
  • Loading branch information
resmo authored and mkrizek committed Apr 6, 2018
1 parent fa8b047 commit af35983
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
20 changes: 15 additions & 5 deletions lib/ansible/modules/packaging/os/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,23 +141,33 @@
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:
Expand Down
10 changes: 9 additions & 1 deletion lib/ansible/modules/packaging/os/yum.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
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).
Expand Down Expand Up @@ -180,6 +180,14 @@
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
Expand Down

0 comments on commit af35983

Please sign in to comment.