How to Install Microsoft Edge in RedHat-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.

Microsoft Edge on Linux

Microsoft Edge is available in the following channels:

  • Stable Channel
  • Beta Channel - Major update every 4 weeks
  • Dev Channel - Updated weekly
  • Canary Channel - Updated daily

More information https://www.microsoftedgeinsider.com/en-us/download/

Ansible install Microsoft Edge in RedHat-like systems

  • Add Microsoft Edge key => ansible.builtin.rpm_key
  • Add Microsoft Edge repository => ansible.builtin.yum_repository
  • Update yum cache and install Microsoft Edge => ansible.builtin.yum

In order to install Microsoft Edge 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 Microsoft releases. The second step is to add the add Microsoft Edge 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 Microsoft Edge 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 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 (Microsoft Edge 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

Let’s jump in a real-life Ansible Playbook to install Microsoft Edge in RedHat-like systems.

code

  • install_microsoft_edge_redhat.yml
---
- name: install Microsoft Edge
  hosts: all
  become: true
  tasks:
    - name: Add Yum signing key
      ansible.builtin.rpm_key:
        key: "https://packages.microsoft.com/keys/microsoft.asc"
        state: present
- name: Add repository into repo.d list
      ansible.builtin.yum_repository:
        name: microsoft-edge
        description: microsoft-edge
        baseurl: "https://packages.microsoft.com/yumrepos/edge/"
        enabled: true
        gpgcheck: true
        gpgkey: "https://packages.microsoft.com/keys/microsoft.asc"
- name: Install microsoft-edge-stable
      ansible.builtin.yum:
        name: "microsoft-edge-stable"
        state: latest
        update_cache: true

execution

$ ansible-playbook -i fedora/inventory install\ edge/redhat.yml

PLAY [install Microsoft Edge] *********************************************************************

TASK [Gathering Facts] ****************************************************************************
ok: [fedora.example.com]

TASK [Add Yum signing key] ************************************************************************
changed: [fedora.example.com]

TASK [Add repository into repo.d list] ************************************************************
changed: [fedora.example.com]

TASK [Install microsoft-edge-stable] **************************************************************
changed: [fedora.example.com]

PLAY RECAP ****************************************************************************************
fedora.example.com         : ok=4    changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

verification

$ ssh [email protected]
[devops@demo ~]$ sudo su
[root@demo devops]# yum list installed microsoft-edge-stable
Installed Packages
microsoft-edge-stable.x86_64                     95.0.1020.40-1                     @microsoft-edge
[root@demo devops]# rpm -qa | grep microsoft-edge-stable
microsoft-edge-stable-95.0.1020.40-1.x86_64
[root@demo devops]# ls -al /etc/yum.repos.d/
total 40
drwxr-xr-x.  2 root root 4096 Nov  1 11:15 .
drwxr-xr-x. 77 root root 4096 Nov  1 11:16 ..
-rw-r--r--.  1 root root  728 Apr 12  2021 fedora-cisco-openh264.repo
-rw-r--r--.  1 root root 1302 Apr 12  2021 fedora-modular.repo
-rw-r--r--.  1 root root 1239 Apr 12  2021 fedora.repo
-rw-r--r--.  1 root root 1349 Apr 12  2021 fedora-updates-modular.repo
-rw-r--r--.  1 root root 1286 Apr 12  2021 fedora-updates.repo
-rw-r--r--.  1 root root 1391 Apr 12  2021 fedora-updates-testing-modular.repo
-rw-r--r--.  1 root root 1344 Apr 12  2021 fedora-updates-testing.repo
-rw-r--r--.  1 root root  190 Nov  1 11:16 microsoft-edge.repo
[root@demo devops]# cat /etc/yum.repos.d/microsoft-edge.repo
[microsoft-edge]
async = 1
baseurl = https://packages.microsoft.com/yumrepos/edge/
enabled = 1
gpgcheck = 1
gpgkey = https://packages.microsoft.com/keys/microsoft.asc
name = microsoft-edge

code with ❤️ in GitHub

Conclusion

Now you know how to install Microsoft Edge in RedHat-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.

BUY the Complete Udemy 300+ Lessons Video Course

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

Want to keep this project going? Please donate

Patreon Buy me a Pizza