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 Spotify snap in RedHat-like systems - Ansible module snap

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

How to automate the installation of Spotify snap system-wide in RedHat-like systems using Ansible module snap.

Install Spotify snap in RedHat-like systems - Ansible module snap

How to Install Spotify snap on 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.

See also: Ansible Playbook for Installing Docker on Linux Systems

Ansible installs Spotify snap on RedHat-like systems

community.general.snap • Manages snaps

Today we are going to talk about the Ansible module snap. The full name is community.general.snap, it's part of community.general modules maintained by the Ansible Community. The purpose of the snap module is to Manage snaps in the target system.

Parameters

• name _string_ - snap name • state _string_ - present/absent • channel _string_ - "stable" • classic _boolean_ - no/yes

Let me summarize the parameters of snap module. The only required is "name", where you specify the snap name to install or remove. The parameter "state" specifies if you would like to perform the install action ("present" option) or the remove action ("absent" option). The parameter "channel" specifies which channel to use, default the "stable" channel. The parameter "classic" allows the confinement allows a snap to have the same level of access to the system as "classic" packages.

See also: Install Zoom flatpak in RedHat-like systems - Ansible module flatpak

Links

community.general.snapspotify snapInstalling snap on Fedora

Playbook

code

---
- name: snap module Playbook
  hosts: all
  become: true
  gather_facts: false
  tasks:
    - name: snapd present
      ansible.builtin.yum:
        name:
          - snapd
          - fuse
          - squashfs-tools
          - squashfuse
          - kernel-modules
        state: present
    - name: symlink /snap
      ansible.builtin.file:
        src: "/var/lib/snapd/snap"
        dest: "/snap"
        state: link
    - name: load squashfs module
      community.general.modprobe:
        name: "squashfs"
        state: present
    - name: install Spotify via snap
      community.general.snap:
        name: spotify
        state: present

execution

ansible-pilot $ ansible-playbook -i virtualmachines/fedora35/inventory container/snap_redhat.yml
PLAY [snap module Playbook] ***************************************************************************
TASK [snapd present] ******************************************************************************
changed: [fedora.example.com]
TASK [symlink /snap] ******************************************************************************
ok: [fedora.example.com]
TASK [load squashfs module] ***********************************************************************
changed: [fedora.example.com]
TASK [install Spotify via snap] *******************************************************************
changed: [fedora.example.com]
PLAY RECAP ****************************************************************************************
fedora.example.com         : ok=4    changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
ansible-pilot $

idempotency

ansible-pilot $ ansible-playbook -i virtualmachines/fedora35/inventory container/snap_redhat.yml
PLAY [snap module Playbook] ***************************************************************************
TASK [snapd present] ******************************************************************************
ok: [fedora.example.com]
TASK [symlink /snap] ******************************************************************************
ok: [fedora.example.com]
TASK [load squashfs module] ***********************************************************************
ok: [fedora.example.com]
TASK [install Spotify via snap] *******************************************************************
ok: [fedora.example.com]
PLAY RECAP ****************************************************************************************
fedora.example.com         : ok=4    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
ansible-pilot $

before execution

ansible-pilot $ ssh devops@fedora.example.com
[devops@fedora ~]$ cat /etc/os-release 
NAME="Fedora Linux"
VERSION="35 (Cloud Edition)"
ID=fedora
VERSION_ID=35
VERSION_CODENAME=""
PLATFORM_ID="platform:f35"
PRETTY_NAME="Fedora Linux 35 (Cloud Edition)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:35"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f35/system-administrators-guide/"
SUPPORT_URL="https://ask.fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=35
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=35
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
VARIANT="Cloud Edition"
VARIANT_ID=cloud
[devops@fedora ~]$ snap list
-bash: snap: command not found
[devops@fedora ~]$ dnf list snapd
Last metadata expiration check: 0:22:10 ago on Fri 04 Mar 2022 05:16:58 AM UTC.
Available Packages
snapd.x86_64                                 2.54.3-1.fc35                                  updates
[devops@fedora ~]$ exit
logout
Connection to fedora.example.com closed.
ansible-pilot $

after execution

ansible-pilot $ ssh devops@fedora.example.com
[devops@fedora ~]$ dnf list snapd
Last metadata expiration check: 0:27:34 ago on Fri 04 Mar 2022 05:16:58 AM UTC.
Installed Packages
snapd.x86_64                                 2.54.3-1.fc35                                 @updates
[devops@fedora ~]$ lsmod | grep squashfs
squashfs               69632  6
[devops@fedora ~]$ ls -al /snap/
total 4
drwxr-xr-x. 1 root root 126 Mar  4 10:43 .
drwxr-xr-x. 1 root root 234 Mar  4 10:43 ..
drwxr-xr-x. 1 root root  16 Mar  4 10:41 bare
drwxr-xr-x. 1 root root  14 Mar  4 10:42 bin
drwxr-xr-x. 1 root root  22 Mar  4 10:41 core18
drwxr-xr-x. 1 root root  20 Mar  4 10:43 gnome-3-28-1804
drwxr-xr-x. 1 root root  22 Mar  4 10:42 gtk-common-themes
-r--r--r--. 1 root root 590 Mar  4 10:40 README
drwxr-xr-x. 1 root root  24 Mar  4 10:40 snapd
drwxr-xr-x. 1 root root  18 Mar  4 10:42 spotify
[devops@fedora ~]$ snap list
Name               Version                     Rev    Tracking       Publisher   Notes
bare               1.0                         5      latest/stable  canonical✓  base
core18             20211215                    2284   latest/stable  canonical✓  base
gnome-3-28-1804    3.28.0-19-g98f9e67.98f9e67  161    latest/stable  canonical✓  -
gtk-common-themes  0.1-59-g7bca6ae             1519   latest/stable  canonical✓  -
snapd              2.54.3                      14978  latest/stable  canonical✓  snapd
spotify            1.1.80.699.gc3dac750        58     latest/stable  spotify✓    -
[devops@fedora ~]$

code with ❤️ in GitHub

See also: Update Zoom flatpak(s) in Linux systems - Ansible module command

Conclusion

Now you know how to Install Spotify snap in RedHat-like systems with Ansible.

Related Articles

Ansible become methods comparedinventory configuration in Ansibleusing the ansible.builtin.file module

Category: installation

Watch the video: Install Spotify snap in RedHat-like systems - Ansible module snap — Video Tutorial

Browse all Ansible tutorials · AnsiblePilot Home