megabyte-labs.snapd
<!-- ⚠️ This README has been generated from the file(s) ".config/docs/blueprint-readme-role.md" ⚠️-->
<div align="center">
<center>
<a href="https://github.com/megabyte-labs/ansible-snapd">
<img width="148" height="148" alt="Snap logo" src="https://gitlab.com/megabyte-labs/ansible-roles/snapd/-/raw/master/logo.png" />
</a>
</center>
</div>
<div align="center">
<center><h1 align="center">Snap - A Linux Package Manager</h1></center>
<center><h4 style="color: #18c3d1;">Made by <a href="https://megabyte.space" target="_blank">Megabyte Labs</a></h4></center>
</div>
<div align="center">
<a href="https://megabyte.space" title="Megabyte Labs homepage" target="_blank">
<img alt="Homepage" src="https://img.shields.io/website?down_color=%23FF4136&down_message=Down&label=Homepage&logo=home-assistant&logoColor=white&up_color=%232ECC40&up_message=Up&url=https%3A%2F%2Fmegabyte.space&style=for-the-badge" />
</a>
<a href="https://github.com/megabyte-labs/ansible-snapd/blob/master/docs/CONTRIBUTING.md" title="Learn about contributing" target="_blank">
<img alt="Contributing" src="https://img.shields.io/badge/Contributing-Guide-0074D9?logo=github-sponsors&logoColor=white&style=for-the-badge" />
</a>
<a href="https://app.slack.com/client/T01ABCG4NK1/C01NN74H0LW/details/" title="Chat with us on Slack" target="_blank">
<img alt="Slack" src="https://img.shields.io/badge/Slack-Chat-e01e5a?logo=slack&logoColor=white&style=for-the-badge" />
</a>
<a href="https://gitter.im/megabyte-labs/community" title="Chat with the community on Gitter" target="_blank">
<img alt="Gitter" src="https://img.shields.io/gitter/room/megabyte-labs/community?logo=gitter&logoColor=white&style=for-the-badge" />
</a>
<a href="https://github.com/megabyte-labs/ansible-snapd" title="GitHub mirror" target="_blank">
<img alt="GitHub" src="https://img.shields.io/badge/Mirror-GitHub-333333?logo=github&style=for-the-badge" />
</a>
<a href="https://gitlab.com/megabyte-labs/ansible-roles/snapd" title="GitLab repository" target="_blank">
<img alt="GitLab" src="https://img.shields.io/badge/Repo-GitLab-fc6d26?style=for-the-badge" />
</a>
</div>
<br/>
<div align="center">
<a title="Ansible Galaxy role: professormanhattan.snapd" href="https://galaxy.ansible.com/professormanhattan/snapd" target="_blank">
<img alt="Ansible Galaxy role: professormanhattan.snapd" src="https://img.shields.io/ansible/role/56331?logo=ansible&style=flat-square" />
</a>
<a title="Version: 0.0.1" href="https://github.com/megabyte-labs/ansible-snapd" target="_blank">
<img alt="Version: 0.0.1" src="https://img.shields.io/badge/version-0.0.1-blue.svg?style=flat-square" />
</a>
<a title="GitLab build status" href="https://gitlab.com/megabyte-labs/ansible-roles/snapd/-/commits/master" target="_blank">
<img alt="Build status" src="https://img.shields.io/gitlab/pipeline-status/megabyte-labs/ansible-roles/snapd?branch=master&label=build&logo=gitlab&logoColor=white&style=flat-square" />
</a>
<a title="Windows 11 test status on GitHub" href="https://github.com/megabyte-labs/ansible-snapd/actions/workflows/Windows.yml" target="_blank">
<img alt="Windows 11 test status" src="https://img.shields.io/github/workflow/status/ProfessorManhattan/ansible-snapd/Windows%20Ansible%20Role%20Test/master?color=cyan&label=windows&logo=windows&style=flat-square" />
</a>
<a title="macOS test status on GitLab" href="https://gitlab.com/megabyte-labs/ansible-roles/snapd/-/commits/master" target="_blank">
<img alt="macOS test status" src="https://img.shields.io/gitlab/pipeline-status/megabyte-labs/ansible-roles/snapd?branch=test%2Fdarwin&label=osx&logo=apple&style=flat-square" />
</a>
<a title="Linux Molecule test status on GitLab" href="https://gitlab.com/megabyte-labs/ansible-roles/snapd/-/commits/master" target="_blank">
<img alt="Linux Molecule test status" src="https://img.shields.io/gitlab/pipeline-status/megabyte-labs/ansible-roles/snapd?branch=test%2Flinux&label=linux&style=flat-square" />
</a>
<a title="Ansible Galaxy quality score (out of 5)" href="https://galaxy.ansible.com/professormanhattan/snapd" target="_blank">
<img alt="Ansible Galaxy quality score" src="https://img.shields.io/ansible/quality/56331?logo=ansible&style=flat-square" />
</a>
<a title="Ansible Galaxy download count" href="https://galaxy.ansible.com/professormanhattan/snapd" target="_blank">
<img alt="Ansible Galaxy download count" src="https://img.shields.io/ansible/role/d/56331?logo=ansible&label=downloads&style=flat-square" />
</a>
<a title="Documentation" href="https://megabyte.space/docs/ansible" target="_blank">
<img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg?style=flat-square" />
</a>
<a title="License: MIT" href="https://github.com/megabyte-labs/ansible-snapd/blob/master/LICENSE" target="_blank">
<img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-yellow.svg?style=flat-square" />
</a>
</div>
> <br/><h4 align="center">**An Ansible role that makes sure Snap is installed and set up correctly on Linux systems**</h4><br/>
<a href="#table-of-contents" style="width:100%"><img style="width:100%" src="https://gitlab.com/megabyte-labs/assets/-/raw/master/png/aqua-divider.png" /></a>
## Table of Contents
- [Overview](#overview)
- [Features](#features)
- [Quick Start](#quick-start)
- [Supported Operating Systems](#supported-operating-systems)
- [Dependencies](#dependencies)
- [Python](#python)
- [Galaxy Roles](#galaxy-roles)
- [Galaxy Collections](#galaxy-collections)
- [Example Playbook](#example-playbook)
- [Real World Example](#real-world-example)
- [Contributing](#contributing)
- [Affiliates](#affiliates)
- [License](#license)
<a href="#overview" style="width:100%"><img style="width:100%" src="https://gitlab.com/megabyte-labs/assets/-/raw/master/png/aqua-divider.png" /></a>
## Overview
This repository contains an [Ansible](https://www.ansible.com/) role that ensures Snap is installed and properly configured on Linux systems. [Snap](https://snapcraft.io/) is a software packaging and deployment system created by Canonical for Linux-based operating systems. The packages, known as snaps, and the tool to manage them, snapd, work on various Linux distributions and allow developers to distribute their applications directly to users. Snaps run in a secure environment, providing limited access to the host system.
<a href="#features" style="width:100%"><img style="width:100%" src="https://gitlab.com/megabyte-labs/assets/-/raw/master/png/aqua-divider.png" /></a>
## Features
**Ensures Snap is installed:**
- Installs Snap on Linux systems
- Makes sure Snap starts and is enabled on system boot
<a href="#quick-start" style="width:100%"><img style="width:100%" src="https://gitlab.com/megabyte-labs/assets/-/raw/master/png/aqua-divider.png" /></a>
## Quick Start
Want to install Snap without using [Ansible](https://www.ansible.com/)? Just run the command that matches your operating system:
**Linux/macOS:**
```shell
curl -sS https://install.doctor/snapd | bash
Windows:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://install.doctor/snapd?os=win'))
Important Note: Before running the above commands, you should check the URL to ensure the code is safe. Although it is confirmed safe, always inspect a script before running it on your computer.
You can also check out Install Doctor, an app we created that simplifies the installation of any Ansible role with a single command. It also has features to install binaries without a password. If you want to use this role in an Ansible playbook and customize settings, keep reading below.
Supported Operating Systems
The chart below lists the operating systems where we have tested this role. It is automatically generated using Ansible Molecule tests found in the molecule/
folder. Our continuous integration (CI) system tests Windows, macOS, Ubuntu, Fedora, CentOS, Debian, and Archlinux. If your OS is not listed but is based on one of these systems, this role might still work.
OS Family | OS Version | Status | Idempotent | Tested On |
---|
What does idempotent mean? Idempotent means that running this role twice in a row will not change the system the second time.
We have put significant effort into refining our CI configurations and build tools. If you're interested in learning more, visit our Ansible common files and Ansible documentation. For more details, check the CONTRIBUTING.md guide.
Dependencies
Most of our roles depend on Ansible Galaxy collections. Some projects also require other roles and collections available on Ansible Galaxy. Before using this role, you need to install the required collections, roles, and Python packages by running:
if type poetry &> /dev/null; then poetry install --no-root; else pip3 install -r .config/assets/requirements.txt; fi
ansible-galaxy install -r requirements.yml
If you're new to Ansible and want an easier setup, just run bash .config/scripts/start.sh
. This will ensure everything is set up correctly.
Python
To run this play on a standard machine, you need Ansible (a Python package). We include various other Python dependencies needed for specific use cases and development. Here’s a table of these packages:
Package | Description | Required |
---|---|---|
ansible | A configuration tool to manage computers remotely | ✔️ |
docker | Enables Ansible to manage Docker containers | ✔️ |
python-vagrant | Needed to manage Vagrant virtual machines | ✔️ |
pywinrm | Used to manage Windows machines using WinRM | ✔️ |
ansible-lint | Tool to check Ansible files for issues | |
ansibler | Custom tool for generating documentation (like compatibility charts) | |
black | Auto-formatter for Python files | |
blocklint | Tool to prevent certain words in the code | |
flake8 | Linter to check Python syntax and style errors | |
mod-ansible-autodoc | A modified version of ansible-autodoc for generating documentation from YAML comments | |
molecule | Testing framework for Ansible | |
molecule-docker | Molecule plugin for managing Docker containers | |
molecule-vagrant | Molecule plugin for managing Vagrant VMs | |
pre-commit-hooks | Tools useful for checking code quality | |
proselint | Linter for improving English in documentation | |
yamllint | Linter for YAML files to ensure correct syntax and style |
Galaxy Roles
Most of our roles do not have dependencies, but some may require another role to be installed first. At the beginning of the play, any required Ansible Galaxy role dependencies from meta/main.yml
will run. These are set to only run once in each playbook. If multiple roles sharing dependencies are included, installation will only occur on the first run. Some roles also use helper roles directly from the task files to keep our main playbook (Gas Station) streamlined.
The requirements.yml
file lists all Ansible Galaxy dependencies needed by this role. Below is a quick overview of the role dependencies:
role_dependencies
Galaxy Collections
This role relies on several Ansible Galaxy collections. The collections and links to their sources are listed below.
Example Playbook
Once the dependencies are installed, just add the role to your main playbook. The role will manage the become
behavior, and you can add it without worrying about commands that shouldn't run as root:
- hosts: all
roles:
- professormanhattan.snapd
If you're adding this role to an existing playbook, consider copying the requirements from pyproject.toml
and requirements.yml
to your playbook's root, so you only need to manage one set of requirements in future uses. Note that the dependencies in pyproject.toml
can also be converted to the more common requirements.txt
, if you're currently using that for Python package management.
Real World Example
You can view an example of a playbook that uses this role in our main playbook (also known as Gas Station). This playbook is a great resource for anyone learning Ansible. It features advanced tools that experienced users will value, and it's useful for those unfamiliar with Ansible as it helps create a powerful development environment. Overall, it’s an excellent project for developers to know about!
Contributing
We welcome contributions, issues, and feature requests! Feel free to check the issues page. If you want to contribute, please review the contributing guide.
Sponsorship
Dear Awesome Person,
I create open source projects out of passion. While I have a job and other basics covered, it would still be nice to receive community support for my work. Please consider sponsoring me! Who knows? I might be able to work on open source full-time someday.
Thanks,
Brian Zalewski
Affiliates
Here are some services we use that offer special incentives if you sign up through our links:

License
Copyright © 2020-2021 Megabyte LLC. This project is licensed under the MIT license. ```
Ensures Snap is installed and properly configured on Linux systems
ansible-galaxy install megabyte-labs.snapd