以下是一个完整的指南,介绍如何在 Debian 类系统(如 Debian、Ubuntu、Linux Mint 等)中安装 Microsoft Edge 浏览器。Microsoft Edge 提供多个版本通道,包括稳定版、Beta 版、开发版和 Canary 版。本指南将展示如何通过 Ansible 自动化安装最新版的 Microsoft Edge。

Microsoft Edge 的版本通道

Microsoft Edge 提供以下版本通道:

  • 稳定版(Stable Channel):适合大多数用户,更新频率较低。
  • Beta 版(Beta Channel):每 4 周进行一次重大更新。
  • 开发版(Dev Channel):每周更新。
  • Canary 版(Canary Channel):每天更新。

更多详细信息,请参考 Microsoft Edge Insider 页面。

使用 Ansible 在 Debian 类系统中安装 Microsoft Edge

任务步骤

  1. 添加 Microsoft Edge 的 GPG 密钥 ⇒ ansible.builtin.apt_key
  2. 添加 Microsoft Edge 仓库 ⇒ ansible.builtin.apt_repository
  3. 更新 apt 缓存并安装 Microsoft Edge ⇒ ansible.builtin.apt

详细步骤

  1. 下载仓库的 GPG 签名密钥 使用 ansible.builtin.apt_key 模块。此加密密钥用于验证软件包和仓库的真实性,确保软件与 Microsoft 发布的版本一致。
  2. 将 Microsoft Edge 仓库添加到系统中 使用 ansible.builtin.apt_repository 模块。这是额外的软件源,系统包管理器(如 apt)会从此处获取软件。
  3. 更新 apt 缓存并安装 Microsoft Edge 使用 ansible.builtin.apt 模块。

参数说明

  • apt_key
  • url(字符串):仓库 GPG 签名密钥的 URL。
  • state(字符串):present 或 absent,确保密钥存在于系统中。
  • apt_repository
  • repo(字符串):仓库的参数,格式为 deb [arch=amd64] <URL> stable main。
  • state(字符串):present 或 absent,确保仓库存在于系统中。
  • filename(字符串):生成的 .list 文件名,位于 /etc/apt/sources.list.d/ 目录下。
  • apt
  • name(字符串):软件包名称(此处为 Microsoft Edge)。
  • state(字符串):latest、present 或 absent,确保软件包安装到最新版本。
  • update_cache(布尔值):是否在安装前更新 apt 缓存,确保下载最新版本的软件包。

示例代码

以下是一个 Ansible Playbook,用于在 Debian 类系统中安装 Microsoft Edge。

文件名:install_microsoft_edge_debian.yml

---
- name: 安装 Microsoft Edge
  hosts: all
  become: true
  tasks:
    - name: 安装 apt-transport-https
      ansible.builtin.apt:
        name: apt-transport-https
        state: latest
        update_cache: true

    - name: 添加 GPG 签名密钥
      ansible.builtin.apt_key:
        url: "https://packages.microsoft.com/keys/microsoft.asc"
        state: present

    - name: 添加 Microsoft Edge 仓库
      ansible.builtin.apt_repository:
        repo: "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main"
        state: present
        filename: "microsoft-edge"

    - name: 安装 Microsoft Edge
      ansible.builtin.apt:
        name: "microsoft-edge-stable"
        state: latest
        update_cache: true

执行命令

$ ansible-playbook -i ubuntu/inventory install_microsoft_edge_debian.yml

执行结果

PLAY [安装 Microsoft Edge] *******************************************************

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

TASK [安装 apt-transport-https] *********************************************
ok: [ubuntu.example.com]

TASK [添加 GPG 签名密钥] *****************************************************
changed: [ubuntu.example.com]

TASK [添加 Microsoft Edge 仓库] **********************************************
changed: [ubuntu.example.com]

TASK [安装 Microsoft Edge] ***************************************************
changed: [ubuntu.example.com]

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

验证安装

$ ssh devops@ubuntu.example.com
$ sudo su -
root@ubuntu:/home/devops# apt-cache search microsoft-edge
microsoft-edge-beta - The web browser from Microsoft
microsoft-edge-dev - The web browser from Microsoft
microsoft-edge-stable - The web browser from Microsoft

root@ubuntu:/home/devops# apt-cache show microsoft-edge-stable
Package: microsoft-edge-stable
Priority: optional
Section: web
Installed-Size: 378122
Maintainer: Microsoft Edge for Linux Team <null@null.com>
Architecture: amd64
Version: 95.0.1020.40-1
Provides: www-browser
Depends: ca-certificates, fonts-liberation, libasound2 (>= 1.0.16), libatk-bridge2.0-0 (>= 2.5.3), libatk1.0-0 (>= 2.2.0), libatomic1 (>= 4.8), 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), libuuid1 (>= 2.16), 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)
Pre-Depends: dpkg (>= 1.14.0)
Recommends: libu2f-udev, libvulkan1
Filename: pool/main/m/microsoft-edge-stable/microsoft-edge-stable_95.0.1020.40-1_amd64.deb
Size: 115596848
MD5sum: c2f860b685aec9dcc4bc7fc62c74c934
SHA1: 49a9f94818cad81e8694eaf1570a11de92ac9fec
SHA256: c5d4965c2216803874bca1b03a354b887e1a468d3a494462f24eb1c7efc4c66a
SHA512: 687a3e8e547dc8f66f252f0afc9edf1dcc1aa01f4b3bf43a36c5971f3f2853dea8c5ed78a1a5f97e082f5342bf7bdd111d5c3ef69052c2c3d3689d05cc43b514
Description: The web browser from Microsoft
Microsoft Edge is a browser that combines a minimal design with sophisticated technology to make the web faster, safer, and easier.
Description-md5: 5b904ee7bee9a072fea390fb6ed74471

root@ubuntu:/home/devops# ls -al /etc/apt/sources.list.d/
total 20
drwxr-xr-x 2 root root 4096 Nov  1 07:06 .
drwxr-xr-x 7 root root 4096 Nov  1 07:06 ..
-rw-r--r-- 1 root root  265 Nov  1 07:06 microsoft-edge.list

root@ubuntu:/home/devops# cat /etc/apt/sources.list.d/microsoft-edge.list
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main

root@ubuntu:/home