Loading...

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

How to automate the installation of Spotify snap system-wide in RedHat-like systems using 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.

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.

Links

  • [community.general.snap](https://docs.ansible.com/ansible/latest/collections/community/general/snap_module.html)
  • [spotify snap](https://snapcraft.io/spotify)
  • [Installing snap on Fedora](https://snapcraft.io/docs/installing-snap-on-fedora)

Playbook

code

``yaml

---

  • 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

``bash

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

Read the full tutorial: Install Spotify snap in RedHat-like systems - Ansible module snap