Ansible Pilot

Install Google Chrome in Suse-like systems - Ansible module rpm_key, zypper_repository and zypper

How to install the latest Google Chrome Stable on a Suse-like workstation (SUSE Linux Enterprise Server and openSUSE) verify software using the public GPG key and set up the Google repository. Included demo in openSUSE.

October 15, 2021
Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons

How to Install Google Chrome in Suse-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 Suse-like systems

In order to install Google Chrome on a Suse-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 zypper, your distribution package manager, looks like for software. You are going to use the community.general.zypper_repository Ansible module. The third step is to refresh the zypper cache for the available packages and install Google Chrome using the community.general.zypper Ansible module.

Parameters

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 community.general.zypper_repository Ansible module I’m going to use four parameters: “name”/“description”, “repo”, and “auto_import_keys”. The “name” and “description” parameters specify the repository name in the Suse system and the “repo” URL of it. The “auto_import_keys” parameter enables the GPG verification and imports of the suitable keys.

For the community.general.zypper 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 a refresh of the zypper cache to ensure that the latest version of the package is going to be downloaded.

The Best Resources For Ansible

Certifications

Video Course

Printed Book

eBooks

demo

Let’s jump into a real-life Ansible Playbook to install Google Chrome in Suse-like systems.

code

---
- name: install Google Chrome
  hosts: all
  become: true
  tasks:
    - name: Add rpm signing key
      ansible.builtin.rpm_key:
        key: https://dl.google.com/linux/linux_signing_key.pub
        state: present

    - name: Add repository into repo list
      community.general.zypper_repository:
        name: google-chrome
        description: google-chrome repository
        repo: http://dl.google.com/linux/chrome/rpm/stable/x86_64
        auto_import_keys: true
        state: present
        runrefresh: true
        enable: true

    - name: Install google-chrome-stable
      community.general.zypper:
        name: "google-chrome-stable"
        state: latest
        update_cache: true

execution

$ ansible-playbook -i suse/inventory install\ chrome/suse.yml
PLAY [install Google Chrome] **********************************************************************
TASK [Gathering Facts] ****************************************************************************
ok: [suse.example.com]
TASK [Add Yum signing key] ************************************************************************
changed: [suse.example.com]
TASK [Add repository into repo.d list] ************************************************************
changed: [suse.example.com]
TASK [Install google-chrome-stable] ***************************************************************
changed: [suse.example.com]
PLAY RECAP ****************************************************************************************
suse.example.com           : ok=4    changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

before Ansible execution

$ ssh [email protected]
devops@suse:~> sudo su -
suse:~ # zypper se -i google-chrome-stable
Loading repository data...
Warning: Repository 'openSUSE-Leap-42.3-Update' appears to be outdated. Consider using a different mirror or server.
Warning: Repository 'openSUSE-Leap-42.3-Update-Non-Oss' appears to be outdated. Consider using a different mirror or server.
Reading installed packages...
No matching items found.
suse:~ # zypper repos
Repository priorities are without effect. All enabled repositories share the same priority.
# | Alias                             | Name                              | Enabled | GPG Check | Refresh
--+-----------------------------------+-----------------------------------+---------+-----------+--------
1 | openSUSE-Leap-42.3-Non-Oss        | openSUSE-Leap-42.3-Non-Oss        | Yes     | (r ) Yes  | No     
2 | openSUSE-Leap-42.3-Oss            | openSUSE-Leap-42.3-Oss            | Yes     | (r ) Yes  | No     
3 | openSUSE-Leap-42.3-Update         | openSUSE-Leap-42.3-Update         | Yes     | (r ) Yes  | No     
4 | openSUSE-Leap-42.3-Update-Non-Oss | openSUSE-Leap-42.3-Update-Non-Oss | Yes     | (r ) Yes  | No

after Ansible execution

$ ssh [email protected]
devops@suse:~> sudo su -
suse:~ # zypper se -i google-chrome-stable
Loading repository data...
Warning: Repository 'openSUSE-Leap-42.3-Update' appears to be outdated. Consider using a different mirror or server.
Warning: Repository 'openSUSE-Leap-42.3-Update-Non-Oss' appears to be outdated. Consider using a different mirror or server.
Reading installed packages...
S  | Name                 | Summary       | Type   
---+----------------------+---------------+--------
i+ | google-chrome-stable | Google Chrome | package
suse:~ # zypper repos
Repository priorities are without effect. All enabled repositories share the same priority.
# | Alias                             | Name                              | Enabled | GPG Check | Refresh
--+-----------------------------------+-----------------------------------+---------+-----------+--------
1 | google-chrome                     | google-chrome repository          | Yes     | (r ) Yes  | Yes    
2 | openSUSE-Leap-42.3-Non-Oss        | openSUSE-Leap-42.3-Non-Oss        | Yes     | (r ) Yes  | No     
3 | openSUSE-Leap-42.3-Oss            | openSUSE-Leap-42.3-Oss            | Yes     | (r ) Yes  | No     
4 | openSUSE-Leap-42.3-Update         | openSUSE-Leap-42.3-Update         | Yes     | (r ) Yes  | No     
5 | openSUSE-Leap-42.3-Update-Non-Oss | openSUSE-Leap-42.3-Update-Non-Oss | Yes     | (r ) Yes  | No     
suse:~ # zypper se -s google-chrome-stable
Loading repository data...
Warning: Repository 'openSUSE-Leap-42.3-Update' appears to be outdated. Consider using a different mirror or server.
Warning: Repository 'openSUSE-Leap-42.3-Update-Non-Oss' appears to be outdated. Consider using a different mirror or server.
Reading installed packages...
S  | Name                 | Type    | Version        | Arch   | Repository              
---+----------------------+---------+----------------+--------+-------------------------
i+ | google-chrome-stable | package | 94.0.4606.81-1 | x86_64 | google-chrome repository

code with ❤️ in GitHub

Recap

Now you know how to install Google Chrome in Suse-like systems using the official Google repository with Ansible. Subscribe to the YouTube channel, Medium, and Website, X (formerly Twitter) 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

BUY the Complete PDF BOOK to easily Copy and Paste the 250+ Ansible code

Donate

Want to keep this project going? Please donate

Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons
Follow me

Subscribe not to miss any new releases