From Harmless Stork, 2 Weeks ago, written in YAML.
  1.    - name: Create job template
  2.       uri:
  3.         url: https://{{ inventory_hostname }}/api/job_templates
  4.         method: POST
  5.         body: |
  6.          {
  7.             "job_template": {
  8.               "name": "Ansible Roles - Ansible Default with env.* parameters",
  9.               "job_category": "Ansible Playbook",
  10.               "template": "{{ lookup('file', 'ansible_default_with_env.erb') }}",
  11.               "provider_type": "Ansible",
  12.               "locations": [{{ loc_id }}],
  13.               "organizations": [{{ org_id }}]
  14.             }
  15.           }
  16.         status_code:
  17.          - 201
  18.           - 422
  19.       register: response
  20.       changed_when: response.status == 201
  21.       failed_when: response.status != 422 and response.status != 201
captcha