Loop until k8s (lookup/query) module returns a valid value

39 views
Skip to first unread message

Thms Hmm

unread,
Aug 15, 2019, 11:21:27 AM8/15/19
to Ansible Project
Ansible Version: 2.8.1

Hi,

I'm trying to get the status of a Kubernetes StatefulSet and wait till it has a specific value.

The task looks like this:
- set_fact:
    myVar
: "{{ query('k8s', host='myhost.local', ... kind='StatefulSet', label_selector='app=test') }}"
  retries
: 5
  delay
: 30
 
until: "myVar[0]['status']['readyReplicas']|int == 3"

The problem I have is, the loop is executed but the "myVar" variable is never updated and has it's initial value.

Has anyone seen or tried this? Is there an alternative?

Thomas
Reply all
Reply to author
Forward
0 new messages