Pages

Tuesday, 3 December 2019

EX294: Software packages and repositories

0. Online Help

$ ansible-doc yum
$ ansible-doc packages
$ ansible-doc dnf

1. use "yum" OR "dnf" OR "package"  to manage packages

Different distributions have different package management systems. Debian/Ubuntu use apt, RHEL/CentOS use yum/dnf, ....

The "package" module is a high-level module that calls the low-level packaging app based on facts.
For EX294, the managed nodes are RHEL8, so "dnf" module is what we need in the exam.

Unfortunately, package names are not consistent across different packaging systems. e.g. Apache is called "httpd" in CentOS while it's named "apache" in Ubuntu. So the "packages" module is not as helpful as expected.

Here are some examples.

1.1 Ensure httpd is installed

$ ansible all --become -m yum -a "name=httpd state=present"

1.2 Ensure ntpd is not installed

$ ansible all --become -m yum -a "name=ntpd state=absent"

2. use "yum_repository" to manage repositories

The repository structure is different between RHEL8 and the old versions.
e.g.

yum_repository:
    name: epel
    description: EPEL YUM repo
    file: external_repos
    baseurl: https://download.fedoraproject.org/pub/epel/$releasever/$basearch/
    gpgcheck: no

3. Key Points

  • Package management requires "root" privilege, so "become" must be setup.
  • Getting familiar with the package names is important. 

No comments:

Post a Comment