Installing the packages

We are going to create four lists of packages; these are in the roles/stack-install/defaults/main.yml file. As per the previous chapter, we first need to uninstall a preinstalled MariaDB package, so our first list includes packages to remove:

packages_remove:
- "mariadb-libs.x86_64"

Next up, we have the packages needed to allow Ansible to interact with services such as SELinux and MariaDB, as well as installing the Postfix package, which, we know from the last time, is removed:

system_packages:
- "postfix"
- "MySQL-python"
- "policycoreutils-python"

Then, we have all of the packages that make up our core software stack:

stack_packages:
- "nginx"
- "mariadb101u"
- "mariadb101u-server"
- "mariadb101u-config"
- "mariadb101u-common"
- "mariadb101u-libs"
- "php72u"
- "php72u-bcmath"
- "php72u-cli"
- "php72u-common"
- "php72u-dba"
- "php72u-fpm"
- "php72u-fpm-nginx"
- "php72u-gd"
- "php72u-intl"
- "php72u-json"
- "php72u-mbstring"
- "php72u-mysqlnd"
- "php72u-process"
- "php72u-snmp"
- "php72u-soap"
- "php72u-xml"
- "php72u-xmlrpc"

Finally, we have a few nice-to-haves:

extra_packages:
- "vim-enhanced"
- "git"
- "unzip"

The tasks to remove the packages and then install them should be placed in the roles/stack-install/tasks/main.yml file, starting with the task to remove the packages:

- name: remove the packages so that they can be replaced
yum:
name: "{{ item }}"
state: "absent"
with_items: "{{ packages_remove }}"

Then, we can install all of the packages in one go using the following task:

- name: install the stack packages
yum:
name: "{{ item }}"
state: "installed"
with_items: "{{ system_packages + stack_packages + extra_packages }}"

Notice how we are combining the three remaining lists of packages in a single variable. We are doing this so we do not have to repeat the yum task any more than we have to. It also allows us to override, say, just extra_packages elsewhere in the playbook and not have to repeat the entire list of required packages needed for other parts of the stack.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.8.247