AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

Install Google Chrome on Suse with Ansible

By Luca Berton · Published 2024-01-01 · Category: installation

Learn how to install the latest Google Chrome Stable on SUSE Linux Enterprise Server and openSUSE using Ansible.

Install Google Chrome on Suse with Ansible

How to Install Google Chrome in Suse-like systems with Ansible? I'm going to show you a live Playbook 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

• Add Google Chrome key => ansible.builtin.rpm_key • Add Google Chrome repository => community.general.zypper_repository • Update yum cache and install Google Chrome => community.general.zypper

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.

See also: Install Google Chrome on Red Hat Using Ansible

Parameters

rpm_key key string - URL • rpm_key state string - present/absent

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. • zypper_repository name string • zypper_repository description string - repository • zypper_repository repo string - URL • zypper_repository auto_import_keys boolean - GPG signature

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. • zypper name string - name or package-specific • zypper state string - latest/present/absent • zypper update_cache boolean - no/yes

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.

## Playbook

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

code

• install_chrome_suse.yml
---
- 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 devops@suse.example.com
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 devops@suse.example.com
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

Conclusion

Now you know how to install Google Chrome in Suse-like systems using the official Google repository with Ansible.

See also: Install Google Chrome in Debian like systems - Ansible module apt_key, apt_repository and apt

Related Articles

become_user and become_method in Ansibleorganizing hosts with Ansible inventoryrole variables and defaults in Ansible

Category: installation

Watch the video: Install Google Chrome on Suse with Ansible — Video Tutorial

Browse all Ansible tutorials · AnsiblePilot Home