在Kubernetes或OpenShift上使用Ansible运算符时,如何获取嵌套规范项的值?
我的OpenShift集群(kubernetes集群)中有一个自定义资源,如下所示。我希望使用operator SDK生成的Ansible运算符使用spec.storage.size和spec.storage.type的值。我该怎么做在Kubernetes或OpenShift上使用Ansible运算符时,如何获取嵌套规范项的值?,kubernetes,ansible,Kubernetes,Ansible,我的OpenShift集群(kubernetes集群)中有一个自定义资源,如下所示。我希望使用operator SDK生成的Ansible运算符使用spec.storage.size和spec.storage.type的值。我该怎么做 apiVersion: my.domain.com/v1alpha1
apiVersion: my.domain.com/v1alpha1
kind: MyApp
metadata:
name: my-myapp
spec:
storage:
size: 1Gi
type: persistent
存储yaml块作为散列传递给Ansible。您可以使用括号或点符号来查找值。在下面的几行中,我使用点表示法获得大小和括号表示法,以确定存储类型是否持久
- debug:
msg: "Requested size is {{ storage.size }}."
when: storage['type'] == "persistent"