'Invalid template' returned by AWX

hi All

I have one external application, which is much easier GUI interface for less experience engineers, compare to the much more complexity of AWX GUI.

Basically this application is using Python towerlib (GitHub - schubergphilis/towerlib: A python library to interface with ansible tower's (awx) api.) to send the HTTP request to AWX to execute a AWX template. AWX will return the output of template executed to this application.

Most of my templates are running fine, but I have some templates which can’t be executed from this application successfully.

  1. I have AWX template A and B, both are the same inventory and the same credential, the same Team (group).
  2. Both A and B can be executed successfully when directly executed from AWX GUI, run by the same user.
  3. Template A can be executed successfully from my own application to AWX. But Template B can’t be executed from my own application towards AWX, and with Debug in Chrome, it seems that AWX is returning ‘Invalid template’ to my application.

The detailed JSON format data returned by AWX

//Success of template A

{
  "id": 1585,
  "options": [
    {
      "argument": {
        "id": 493,
        "awx_argument_name": "dest_ip",
        "multi_select": false,
        "argument_type": "text",
        "validation": "ip",
        "dropdowns": [],
        "max_length": 100,
        "required": true
      },
      "value": "8.8.8.8"
    }
  ],
  "jobs": [
    {
      "id": 1438,
      "hosts": [
        {
          "awx_host_id": 48,
          "hostname": "test.test.net"
        }
      ],
      "inventory": {
        "id": 10,
        "awx_inventory_id": 3,
        "name": "Production_Monboxes"
      },
      "awx_job_id": 1010,
      "status": "Unknown",
      "stdout": null,
      "created_at": null,
      "finished_at": null
    }
  ],
  "finished": false,
  "download_hash": "b973526b176b336df735d765c7a91733",
  "created_at": "2023-12-22T08:28:14.281440Z",
  "total_execution_time": null,
  "template": {
    "id": 1,
    "noc_groups": [
      {
        "awx_group_id": 2,
        "name": "QNOC"
      },
      {
        "awx_group_id": 1,
        "name": "NOC"
      }
    ],
    "arguments": [
      {
        "id": 493,
        "awx_argument_name": "dest_ip",
        "multi_select": false,
        "argument_type": "text",
        "validation": "ip",
        "dropdowns": [],
        "max_length": 100,
        "required": true
      },
      {
        "id": 494,
        "awx_argument_name": "count",
        "multi_select": false,
        "argument_type": "text",
        "validation": "dec",
        "dropdowns": [],
        "max_length": 100,
        "required": false
      },
      {
        "id": 495,
        "awx_argument_name": "quiet",
        "multi_select": false,
        "argument_type": "dropdown",
        "validation": "",
        "dropdowns": [
          {
            "value": "-q"
          }
        ],
        "max_length": 100,
        "required": false
      }
    ],
    "inventories": [
      {
        "id": 10,
        "awx_inventory_id": 3,
        "name": "Production_Monboxes"
      }
    ],
    "name": "Tshoot - Arping",
    "awx_template_id": 44,
    "created_at": "2022-03-11T09:47:46.364763Z",
    "created_by": 1
  },
  "created_by": {
    "first_name": "Test",
    "last_name": "Test"
  }
}

//Fail of template B

{
  "id": 1590,
  "options": [
    {
      "argument": {
        "id": 588,
        "awx_argument_name": "dest_ip",
        "multi_select": false,
        "argument_type": "text",
        "validation": "ip",
        "dropdowns": [],
        "max_length": 100,
        "required": true
      },
      "value": "8.8.8.8"
    }
  ],
  "jobs": [
    {
      "id": 1443,
      "hosts": [
        {
          "awx_host_id": 48,
          "hostname": "test.test.net"
        }
      ],
      "inventory": {
        "id": 10,
        "awx_inventory_id": 3,
        "name": "Production_Monboxes"
      },
      "awx_job_id": null,
      "status": "Invalid template",
      "stdout": null,
      "created_at": null,
      "finished_at": null
    }
  ],
  "finished": false,
  "download_hash": "c02f529f7fc083d6ddf78cfe37dc3320",
  "created_at": "2023-12-22T08:53:52.265769Z",
  "total_execution_time": null,
  "template": {
    "id": 43,
    "noc_groups": [
      {
        "awx_group_id": 2,
        "name": "QNOC"
      },
      {
        "awx_group_id": 1,
        "name": "NOC"
      }
    ],
    "arguments": [
      {
        "id": 588,
        "awx_argument_name": "dest_ip",
        "multi_select": false,
        "argument_type": "text",
        "validation": "ip",
        "dropdowns": [],
        "max_length": 100,
        "required": true
      }
    ],
    "inventories": [
      {
        "id": 10,
        "awx_inventory_id": 3,
        "name": "Production_Monboxes"
      }
    ],
    "name": "Tshoot - Ping",
    "awx_template_id": 20,
    "created_at": "2023-12-11T13:02:21.405041Z",
    "created_by": 7
  },
  "created_by": {
    "first_name": "Test",
    "last_name": "Test"
  }
}

You can see that for the success one, AWX returns an ‘awx_job_id’, but for the failed ones, AWX returns ‘Invalid template’

Any suggestion

  1. Under what condition will AWX return a ‘Invalid template’ ?
  2. Is there anyway I can check a bit more logs related to the whole execution process ? When a template can be called in AWX, I know we can find more logs by changing Verbosity level of the template. But in this case, the template can’t be even called in AWX

anyone can help here :slight_smile: or all are celebrating Christmas now ?

Merry Christmas to all engineers working hard on AWX :slight_smile:

I’m not exactly sure what you’re showing us up there. Are “1585” and “1590” the ids of the job templates you are trying to run? If so, what do you get if you go to “https://your.awx.instance/api/v2/job_templates/1585/” and “https://your.awx.instance/api/v2/job_templates/1590/”? Particularly the latter, as that’s the one that’s failing.

My guess would be that your AWX instance doesn’t have a job template with an id of 1590.

(Or maybe the job template ids are 1 and 43? In which case, substitute those numbers for 1585 and 1590 above, particularly the 2nd url.)

@utoddl thanks a lot for your answer, actually the awx template ID

"awx_template_id": 44,

and
“awx_template_id”: 20,

These two AWX template IDs do exist in my AWX. With http request to these two template IDs, I have got the 200 OK success for both, so this is the weird part.