Continuous Configuration Automation (CCA)

Integrating Ansible

Ansible is open-source software for provisioning, configuration management, and application deployment.

In the following examples:

IdentifierDescription
OWNERYour Cloudsmith organization name (namespace)
REPOSITORYYour Cloudsmith Repository identifier (also called "slug")
DISTROYour distribution (for example, el, fedora, or debian)
VERSIONYour version name (for example, 7, 29, hardy, or buster)
FINGERPRINTThe 8 Byte fingerprint of the Public GPG key for the repository
TOKENYour Cloudsmith entitlement token (see Entitlements for more details)
USERNAMEYour Cloudsmith username
PASSWORDYour Cloudsmith password
API-KEYYour 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: true

Private repository

- 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: true

Install 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: true

Adding 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: true

Private repository

- 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: true

Install 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