I am trying to execute launch_template
API through Python and send extra_vars
as JSON payload as per API documentation. But extra_vars
are not working and template execution gets failed.
def execPlaybookAWX():
AWX_API = "http://<AWX_SERVER>/api/v2/job_templates/15/launch/"
payload = {
"vcenter_dest_folder": "POC-VM-Build-Auto",
"vcenter_datacenter": "TUL1_Lab",
"vcenter_cluster": "Management",
"vm_annotation": "Test VM 2 created using ansible...",
"vm_template": "POC-VM-Build-Auto-Template",
"vm_disk_datastore": "tul1virt152-VM-01",
"vm_vlan_net": "VLAN66 10.151.66.0/23",
"vm_hw_mem_mb": 4096,
"vm_hw_cpu_n": 2,
"vm_disk_size_gb": 25,
"guest_hostname": "tul1itt-vmpoc-l09",
"guest_domain": "test.com",
"vm_net_mask": "255.255.255.0",
"vm_net_gw": "10.10.1.0",
"Network": "10.10.1.0/24",
"vcenter_ip": "tul1ittvmvc2.corporate.local",
"vcenter_username": "USER",
"vcenter_password": "<PASS>",
"ipv4addr": "10.10.1.0"
}
response = requests.post(AWX_API, json={"extra_vars": payload},
auth=HTTPBasicAuth('USER', 'PASS'))
print(response)
The following error it shows:
I tried based on the docs, Launch a Job Template but its not working.
Can anyone give solution for this ?