Good afternoon. Hope all is well. This is my first post here though I’ve been lurking for several months. Apologies in advance if this is the incorrect forum.
I am trying to target multiple k8s/OpenShift clusters with a playbook. Using the examples, I can successfully target a single remote cluster:
-
hosts: localhost
module_defaults:
group/k8s:
host: https://api.cluster001.digitalhermit.com:6443
ca_cert: /path/to/cluster001.digitalhermit.com.crt
validate_certs: no
tasks: -
block:
-
name: Log in (obtain access token)
k8s_auth:
username: “{{ k8s_admin_username }}”
password: “{{ k8s_admin_password }}”
register: k8s_auth_results -
name: Do something
This snippet works for the most part (though I am getting python TLS warnings).
What I’m trying to do is target multiple OCP clusters.
I can use a variable for the host name:
module_defaults:
group/k8s:
host: “{{ k8s_cluster_name }}”
ca_cert: /path/to/cluster001.digitalhermit.com.crt
And call with:
ansible-playbook foo.yaml -e “k8s_cluster_name=https://api.cluster001.foo.com:6443”
This works. However, I’m looking for a way to pass a list of clusters and run the playbook in parallel across them.
I tried with an inventory file, but this seems to only specify where the playbooks run, not the target clusters.
Is there an example somewhere that shows how to target multiple separate clusters?
Thanks,
KL