Open etsauer opened 4 years ago
@etsauer for your two examples, what do you think about an applier inventory like the following? Does this align with what you were thinking?
openshift_cluster_content:
- object: Machine Autoscaler
content:
- name: Fetch cluster id from running cluster
action: get
get_vars:
kind: machinesets
namespace: openshift-machine-api
jsonpath: '{.items[0].metadata.labels.machine\.openshift\.io\/cluster-api-cluster}'
output_name: 'machinesets_output'
- name: Apply machine autoscaler template
template: "http://some-url.com/machineautoscaler-template.yaml"
namespace: openshift-machine-api
params_from_vars:
CLUSTER_ID: "{{ machinesets_output }}"
- object: Fetch and apply secret / token
content:
- name: Fetch builder SA secret name
action: get
get_vars:
kind: sa
name: builder
namespace: somenamespace
jsonpath: '{.secrets[0].name}'
output_name: 'builder_sa_secret_name'
- name: Fetch secret content based on secret name
action: get
get_vars:
kind: secret
namespace: somenamespace
name: "{{ builder_sa_secret_name }}"
jsonpath: '{.data.token}'
output_name: 'builder_sa_secret_content'
- name: Apply secret template
template: "http://some-url.com/secret-template.yaml"
params_from_vars:
TOKEN: "{{ builder_sa_secret_content }}"
@oybed yes that looks perfect
Related Ansible Galaxy role to "get" data: https://galaxy.ansible.com/oybed/openshift_get_resources
When writing automation for kubernetes, we often need the ability to grab the value of a field in a resource and use that value in another resource. Applier should support this. Here are a few examples I can think of:
Grab Cluster ID to feed into resources.
Copy a token between clusters