I'm querying an API with Ansible command
's command. The API returns a JSON object with network information.
I'd like to get a server's private ip based on its public ip. I know this is possible with JSON query filter but I can't figure out how.
The code:
- name: Get RPN topology
command: 'curl -X GET -H "Authorization: Bearer {{ onlineApiToken }}" "https://api.online.net/api/v1/rpn/group"'
register: RPN
delegate_to: 127.0.0.1
This is what RPN.stdout
output looks like:
TASK [debug] ****************************************************************************************
ok: [ps1] => {
"changed": false,
"msg": [
{
"id": 7406,
"members": [
{
"id": 0000,
"ip": "x.x.x.x",
"owner": "buzut",
"private_ip": "10.91.154.39",
"speed": 100,
"status": "active"
},
{
"id": 1111,
"ip": "y.y.y.y",
"owner": "buzut",
"private_ip": "10.91.120.148",
"speed": 100,
"status": "active"
},
{
"id": 2222,
"ip": "z.z.z.z",
"owner": "buzut",
"private_ip": "10.91.165.215",
"speed": 1000,
"status": "active"
}
],
"name": "MySQL",
"owner": "buzut",
"shared": false,
"status": "updating"
}
]
}
The question: how do I get a server's private ip, based on its public one?