Hello all, I have an API call, called by Ansible module. I want that this
JSON loop 'n' times with differents values. This is the JSON:
> {
> "name": "{{hostname}}",
> "links": [
> {
> "href": "https://xxxxxxxxxx.ixxi-servicios.com/api/admin/enterprises/2",
> "rel": "enterprise"
> },
> {
> "href":
> "https://cxxxxxxter.xxxx-serxxxvicios.com/api/admin/enterprises/2/datacenterrepositories/1/virtualmachinetemplates/{{id_template.stdout}}",
> "rel": "virtualmachinetemplate"
> },
> {
> "title":"{{ip}}",
> "rel":"nic1",
> "type":"xxxx/vnd.xxxxx.externalip+json",
> "href":
> "https://xxxxxx.xxxx-xxxxxx.com:443/api/admin/enterprises/2/limits/2/externalnetworks/{{id_vlan.stdout}}/ips/{{id_ip.stdout}}"
> }
> ],
> "variables": {
> "net-ip0": "{{ip}}",
> "net-mask0": "{{netmask}}",
> "net-gw0": "{{gateway}}",
> "hostname": "{{hostname}}"
> },
> "ram": "{{ram}}",
> "cpu": "{{cpu}}",
> "description": "{{hostname}}"
> }
>
>
The values that must vary the value are:
- {{id_template.stdout}}
- {{id_vlan.stdout}}
- {{id_ip.stdout}}
- {{ip}}
- {{netmask}}
- {{gateway}}
I will use this to add some ethernet interfaces into VM. This vars are
defined in other file like this:
hostname: 'prueba'
cpu: '1'
ram: '1024'template: 'CENTOS_6.5_AUTO'
nic:- nic: nic1
ip: '192.168.1.1'
netmask: '255.255.255.192'
gateway: '192.168.1.1'
vlan: 'vlan1'- nic: nic2
ip: '192.168.1.2'
netmask: '255.255.255.192'
gateway: '192.168.1.4'
vlan: 'vlan2'
The loop should be use this information to insert in the JSON this vars as
many times as the number of nic we have.
any ideas?
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/9f1dd9ff-b3f0-42d9-99c6-2ad7c73ddca3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.