Starting on the host workstation.example.com, let’s ssh over to node1.example.com. No password should be required.
ssh node1.example.com
Verify that you are on the right host for these exercises.
cheat-appstream-checkhost.sh
Determine what modules are available.
yum module list | grep postgresql
We see that we have:
postgresql 10 [d] client, server [d] PostgreSQL server and client module
postgresql 9.6 client, server [d] PostgreSQL server and client module
This means that I can pick either the postgresql 10 stream (the default) or the 9.6 stream. This enables me to use whichever postgresql best fits my needs. In the future as new postgresql versions come out, they can be added as different streams that I can change to as well. Switching streams is not supported. App Stream allows us to be more in control with userspace than any previous version of RHEL.
On your new RHEL 8 system, if you do:
yum install -y postgresql-server
you will get:
...<SNIP>...
Installing : postgresql-server-10.6-1.module+el8+2469+5ecd5aae.x86_64 3/3
Running scriptlet: postgresql-server-10.6-1.module+el8+2469+5ecd5aae.x86_64 3/3
Verifying : libpq-10.5-1.el8.x86_64 1/3
Verifying : postgresql-10.6-1.module+el8+2469+5ecd5aae.x86_64 2/3
Verifying : postgresql-server-10.6-1.module+el8+2469+5ecd5aae.x86_64 3/3
Installed:
postgresql-server-10.6-1.module+el8+2469+5ecd5aae.x86_64 libpq-10.5-1.el8.x86_64
postgresql-10.6-1.module+el8+2469+5ecd5aae.x86_64
Complete!
But let’s say that our application teams have a dependency on 9.6 but we want to move to RHEL 8. With the app stream, we can do this. Let’s do this next exercise on node3.example.com.
exit
Then:
ssh node3.example.com
On node3.example.com, let’s now run:
yum module install -y postgresql:9.6/server
The above command tells yum to install the server profile for postgresql in the 9.6 version.
Once we’ve installed that, we will see:
yum module list | grep postgresql
postgresql 10 [d] client, server [d] PostgreSQL server and client module
postgresql 9.6 [e] client, server [d] [i] PostgreSQL server and client module
The [e] by 9.6 means enabled. The [i] by server means installed. Anywhere that we see a [d] it represents the default on the operating system.
The server profile installs both the server and the client. If we just wanted the client, we could remove the server profile:
yum module remove -y postgresql:9.6/server
and install only the client:
yum module install -y postgresql:9.6/client
We would then see:
yum module list | grep postgresql
postgresql 10 [d] client, server [d] PostgreSQL server and client module
postgresql 9.6 [e] client [i], server [d] PostgreSQL server and client module
Another interesting feature of application streams is the ability to easily prevent packages from being installed. On node3.example.com, we just installed postgresql. We don’t want to have another database on the same machine and we see app stream profiles for mysql and mariadb. Let’s disable these:
yum module disable mariadb mysql -y
Now when we do yum module list, we will see:
yum module list | grep -e mariadb -e mysql
mariadb 10.3 [d][x] client, server [d], galera MariaDB Module
mysql 8.0 [d][x] client, server [d] MySQL Module
The [x] stands for disabled. When we run:
yum install mariadb -y
we get:
No match for argument: mariadb
Error: Unable to find a match
To re-enable these app streams and allow the packages to be installed, the command is:
yum module enable mariadb mysql -y
You may now switch back to the workstation:
exit
App Stream operations can be performed in ansible with the dnf module, like such:
- name: install the postgresql 9.6 stream with the client profile.
dnf:
name: '@postgresql:9.6/client'
state: present
On the workstation, as root, run:
cd ~/RHEL8-Workshop/config
ansible-playbook ../playbooks/appstream-pgsql.yml
then:
ansible rhel8 -o -a "rpm -q postgresql-server"
You should have postgresql-server 10.6 on node1 and 9.6 on node3 and no postgresql-server on node2.
and:
ansible rhel8 -o -a "rpm -q postgresql"
You should have postgresql 10.6 on nodes 1 and 2 and postgresql 9.6 on node3.
Red Hat Documentation