简体   繁体   中英

Ansible Tower: 'extra_vars' with multiple variables are ignored when running with curl in cmd

Can some one tell how to pass multiple extra_vars variables from the command line which will run the Job Template in Tower?

I've followed Ansible documentaion https://docs.ansible.com/ansible-tower/latest/html/userguide/job_templates.html#passing-extra-variables-to-provisioning-callbacks

curl -f -H 'Content-Type: application/json' -XPOST \
                  -d '{"host_config_key": "efref3d9-740f-429c-43r2-15t326b76", "extra_vars": "{\"Job_ID\": \"24\"},{\"job_templates\": \"test99\"}"}' \
                  https://tower-ansible.com:443/api/v2/job_templates/822/callback/ -k

For single variable it's working. Below curl command works with single extra variable

curl -f -H 'Content-Type: application/json' -XPOST     -d '{"host_config_key": "efref3d9-740f-429c-43r2-15t323b76", "extra_vars": "{\"job_id\": \"24\"}"}'     https://tower-ansible.com:443/api/v2/job_templates/822/callback/ -k

According the documentation about Passing Extra Variables to Provisioning Callbacks you have referenced you may

Use the following JSON format as an example when adding your own extra_vars to be passed

"extra_vars": {"variable1":"value1","variable2":"value2",...}

instead of as in your provided example

"extra_vars": {"variable1":"value1"},{"variable2":"value2"}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM