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
```yaml
---
- 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: