Team,
I have json response from which am getting query with hosts name. I need to further take all goats names and ssh and run some command.
How can I achieve this? Please give complete syntax.
@Rahul Rameshbabu may be you can catch this?
basically, i have below task that yields above output..
k8s_facts:
kubeconfig: $WORKSPACE
kind: Node
label_selectors:
- nodeType=gpu
verify_ssl: no
register: gpu_node_info
#Form a list of dic with key value
- debug:
var: gpu_node_info | json_query(query)
vars:
query: 'resources[].{node_name: metadata.name}'
Output:
rfr *pulling dict value and ssh in loop to all the values*
"gpu_node_info | json_query(query)": [
{
"node_name": "host2"
},
{
"node_name": "host1"
}
]
}```
Below is my try to loop and ssh which fails
```- name: "Loop on all nodeNames and ssh."
shell: ssh \-F \~/\.ssh/ssh\_config bouncer@\{\{ item \}\}\.internal\.sshproxy\.net "name \-a"
register: ssh\_result\_per\_host
failed\_when: ssh\_result\_per\_host\.rc \!= 0
with\_items: "\{\{ var\.node\_name \}\}"
\- debug:
var: ssh\_result\_per\_host\.stdout\_lines\`\`\`