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 Debian-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 Debian-like systems using Ansible module snap.

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

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

See also: Install Spotify snap in RedHat-like systems - Ansible module snap

Ansible installs Spotify snap on Debian-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 Docker in Debian-like systems - Ansible module apt_key, apt_repository and apt

Links

community.general.snapspotify snap

## Playbook

code

---
- name: snap module Playbook
  hosts: all
  become: true
  gather_facts: false
  tasks:
    - name: snapd present
      ansible.builtin.apt:
        name: snapd
        state: present
    - name: install Spotify via snap
      community.general.snap:
        name: spotify
        state: present

execution

ansible-pilot $ ansible-playbook -i virtualmachines/ubuntu2110desktop/inventory container/snap_debian.yml
PLAY [snap module Playbook] ***************************************************************************
TASK [snapd present] ******************************************************************************
ok: [ubuntu2110.example.com]
TASK [install Spotify via snap] *******************************************************************
changed: [ubuntu2110.example.com]
PLAY RECAP ****************************************************************************************
ubuntu2110.example.com     : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
ansible-pilot $

idempotency

ansible-pilot $ ansible-playbook -i virtualmachines/ubuntu2110desktop/inventory container/snap_debian.yml
PLAY [snap module Playbook] ***************************************************************************
TASK [snapd present] ******************************************************************************
ok: [ubuntu2110.example.com]
TASK [install Spotify via snap] *******************************************************************
ok: [ubuntu2110.example.com]
PLAY RECAP ****************************************************************************************
ubuntu2110.example.com     : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
ansible-pilot $

before execution

ansible-pilot $ ssh devops@ubuntu2110.example.com
Welcome to Ubuntu 21.10 (GNU/Linux 5.13.0-30-generic x86_64)
* Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage
0 updates can be applied immediately.
Last login: Thu Mar  3 07:06:34 2022 from 192.168.0.59
$ snap --version
snap    2.54.3.2
snapd   2.54.3.2
series  16
ubuntu  21.10
kernel  5.13.0-30-generic
$ snap list
Name               Version             Rev    Tracking         Publisher   Notes
bare               1.0                 5      latest/stable    canonical✓  base
core               16-2.54.3           12725  latest/stable    canonical✓  core
core20             20220215            1361   latest/stable    canonical✓  base
firefox            97.0.1-1            1025   latest/stable/…  mozilla✓    -
gnome-3-38-2004    0+git.1f9014a       99     latest/stable/…  canonical✓  -
gtk-common-themes  0.1-59-g7bca6ae     1519   latest/stable/…  canonical✓  -
snap-store         3.38.0-66-gbd5b8f7  558    latest/stable/…  canonical✓  -
$ 

after execution

ansible-pilot $ ssh devops@ubuntu2110.example.com
Welcome to Ubuntu 21.10 (GNU/Linux 5.13.0-30-generic x86_64)
* Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage
0 updates can be applied immediately.
Last login: Thu Mar  3 08:36:22 2022 from 192.168.0.59
$ snap list
Name               Version                     Rev    Tracking         Publisher   Notes
bare               1.0                         5      latest/stable    canonical✓  base
core               16-2.54.3                   12725  latest/stable    canonical✓  core
core18             20211215                    2284   latest/stable    canonical✓  base
core20             20220215                    1361   latest/stable    canonical✓  base
firefox            97.0.1-1                    1025   latest/stable/…  mozilla✓    -
gnome-3-28-1804    3.28.0-19-g98f9e67.98f9e67  161    latest/stable    canonical✓  -
gnome-3-38-2004    0+git.1f9014a               99     latest/stable/…  canonical✓  -
gtk-common-themes  0.1-59-g7bca6ae             1519   latest/stable/…  canonical✓  -
snap-store         3.38.0-66-gbd5b8f7          558    latest/stable/…  canonical✓  -
spotify            1.1.77.643.g3c4c6fc6        57     latest/stable    spotify✓    -
$

code with ❤️ in GitHub

Conclusion

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

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

Related Articles

privilege escalation with Ansible becomeinventory configuration in Ansible

Category: installation

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

Browse all Ansible tutorials · AnsiblePilot Home