How to Install Google Chrome in Debian-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 Debian-like systems
- Add Google Chrome key =>
ansible.builtin.apt_key
- Add Google Chrome repository =>
ansible.builtin.apt_repository
- Update apt cache and install Google Chrome =>
ansible.builtin.apt
In order to install Google Chrome on a Debian-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.apt_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 were apt
, your distribution Package Manager looks like for software.
You are going to use the ansible.builtin.apt_repository
Ansible module.
The third step is to update the apt cache for the available packages and install Google Chrome using the ansible.builtin.apt
Ansible module.
Parameters
- apt-key url string - URL
- apt-key state string - present/absent
- apt_repository repo string - repository
- apt_repository state string - present/absent
- apt name string - name or package-specific
- apt state string - latest/present/absent
- apt update_cache boolean - no/yes
For the ansible.builtin.apt_key
Ansible module I’m going to use two parameters: “url” and “state”.
The “url” parameter specifies the URL of the repository gpg signature key and the “state” verify that is present in our system after the execution.
For the ansible.builtin.apt_repository
Ansible module I’m going to use two parameters: “repo” and “state”.
The “repo” parameter specifies the repository parameters and the “state” verify that is present in our system after the execution.
For the ansible.builtin.apt
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 apt-cache to ensure that the latest version of the package is going to be downloaded.
Playbook
Install Google Chrome in Debian-like systems with Ansible Playbook.
code
- install_chrome_debian.yml
---
- name: install Google Chrome
hosts: all
become: true
tasks:
- name: Install apt-transport-https
ansible.builtin.apt:
state: latest
update_cache: true
- name: Add Apt signing key
ansible.builtin.apt_key:
url: "https://dl.google.com/linux/linux_signing_key.pub"
state: present
- name: Add repository into sources list
ansible.builtin.apt_repository:
repo: deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main
state: present
filename: google-chrome
- name: Install google-chrome-stable
ansible.builtin.apt:
name: "google-chrome-stable"
state: latest
update_cache: true
execution
output
$ ansible-playbook -i ubuntu/inventory install\ chrome/debian.yml
PLAY [install Google Chrome] **********************************************************************
TASK [Gathering Facts] ****************************************************************************
ok: [ubuntu.example.com]
TASK [Install apt-transport-https] ****************************************************************
changed: [ubuntu.example.com]
TASK [Add Apt signing key] ************************************************************************
changed: [ubuntu.example.com]
TASK [Add repository into sources list] ***********************************************************
changed: [ubuntu.example.com]
TASK [Install google-chrome-stable] ***************************************************************
changed: [ubuntu.example.com]
PLAY RECAP ****************************************************************************************
ubuntu.example.com : ok=5 changed=4 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
verification
$ ssh [email protected]
$ sudo su -
# apt-cache search google-chrome
google-chrome-beta - The web browser from Google
google-chrome-stable - The web browser from Google
google-chrome-unstable - The web browser from Google
# apt-cache show google-chrome-stable
Package: google-chrome-stable
Version: 94.0.4606.81-1
Architecture: amd64
Maintainer: Chrome Linux Team <[email protected]>
Installed-Size: 276179
Pre-Depends: dpkg (>= 1.14.0)
Depends: ca-certificates, fonts-liberation, libasound2 (>= 1.0.16), libatk-bridge2.0-0 (>= 2.5.3), libatk1.0-0 (>= 2.2.0), libatspi2.0-0 (>= 2.9.90), libc6 (>= 2.17), libcairo2 (>= 1.6.0), libcups2 (>= 1.6.0), libcurl3-gnutls | libcurl3-nss | libcurl4 | libcurl3, libdbus-1-3 (>= 1.5.12), libdrm2 (>= 2.4.38), libexpat1 (>= 2.0.1), libgbm1 (>= 8.1~0), libgcc1 (>= 1:3.0), libglib2.0-0 (>= 2.39.4), libgtk-3-0 (>= 3.9.10) | libgtk-4-1, libnspr4 (>= 2:4.9-2~), libnss3 (>= 2:3.22), libpango-1.0-0 (>= 1.14.0), libx11-6 (>= 2:1.4.99.1), libxcb1 (>= 1.9.2), libxcomposite1 (>= 1:0.4.4-1), libxdamage1 (>= 1:1.1), libxext6, libxfixes3, libxkbcommon0 (>= 0.4.1), libxrandr2, libxshmfence1, wget, xdg-utils (>= 1.0.2)
Recommends: libu2f-udev, libvulkan1
Provides: www-browser
Priority: optional
Section: web
Filename: pool/main/g/google-chrome-stable/google-chrome-stable_94.0.4606.81-1_amd64.deb
Size: 90229076
SHA256: bfe97cd8d9f941e4a1e73f53d9de6bb54e73a007ee4ce5d4e94a9a65ae2d7fb4
SHA1: 2dc4cbaa205ab61dbf10303400f23e3515fe6c4b
MD5sum: bd49a8b9956cef901657482050a88925
Description: The web browser from Google
Google Chrome is a browser that combines a minimal design with sophisticated technology to make the web faster, safer, and easier.
Description-md5: a2d34067fc33f1c87253c33b9fd975f0
# ls -al /etc/apt/sources.list.d/
total 16
drwxr-xr-x 2 root root 4096 Oct 11 11:42 .
drwxr-xr-x 7 root root 4096 Oct 11 11:42 ..
-rw-r--r-- 1 root root 68 Oct 11 11:40 dl_google_com_linux_chrome_deb.list
-rw-r--r-- 1 root root 189 Oct 11 11:42 google-chrome.list
root@ubuntu:~# cat /etc/apt/sources.list.d/google-chrome.list
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main
root@ubuntu:~# cat /etc/apt/sources.list.d/dl_google_com_linux_chrome_deb.list
deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main
# apt list google-chrome-stable
Listing... Done
google-chrome-stable/stable,now 94.0.4606.81-1 amd64 [installed]
Conclusion
Now you know how to install Google Chrome in Debian-like systems 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 Udemy 300+ Lessons Video Course.
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