Skip to content

Latest commit

 

History

History
270 lines (199 loc) · 6.16 KB

appstream-yum.adoc

File metadata and controls

270 lines (199 loc) · 6.16 KB

Application Streams

1. Choosing an appstream module on RHEL 8.

Starting on the host workstation.example.com, let’s ssh over to node1.example.com. No password should be required.

[root@workstation RHEL8-Workshop]#
ssh node1.example.com

Verify that you are on the right host for these exercises.

[root@node1 ~]#
cheat-appstream-checkhost.sh

Determine what modules are available.

[root@node1 ~]#
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:

[root@node1 ~]#
yum install -y postgresql-server

you will get:

Command Output
    ...<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.

[root@node1 ~]#
exit

Then:

[root@workstation RHEL8-Workshop]#
ssh node3.example.com

On node3.example.com, let’s now run:

[root@node3 ~]#
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:

[root@node3 ~]#
yum module list | grep postgresql
Command Output
    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:

[root@node3 ~]#
yum module remove -y postgresql:9.6/server

and install only the client:

[root@node3 ~]#
yum module install -y postgresql:9.6/client

We would then see:

[root@node3 ~]#
yum module list | grep postgresql
Command Output
    postgresql               10 [d]          client, server [d]                           PostgreSQL server and client module
    postgresql               9.6 [e]         client [i], server [d]                       PostgreSQL server and client module

2. Disabling application streams

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:

[root@node3 ~]#
yum module disable mariadb mysql -y

Now when we do yum module list, we will see:

[root@node3 ~]#
yum module list | grep -e mariadb -e mysql
Command Output
    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:

[root@node3 ~]#
yum install mariadb -y

we get:

Command Output
    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:

[root@node3 ~]#
yum module enable mariadb mysql -y

You may now switch back to the workstation:

[root@node3 ~]#
exit

3. Ansible automation with App Stream

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:

[root@workstation ~]#
cd ~/RHEL8-Workshop/config
[root@workstation config]#
ansible-playbook ../playbooks/appstream-pgsql.yml

then:

[root@workstation config]#
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:

[root@workstation config]#
ansible rhel8 -o -a "rpm -q postgresql"

You should have postgresql 10.6 on nodes 1 and 2 and postgresql 9.6 on node3.

4. Additional Resources