Integrations
Integrating Ansible
How to integrate Ansible with Cloudsmith.
Ansible is open-source software for provisioning, configuration management, and application deployment.
- Ansible: Ansible Website
- Ansible Docs: Official Ansible documentation
In the following examples:
| Identifier | Description |
|---|---|
| OWNER | Your Cloudsmith organisation name (namespace) |
| REPOSITORY | Your Cloudsmith Repository identifier (also called "slug") |
| DISTRO | Your distribution (i.e el, fedora, debian etc) |
| VERSION | Your version name (i.e 7, 29, hardy, buster etc) |
| FINGERPRINT | The 8 Byte fingerprint of the Public GPG key for the repository |
| TOKEN | Your Cloudsmith Entitlement Token (see Entitlements for more details) |
| USERNAME | Your Cloudsmith username |
| PASSWORD | Your Cloudsmith password |
| API-KEY | Your Cloudsmith API Key |
Adding a RPM repository
To add a Cloudsmith repository for RPM packages using Ansible, you would use the Ansible yum_repository module. The yum_repository module can add or remove YUM repositories in RPM-based Linux distributions.
Example yum_repository task:
Public Repository
yaml
- name: Add Cloudsmith Repository
yum_repository:
name: cloudsmith
description: Cloudsmith
file: cloudsmith
baseurl: https://dl.cloudsmith.io/public/OWNER/REPOSITORY/rpm/DISTRO/VERSION/$basearch
repo_gpgcheck: yes
gpgkey: https://dl.cloudsmith.io/public/OWNER/REPOSITORY/cfg/gpg/gpg.FINGERPRINT.key
enabled: yes
become: truePrivate Repository
yaml
- name: Add Cloudsmith Repository
yum_repository:
name: cloudsmith
description: Cloudsmith
file: cloudsmith
baseurl: https://dl.cloudsmith.io/TOKEN/OWNER/REPOSITORY/rpm/DISTRO/VERSION/$basearch
repo_gpgcheck: yes
gpgkey: https://dl.cloudsmith.io/TOKEN/OWNER/REPOSITORY/cfg/gpg/gpg.FINGERPRINT.key
enabled: yes
become: trueInstall a package
To install a RPM package via Ansible, you use the Ansible yum module:
yaml
- name: Install a package
yum:
name: PACKAGE_NAME
state: present
update_cache: yes
become: trueAdding a Debian repository
To add a Cloudsmith repository for Debian packages using Ansible, you would use the Ansible apt_key module and the apt_repository module.
Example apt_key and apt_repository tasks:
Public Repository
yaml
- name: Import Cloudsmith Repository GPG key
apt_key:
url: https://dl.cloudsmith.io/public/OWNER/REPOSITORY/cfg/gpg/gpg.FINGERPRINT.key
state: present
become: true
- name: Add Cloudsmith Repository
apt_repository:
repo: deb https://dl.cloudsmith.io/public/OWNER/REPOSITORY/deb/DISTRO VERSION main
state: present
become: truePrivate Repository
yaml
- name: Import Cloudsmith Repository GPG key
apt_key:
url: https://dl.cloudsmith.io/TOKEN/OWNER/REPOSITORY/cfg/gpg/gpg.FINGERPRINT.key
state: present
become: true
- name: Add Cloudsmith Repository
apt_repository:
repo: deb https://dl.cloudsmith.io/TOKEN/OWNER/REPOSITORY/deb/DISTRO VERSION main
state: present
become: trueInstall a package
To install a Debian package via Ansible, you use the Ansible apt module:
yaml
- name: Install a package
apt:
name: PACKAGE_NAME
state: present
update_cache: yes
become: true