Skip to content

stolostron/ansible-collection.core

Repository files navigation

Ansible Collection for Red Hat Advanced Cluster Management for Kubernetes Integration

This collection includes modules and plugins for driving Red Hat Advanced Cluster Management for Kubernetes functionality from Ansible Playbooks.

Prerequisites

Before using this collection, install compatible versions of Red Hat Advanced Cluster Management for Kubernetes and Ansible (or Ansible Automation Platform). Review the following documentation for more information.

Red Hat Advanced Cluster Management for Kubernetes version compatibility

Tested with Red Hat Advanced Cluster Management for Kubernetes version 2.5. All versions before 2.5 are not supported.

Ansible version compatibility

Tested with stable versions of Ansible 2.10, Ansible 2.11, and Ansible 2.12. Ansible versions before 2.10 are not supported.

Python support

Tested with Python 3.6, Python 3.7, Python 3.8, and Python 3.9. Python versions before 3.6 are not supported.

Prepping your Red Hat Advanced Cluster Management for Kubernetes Hub cluster

Prior to using this collection, include the following configuration updates on your Hub cluster:

Included content

Name Description
stolostron.core.cluster_proxy Install the cluster proxy on a managedcluster, and get proxy url from the addon. cluster-admin permission on hub is assumed to enable the plugin.
stolostron.core.managed_serviceaccount_rbac Use the managed-serviceaccount RBAC to setup a serviceaccount on a managedcluster with the specified RBAC permission.
stolostron.core.managed_serviceaccount Use the managed-serviceaccount to setup a serviceaccount on a managedcluster, and return the serviceaccount token.
stolostron.core.managedcluster_addon Use managedcluster_addon to enable/disable an addon on a managedcluster.
stolostron.core.ocm_managedcluster Fetch ocm managedclusters, and group clusters by labels. Hub cluster information will be stored in the "hub" group.
stolostron.core.cluster_management_addon Use cluster_management_addon to enable/disable a feature on the hub. Users can only install an addon on managed clusters if the feature of that addon is enabled. This plugin will need access to the Multicloudhub CR, and it enables/disables available features by updating the corresponding fields in the CR.
stolostron.core.managedcluster_info Use managedcluster_info to retrieve information about one or more managed clusters from the hub.

Installation and Usage

Installing the Collection from Ansible Galaxy

Before using the stolostron.core collection, you need to install it with the Ansible Galaxy CLI:

ansible-galaxy collection install stolostron.core

You can also include it in a requirements.yml file and install it via ansible-galaxy collection install -r requirements.yml, using the format:

---
collections:
  - name: stolostron.core

Using the stolostron.core Collection in your playbooks

It's preferable to use content in this collection using their Fully Qualified Collection Namespace (FQCN), for example stolostron.core.cluster_proxy:

---
- hosts: "{{ target_hosts }}"
  connection: local

tasks:
- name: "Get ClusterProxy URL for {{ hostvars[inventory_hostname].cluster_name }}"
  stolostron.core.cluster_proxy:
    hub_kubeconfig: "{{ hostvars['local-cluster'].kubeconfig }}"
    managed_cluster: "{{ hostvars[inventory_hostname].cluster_name }}"
    wait: True
    timeout: 60
  register: cluster_proxy_url

For documentation on how to use individual modules and other content included in this collection, please see the links in the 'Included content' section earlier in this README.

A robust example utilizing the stolostron.core collection is available in the acm-ansible-collection-demo GitHub repository.

Development

If you want to develop new content for this collection or improve what's already here, the easiest way to work on the collection is to clone it into one of the configured COLLECTIONS_PATHS, and work on it there.

Testing

The tests directory contains configuration for running sanity, unit, and integration tests using ansible-test.

For more information, see the Testing README.

Contributing to this collection

See Contributing to stolostron.core.

Release Notes

See the changelog.

More information

For more information, join the #forum-acm-devops-wg channel on Slack.

License

Licensed under the Apache License, Version 2.0.

See LICENSE for full text.