Skupper Ansible Examples
This document provides a comprehensive overview of Ansible examples and end-to-end test scenarios available in the Skupper ecosystem. These examples demonstrate how to use the skupper.v2 Ansible collection to automate Skupper deployments, establish site connectivity, and manage service networks across Kubernetes and non-Kubernetes platforms.
Example Categories
Production Examples
Located in scripts/skewer-yamls/ and referenced documentation.
Hello World with Ansible
File: skupper-example-ansible.yaml
A complete walkthrough demonstrating frontend/backend deployment across two Kubernetes clusters using Ansible automation.
What it demonstrates:
- Installing the
skupper.v2Ansible collection - Using inventory files to manage multiple sites
- Applying Skupper resources with
skupper.v2.resourcemodule - Generating and redeeming access tokens with
skupper.v2.tokenmodule - Establishing cross-cluster connectivity
- Teardown and cleanup automation
Key Ansible modules used:
skupper.v2.resource- Apply Site, Listener, Connector resourcesskupper.v2.token- Issue AccessToken for site linking
Architecture:
- West site: Frontend application + Skupper Site with Listener
- East site: Backend application + Skupper Site with Connector
- Link: AccessGrant from west redeemed by east
Inventory structure:
all:
vars:
ansible_connection: local
hosts:
west:
kubeconfig: "{{ inventory_dir }}/kubeconfigs/west"
namespace: west
resources_path: "{{ playbook_dir }}/kubernetes/west.yaml"
east:
kubeconfig: "{{ inventory_dir }}/kubeconfigs/east"
namespace: east
resources_path: "{{ playbook_dir }}/kubernetes/east.yaml"Playbook pattern (setup.yml):
# Apply resources to all sites
- hosts: all
tasks:
- name: Apply site resources
skupper.v2.resource:
path: "{{ resources_path }}"
kubeconfig: "{{ kubeconfig }}"
namespace: "{{ namespace }}"
# Generate token from one site
- hosts: west
tasks:
- name: Create a token to the west site
skupper.v2.token:
name: "west"
kubeconfig: "{{ kubeconfig }}"
namespace: "{{ namespace }}"
register: accesstoken
# Redeem token at another site
- hosts: east
tasks:
- name: Link east site to west
skupper.v2.resource:
def: "{{ hostvars['west']['accesstoken']['token'] }}"
kubeconfig: "{{ kubeconfig }}"
namespace: "{{ namespace }}"End-to-End Test Scenarios
Located in human/skupper/tests/e2e/scenarios/. These are comprehensive test playbooks that demonstrate various Skupper features and use cases.
1. Hello World Test
Directory: scenarios/hello-world/
Purpose: Basic Skupper connectivity test between two Kubernetes clusters.
Resources deployed:
- West cluster: Frontend application, Site, Listener for backend service
- East cluster: Backend application, Site, Connector to backend
Skupper resources:
# west/site.yml
apiVersion: skupper.io/v2alpha1
kind: Site
metadata:
name: west
spec:
linkAccess: default
# west/listener.yml
apiVersion: skupper.io/v2alpha1
kind: Listener
metadata:
name: backend
spec:
port: 8080
host: backend
routingKey: e2e-backend
# east/connector.yml
apiVersion: skupper.io/v2alpha1
kind: Connector
metadata:
name: backend
spec:
routingKey: e2e-backend
port: 8080
selector: app=backendTest flow:
- Environment validation (
e2e.tests.env_shakeoutrole) - Namespace generation (
e2e.tests.generate_namespacesrole) - Create Skupper resources for both sites using
skupper-sites.ymlinclude - Issue AccessToken from west site (
skupper.v2.tokenmodule) - Apply token to east site (
skupper.v2.resourcemodule) - Run connectivity test (
e2e.tests.run_curlrole) - Teardown (automatic cleanup)
Key variables:
namespace_prefix: Base for generated namespace namesnamespace_name: Site-specific namespace suffixrun_curl_address: Target endpoint for connectivity testskip_teardown: Skip cleanup (default: false)
2. Redis Multicloud High Availability Test
Directory: scenarios/redis/
Purpose: Demonstrate distributed Redis with Sentinel across three Kubernetes clusters plus Podman.
Architecture:
- West, East, North: Kubernetes clusters with Redis Server + Sentinel
- Podman site: Non-Kubernetes environment connected via Skupper
- Connectivity: Hub-and-spoke from west to east, north, and podman
What it demonstrates:
- Multi-site connectivity (4 sites)
- Mixed platform deployment (Kubernetes + Podman)
- Stateful service networking (Redis with Sentinel failover)
- Multiple Listeners and Connectors per site
skupper.v2.systemmodule for Podman sites
Test phases:
- Kubernetes setup: Sites, namespaces, Redis deployments
- Service networking: Listeners and Connectors for Redis and Sentinel
- Site linking: West issues token, east/north redeem
- Podman setup: Network creation, site initialization, token redemption
- Validation: Wait for pod readiness and site connectivity
- Teardown: Cleanup across all platforms
Podman-specific tasks:
- name: Create Skupper podman network
containers.podman.podman_network:
name: skupper
state: present
- name: Create Skupper sites resources
skupper.v2.resource:
path: "{{ playbook_dir }}/resources/podman/"
platform: podman
- name: Apply access token
skupper.v2.resource:
def: "{{ hostvars['west']['west_token']['token'] }}"
platform: podman
- name: Initialize default namespace using podman
skupper.v2.system:
action: start
platform: podman3. Labels and Annotations Test
Directory: scenarios/labels-and-annotations/
Purpose: Validate Skupper’s ConfigMap-driven label and annotation propagation.
Test scenarios:
- Pre-existing component: ConfigMap applied after Site creation → labels/annotations added
- New component: ConfigMap exists before Site creation → labels/annotations present immediately
- Removal: ConfigMap deleted → labels/annotations removed from all components
What it demonstrates:
- Dynamic component labeling via ConfigMap
- Skupper controller reconciliation behavior
- Validation using
kubernetes.core.k8s_infomodule
Test pattern:
- name: Deploy site before ConfigMap (Scenario 1)
skupper.v2.resource:
path: "{{ playbook_dir }}/resources/east/site.yml"
namespace: "{{ namespace }}"
- name: Apply ConfigMap with custom labels/annotations
kubernetes.core.k8s:
state: present
definition: "{{ lookup('file', 'configmap.yml') | from_yaml }}"
- name: Wait and verify labels appear
kubernetes.core.k8s_info:
kind: Deployment
namespace: "{{ namespace }}"
label_selectors:
- "custom-label=custom-value"
- name: Delete ConfigMap
kubernetes.core.k8s:
state: absent
# ...
- name: Verify labels removed
# Assertion task4. Service Scale Test
Directory: scenarios/service-scale/
Purpose: Stress-test Skupper with large numbers of Listener/Connector pairs.
Scale dimensions:
- Number of Listeners (configurable, default varies)
- Number of Connectors (matches Listener count)
- All pairs route to single backend (differentiated by routing keys)
What it demonstrates:
- Dynamic resource generation at scale
- Performance validation under load
- Readiness polling for bulk resources
Key variables:
service_count: 100 # Number of Listener/Connector pairs
service_name_prefix: svc
routing_key_prefix: svc
base_listener_port: 10080 # Incremented per service
backend_port: 8080
smoke_test_index: 1 # Which service to curl for validationDynamic resource creation:
- name: Create N Listeners
skupper.v2.resource:
def:
apiVersion: skupper.io/v2alpha1
kind: Listener
metadata:
name: "{{ service_name_prefix }}{{ item }}"
spec:
port: "{{ base_listener_port + item }}"
routingKey: "{{ routing_key_prefix }}{{ item }}"
loop: "{{ range(1, service_count + 1) | list }}"
- name: Create N Connectors
skupper.v2.resource:
def:
apiVersion: skupper.io/v2alpha1
kind: Connector
metadata:
name: "{{ service_name_prefix }}{{ item }}"
spec:
port: "{{ backend_port }}"
routingKey: "{{ routing_key_prefix }}{{ item }}"
selector: "{{ backend_app_label }}"
loop: "{{ range(1, service_count + 1) | list }}"5. Attached Connector Test
Directory: scenarios/attached-connector/
Purpose: Validate network connectivity and performance using iPerf3 and Skupper’s Attached Connector feature.
Architecture:
- Hub site: Central Skupper site managing connections
- Client site: Runs iPerf3 client
- Workload site: Runs iPerf3 server
What it demonstrates:
- Attached Connectors (direct workload-to-router attachment)
- Performance testing integration (iPerf3)
- Three-site topology (hub-and-spoke)
6. Expose Pods by Name Test
Directory: scenarios/expose-pods-by-name/
Purpose: Demonstrate exposing individual pods rather than services.
What it demonstrates:
- Pod-level service exposure
- Connector targeting specific pod names
- Use cases for stateful workloads or debugging
7. High Availability (HA) Test
Directory: scenarios/ha/
Purpose: Validate Skupper’s high availability and failover capabilities.
What it demonstrates:
- Multiple router instances per site
- Automatic failover on router failure
- Persistent connectivity during disruptions
Common Ansible Patterns
Pattern 1: Resource Application
Use skupper.v2.resource for all Skupper YAML resources:
- name: Apply resources from directory
skupper.v2.resource:
path: "{{ playbook_dir }}/resources/west/"
kubeconfig: "{{ kubeconfig }}"
namespace: "{{ namespace }}"
- name: Apply inline resource definition
skupper.v2.resource:
def:
apiVersion: skupper.io/v2alpha1
kind: Site
metadata:
name: my-site
spec:
linkAccess: default
kubeconfig: "{{ kubeconfig }}"
namespace: "{{ namespace }}"
- name: Delete resources
skupper.v2.resource:
state: absent
path: "{{ resources_path }}"
kubeconfig: "{{ kubeconfig }}"
namespace: "{{ namespace }}"Pattern 2: Token Generation and Redemption
# Site A: Generate token
- name: Create access token
skupper.v2.token:
name: "site-a-grant"
redemptions_allowed: 1
namespace: "{{ namespace }}"
kubeconfig: "{{ kubeconfig }}"
register: site_a_token
# Site B: Redeem token
- name: Apply access token
skupper.v2.resource:
def: "{{ hostvars['site-a']['site_a_token']['token'] }}"
namespace: "{{ namespace }}"
kubeconfig: "{{ kubeconfig }}"Pattern 3: Cross-Host Variable Access
Use hostvars to share data between inventory hosts:
# Playbook against host "west"
- hosts: west
tasks:
- name: Generate token
skupper.v2.token:
name: west-grant
register: my_token
# Playbook against host "east"
- hosts: east
tasks:
- name: Use token from west
skupper.v2.resource:
def: "{{ hostvars['west']['my_token']['token'] }}"Pattern 4: Conditional Execution by Host
- name: Task runs only on west
skupper.v2.token:
name: west-grant
when: "'west' in inventory_hostname"
- name: Task runs only on east
skupper.v2.resource:
def: "{{ token }}"
when: "'east' in inventory_hostname"Pattern 5: Non-Kubernetes Platforms
For Podman, Docker, or Linux sites:
- name: Start Podman site
skupper.v2.system:
action: start
platform: podman
site_config_path: "{{ playbook_dir }}/podman-site.yaml"
- name: Apply resources to Podman
skupper.v2.resource:
path: "{{ playbook_dir }}/resources/"
platform: podman
- name: Stop Podman site
skupper.v2.system:
action: stop
platform: podmanReusable Roles
Located in human/skupper/tests/e2e/collections/ansible_collections/e2e/tests/roles/:
e2e.tests.env_shakeout
Validates the test environment before proceeding.
What it checks:
- Cluster connectivity
- Required Kubernetes API access
- Ansible collection availability
e2e.tests.generate_namespaces
Creates isolated namespaces for test runs.
Variables:
namespace_prefix: Prefix for generated namespacesgenerate_namespaces_namespace_label: Label for cleanup identification
e2e.tests.run_curl
Executes connectivity tests via curl.
Variables:
run_curl_address: Target URLrun_curl_image: Container image for curl podrun_curl_retries: Number of retry attemptsrun_curl_delay: Delay between retries (seconds)
e2e.tests.pod_wait
Waits for pods to reach Running state.
Variables:
pod_wait_namespace: Target namespacepod_wait_label_selector: Label selector for podspod_wait_timeout: Timeout in seconds
e2e.tests.skupper_test_images
Manages test container images.
Provides variables:
skupper_test_images_lanyard: Image for HTTP testing
rescue
Error recovery and cleanup tasks.
Running the Examples
Prerequisites
-
Install Ansible (2.15+):
pip install ansible -
Install required collections:
ansible-galaxy collection install skupper.v2 ansible-galaxy collection install kubernetes.core ansible-galaxy collection install containers.podman # For Podman examples -
Install Python dependencies:
pip install -r https://raw.githubusercontent.com/skupperproject/skupper-ansible/refs/heads/main/requirements.txt
Running Hello World Example
cd /path/to/skupper-example-ansible
ansible-galaxy collection install skupper.v2
ansible-playbook -i ansible/inventory.yml ansible/setup.yml
# Test the application
ansible-playbook -i ansible/inventory.yml ansible/teardown.ymlRunning E2E Tests
cd human/skupper/tests/e2e/scenarios/hello-world
ansible-playbook -i inventory/ test.yml
# Skip teardown for debugging
ansible-playbook -i inventory/ test.yml -e skip_teardown=true
# Override kubeconfig paths
ansible-playbook -i inventory/ test.yml \
-e kubeconfig_1=/path/to/west.kubeconfig \
-e kubeconfig_2=/path/to/east.kubeconfigKey Differences: Production vs. E2E Tests
| Aspect | Production Examples | E2E Tests |
|---|---|---|
| Purpose | Demonstrate real-world usage | Validate Skupper functionality |
| Scope | Single scenario (e.g., Hello World) | Multiple scenarios with variations |
| Cleanup | Manual (via teardown playbook) | Automatic (via always block) |
| Namespace management | User-provided | Auto-generated with labels |
| Validation | User-driven (port-forward, curl) | Automated (roles like run_curl) |
| Inventory | Simple, two hosts | Complex, with extensive variables |
| Resource structure | Bundled YAML files | Separated by site and resource type |
Best Practices from the Examples
-
Use inventory variables: Define
kubeconfig,namespace, andresources_pathper host for flexibility. -
Leverage hostvars: Share data (like tokens) between hosts without external files.
-
Modularize with includes: Use
include_tasksorinclude_rolefor repeated operations (e.g.,skupper-sites.yml). -
Always block for cleanup: Wrap test tasks in a
blockwith analwayssection for guaranteed teardown. -
Label resources: Use labels like
e2e.idfor bulk cleanup via label selectors. -
Wait for readiness: Use
kubernetes.core.k8s_infowith retries before testing services. -
Conditional tasks: Use
when: "'hostname' in inventory_hostname"for host-specific tasks. -
Platform abstraction: Use the
platformparameter (kubernetes,podman,docker,linux) for cross-platform playbooks.
Troubleshooting
Common Issues
-
Module not found:
ansible-galaxy collection install skupper.v2 --force -
Python dependencies missing:
pip install kubernetes pyyaml jinja2 -
Token redemption fails:
- Verify the token was registered:
debug: var=hostvars['source-host']['token_var'] - Check network connectivity between sites
- Ensure
linkAccess: defaultin Site spec
- Verify the token was registered:
-
Resources not deleted:
- Check for
state: absentinskupper.v2.resource - Verify the
pathordefmatches creation task - For namespace-level cleanup:
kubernetes.core.k8swithstate: absent
- Check for
-
Test results location:
- E2E tests store artifacts in
/tmp/ansible.<hostname>/ - Check
ansible.logfor detailed error messages
- E2E tests store artifacts in
Source References
- Production example:
scripts/skewer-yamls/skupper-example-ansible.yaml - E2E tests:
human/skupper/tests/e2e/scenarios/ - Ansible collection: https://galaxy.ansible.com/ui/repo/published/skupper/v2/
- Collection source: https://github.com/skupperproject/skupper-ansible
- Requirements: https://raw.githubusercontent.com/skupperproject/skupper-ansible/refs/heads/main/requirements.txt
Related Documentation
- skupper-ansible-overview - Overview of the Skupper Ansible collection
- skupper-ansible-module-resource - Resource module reference
- skupper-ansible-module-token - Token module reference
- skupper-ansible-module-system - System module reference (Podman/Docker/Linux)
- skupper-ansible-module-controller - Controller module reference
- skupper-ansible-workflow-kubernetes - Kubernetes workflow guide
- skupper-ansible-workflow-mixed-sites - Mixed-platform workflow guide
- skupper-ansible-workflow-non-kubernetes - Non-Kubernetes workflow guide