Run a playbook that needs an Ansible Content Collection in a particular execution environment, and another playbook that needs an Ansible Content Collection that is not provided by an execution environment.
Outcomes
Identify Ansible Content Collections inside automation execution environment images.
Run a playbook that requires a collection from an automation execution environment.
Install a collection from automation hub.
Run a playbook that requires a collection from automation hub.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command creates the /home/student/manage-review/ directory on the workstation machine and obtains the files necessary to complete this lab.
[student@workstation ~]$ lab start manage-review
Procedure 2.4. Instructions
Change into the /home/student/manage-review/ directory and review the cockpit.yml playbook.
Make note of the Ansible Content Collections that the playbook requires.
Change into the /home/student/manage-review/ directory.
[student@workstation ~]$ cd ~/manage-review/Review the cockpit.yml playbook.
[student@workstation manage-review]$cat cockpit.yml--- - name: Deploy cockpit hosts: servera.lab.example.com become: true tasks: - name: Ensure cockpit is installed ansible.builtin.yum: name: cockpit state: present - name: Ensure the cockpit service is started and enabled ansible.builtin.systemd: name: cockpit state: started enabled: true - name: Ensure Cockpit network traffic is allowedansible.posix.firewalld: service: cockpit permanent: true state: enabled immediate: true
Notice that the ansible.posix.firewalld module requires the ansible.posix collection.
Use the ansible-navigator command to inspect the automation execution environment images available on your local system.
Determine which one you need to run the cockpit.yml playbook.
List the available automation execution environment images.
[student@workstation manage-review]$ansible-navigator imagesImage Tag Execution environment Created Size 0│ee-minimal-rhel8 latest True 3 months ago 294 MB1│ee-supported-rhel8latest True 3 months ago 1.68 GB
Type 1 to select the ee-supported-rhel8 image.
The TUI displays information about the ee-supported-rhel image.
Image: ee-supported-rhel8:latest Description
0│Image information Information collected from image inspection
1│General information OS and python version information
2│Ansible version and collections Information about ansible and ansible ...
3│Python packages Information about python and python packages
4│Operating system packages Information about operating system packages
5│Everything All image informationType 2 to view the collections available in the ee-supported-rhel8 image.
Notice that the ee-supported-rhel8 image provides the ansible.posix collection that you need to run the cockpit.yml playbook.
Image: ee-supported-rhel8:latest (Information about ansible and ansible collections)
0│---
1│ansible:
2│ collections:
3│ details:
4│ amazon.aws: 3.2.0
5│ ansible.controller: 4.2.1
6│ ansible.netcommon: 3.1.1
7│ ansible.network: 1.2.0
8│ ansible.posix: 1.3.0
9│ ansible.security: 1.0.0
10│ ansible.utils: 2.6.1
...output omitted...Type :q and then press Enter to exit the ansible-navigator command.
Run the cockpit.yml playbook by using the ansible-navigator command with the correct automation execution environment image.
Use the ansible-navigator run command with the ee-supported-rhel8 image to run the cockpit.yml playbook.
[student@workstation manage-review]$ansible-navigator run cockpit.yml \>--eei ee-supported-rhel8...output omitted...
Press Esc to exit the ansible-navigator command after the playbook run is complete.
Log in to the web console at https://servera.lab.example.com:9090 to confirm that the playbook correctly configured the web console.
Accept the insecure TLS certificate and then log in as the student user.
Use student as the password.
Open a web browser on the workstation machine and navigate to https://servera.lab.example.com:9090.
![]() |
Log in with student as the username and student as the password.
The playbook correctly configured the web console if the login process is successful.
![]() |
Review the create_samples_db.yml playbook.
Make note of the collections that it requires.
Find those collections in the private automation hub.
You can access the private automation hub web UI at https://hub.lab.example.com.
Use student as the username and redhat123 as the password.
Review the create_samples_db.yml playbook.
[student@workstation manage-review]$cat create_samples_db.yml--- - name: Create samples database hosts: serverb.lab.example.com become: true tasks: - name: Ensure MariaDB is installed ansible.builtin.yum: name: - mariadb - mariadb-server state: present - name: Ensure the mariadb service is started and enabled ansible.builtin.systemd: name: mariadb state: started enabled: true - name: Ensure the samples database existscommunity.mysql.mysql_db: name: samples state: present
Notice that the playbook requires the community.mysql collection.
Open a web browser and navigate to https://hub.lab.example.com.
Use student as the username and redhat123 as the password.
Navigate to → .
Change the selection to Community and search for mysql.
![]() |
Click the mysql collection to obtain the ansible-galaxy installation command.
![]() |
Configure the /home/student/manage-review/ansible.cfg file so that the ansible-galaxy command installs collections from private automation hub.
From the private automation hub web UI, navigate to → .
Use the section from the community repository to construct the /home/student/manage-review/ansible.cfg file.
![]() |
Add the repository configurations to the /home/student/manage-review/ansible.cfg file.
[defaults] inventory = ./inventory remote_user = devops[galaxy]server_list = community_repo[galaxy_server.community_repo]url=https://hub.lab.example.com/api/galaxy/content/community/token=<put your token here>
From the private automation hub web UI, navigate to → and then click . Click the icon.
![]() |
Edit the /home/student/manage-review/ansible.cfg file and then paste the token from the clipboard as the value for the token parameters.
Your token is different from the one displayed in the following example.
[defaults]
inventory = ./inventory
remote_user = devops
[galaxy]
server_list = community_repo
[galaxy_server.community_repo]
url=https://hub.lab.example.com/api/galaxy/content/community/
token=865d4517fe18135059d5c093321aac0959041720Create the /home/student/manage-review/collections/ directory.
In this directory, install any collections that the create_samples_db.yml playbook requires.
Create the /home/student/manage-review/collections/ directory.
[student@workstation manage-review]$ mkdir collectionsInstall the community.mysql collection into the /home/student/manage-review/collections/ directory.
[student@workstation manage-review]$ansible-galaxy collection install \>community.mysql -p collections/...output omitted...
Use the ansible-navigator command to run the create_samples_db.yml playbook.
Confirm that the playbook correctly configured a MariaDB database on the serverb machine.
You can confirm that the playbook created the samples database by running the sudo mysql -e "SHOW DATABASES" command.
The password for the student user is student.
Connect to serverb as the student user.
[student@workstation manage-review]$ ssh serverb
...output omitted...
[student@serverb ~]$Confirm that the samples database exists.
[student@serverb ~]$sudo mysql -e "SHOW DATABASES"[sudo] password for student:student+--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | |samples| +--------------------+
Log out of the serverb machine.
[student@serverb ~]$ logout
Connection to serverb closed.
[student@workstation manage-review]$