Install Google Chrome in RedHat-like systems - Ansible module rpm_key, yum_repository and yum
How to install the latest Google Chrome Stable on a RedHat-like workstation (RedHat Enterprise Linux, CentOS, CentOS Stream, Fedora, ClearOS, Oracle Linux, EuroLinux, Fermi Linux, EulerOS, ROSA Linux, Springdale Linux, Asianux) verify software using the public GPG key and set up the Google repository. Included demo in RHEL 8.4.


How to Install Google Chrome in RedHat-like systems with Ansible? I’m going to show you a live demo with some simple Ansible code. I’m Luca Berton and welcome to today’s episode of Ansible Pilot.
Ansible install Google Chrome in RedHat-like systems
- Add Google Chrome key => ansible.builtin.rpm_key
- Add Google Chrome repository => ansible.builtin.yum_repository
- Update yum cache and install Google Chrome => ansible.builtin.yum
In order to install Google Chrome on a RedHat-like system, we need to perform three different steps.
The first step is to download the GPG signature key for the repository. You are going to use the ansible.builtin.rpm_key
Ansible module.
This encrypted key verifies the genuinity of the packages and the repository and guarantees that the software is the same as Google releases.
The second step is to add the add Google Chrome repository to the distribution. It’s an extra website where yum/dnf
, your distribution package manager looks like for software.
You are going to use the ansible.builtin.yum_repository
Ansible module.
The third step is to update the yum cache for the available packages and install Google Chrome using the ansible.builtin.yum
Ansible module.
Parameters
- rpm_key key string — URL
- rpm_key state string — present/absent
- yum_repository name string — repository
- yum_repository baseurl string — URL
- yum_repository gpgcheck boolean — enable GPG
- yum_repository gpgkey string — GPG check and key URL
- yum name string — name or package-specific
- yum state string — latest/present/absent
- yum update_cache boolean — no/yes
For the ansible.builtin.rpm_key
Ansible module I’m going to use two parameters: “key” and “state”.
The “key” parameter specifies the URL or the key ID of the repository gpg signature key and the “state” verify that is present in our system after the execution.
For the ansible.builtin.yum_repository
Ansible module I’m going to use four parameters: “name”, “baseurl”, “gpgcheck” and “gpgkey”.
The “name” parameter specifies the repository parameters and the “baseurl” URL of it.
The “gpgcheck” parameter enables the gpg verification with the URL specified in “gpgkey” parameter.
For the ansible.builtin.yum
Ansible module I’m going to use three parameters: “name”, “state”, and “update_cache”.
The “name” parameter specifies the package name (Google Chrome in our use-case) and the “state” verify that is present in our system after the execution.
Before installing the package the “update_cache” performs an update of the yum cache to ensure that the latest version of the package is going to be downloaded.
The Best Resources For Ansible
Video Course
Printed Book
eBooks
- Ansible by Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps
- Ansible For Windows By Examples: 50+ Automation Examples For Windows System Administrator And DevOps
- Ansible For Linux by Examples: 100+ Automation Examples For Linux System Administrator and DevOps
- Ansible Linux Filesystem By Examples: 40+ Automation Examples on Linux File and Directory Operation for Modern IT Infrastructure
- Ansible For Containers and Kubernetes By Examples: 20+ Automation Examples To Automate Containers, Kubernetes and OpenShift
- Ansible For Security by Examples: 100+ Automation Examples to Automate Security and Verify Compliance for IT Modern Infrastructure
- Ansible Tips and Tricks: 10+ Ansible Examples to Save Time and Automate More Tasks
- Ansible Linux Users & Groups By Examples: 20+ Automation Examples on Linux Users and Groups Operation for Modern IT Infrastructure
- Ansible For PostgreSQL by Examples: 10+ Examples To Automate Your PostgreSQL database
- Ansible For Amazon Web Services AWS By Examples: 10+ Examples To Automate Your AWS Modern Infrastructure
- Ansible Automation Platform By Example: A step-by-step guide for the most common user scenarios
demo
Install Google Chrome in RedHat-like systems with Ansible Playbook.
code
- install_chrome_redhat.yml
---
- name: install Google Chrome
hosts: all
become: true
tasks:
- name: Add Yum signing key
ansible.builtin.rpm_key:
key: https://dl.google.com/linux/linux_signing_key.pub
state: present
- name: Add repository into repo.d list
ansible.builtin.yum_repository:
name: google-chrome
description: google-chrome repository
baseurl: http://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled: true
gpgcheck: true
gpgkey: https://dl.google.com/linux/linux_signing_key.pub
- name: Install google-chrome-stable
ansible.builtin.yum:
name: "google-chrome-stable"
state: latest
update_cache: true
execution
output
$ ansible-playbook -i demo/inventory install\ chrome/redhat.yml
PLAY [install Google Chrome] **********************************************************************
TASK [Gathering Facts] ****************************************************************************
ok: [demo.example.com]
TASK [Add Yum signing key] ************************************************************************
changed: [demo.example.com]
TASK [Add repository into repo.d list] ************************************************************
changed: [demo.example.com]
TASK [Install google-chrome-stable] ***************************************************************
changed: [demo.example.com]
PLAY RECAP ****************************************************************************************
demo.example.com : ok=4 changed=3 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
verification
$ ssh [email protected]
$ sudo su -
# ls -l /etc/yum.repos.d/
total 420
-rw-r--r--. 1 root root 1485 Sep 4 17:28 epel-modular.repo
-rw-r--r--. 1 root root 1304 Sep 1 00:13 epel-playground.repo
-rw-r--r--. 1 root root 1564 Sep 4 17:28 epel-playground.repo.rpmnew
-rw-r--r--. 1 root root 1111 Sep 1 00:13 epel.repo
-rw-r--r--. 1 root root 1422 Sep 4 17:28 epel.repo.rpmnew
-rw-r--r--. 1 root root 1584 Sep 4 17:28 epel-testing-modular.repo
-rw-r--r--. 1 root root 1258 Sep 1 00:13 epel-testing.repo
-rw-r--r--. 1 root root 1521 Sep 4 17:28 epel-testing.repo.rpmnew
-rw-r--r--. 1 root root 205 Oct 12 14:50 google-chrome.repo
-rw-r--r--. 1 root root 391942 Oct 8 10:54 redhat.repo
# cat /etc/yum.repos.d/google-chrome.repo
[google-chrome]
async = 1
baseurl = http://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled = 1
gpgcheck = 1
gpgkey = https://dl.google.com/linux/linux_signing_key.pub
name = google-chrome repository
# rpm -qa | grep google-chrome-stable
google-chrome-stable-94.0.4606.81-1.x86_64
[root@demo ~]# yum list installed google-chrome-stable
Updating Subscription Management repositories.
Installed Packages
google-chrome-stable.x86_64 94.0.4606.81-1 @google-chrome
Recap
Now you know how to install Google Chrome in RedHat-like systems with Ansible. Subscribe to the YouTube channel, Medium, Website, Twitter, and Substack to not miss the next episode of the Ansible Pilot.
Academy
Learn the Ansible automation technology with some real-life examples in my
My book Ansible By Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps
Donate
Want to keep this project going? Please donate