Enabling the repositories

Let's start our playbook by enabling the three repositories we need in order to install our software stack and then, once those repositories are enabled, we should do a yum update to make sure that the base operating system is up to date.

The roles/stack-install/defaults/main.yml file requires the following content to achieve this. First, we have the locations for the RPM packages that enable EPEL and IUS:

repo_packages:
- "epel-release"
- "https://centos7.iuscommunity.org/ius-release.rpm"

After that, we have the following nested variable, which contains all of the information we need to use the yum_repository module in order to create a .repo file for the NGINX repository:

nginx_repo:
name: "nginx"
description: "The mainline NGINX repo"
baseurl: "http://nginx.org/packages/mainline/centos/7/$basearch/"
gpgcheck: "no"
enabled: "yes"

Now that we have the defaults in place, we can add the tasks to the roles/stack-install/tasks/main.yml file; these are as follows, with the first task being already familiar as all it does is install our two packages: 

- name: install the repo packages
yum:
name: "{{ item }}"
state: "installed"
with_items: "{{ repo_packages }}"

The next task creates a repository file called nginx.repo in /etc/yum.repos.d/:

- name: add the NGINX mainline repo
yum_repository:
name: "{{ nginx_repo.name }}"
description: "{{ nginx_repo.description }}"
baseurl: "{{ nginx_repo.baseurl }}"
gpgcheck: "{{ nginx_repo.gpgcheck }}"
enabled: "{{ nginx_repo.enabled }}"

As you can see from the following Terminal output, the content of the file is pointing toward the NGINX repository, and we can get more information on the NGINX package by running:

$ yum info nginx

The following screenshot shows the output for the preceding command:

The following task should also look familiar, as we used it in the previous chapter to update the installed packages:

- name: update all of the installed packages
yum:
name: "*"
state: "latest"
update_cache: "yes"

Now that we have our source repositories set up and the already installed packages updated, we can proceed with the remainder of the package installations.

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

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