awx job_templates launch: argument --instance_groups: invalid int value: ‘[3]’
Dear Ansible community,
I am trying to trigger awx cli with --instance_groups argument, I tried with [3] but it is not working
My AWX and Ansible versions are
AWX version : AWX 23.8.1
ansible --version
ansible [core 2.15.13]
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.9.17 (main, Aug 9 2023, 00:00:00) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True
awx --conf.host [https://awx.us-XXXX.io](https://awx.us-xxxx.io/) --conf.username XXXXX --conf.password XXXX job_templates launch --name XXXXX --extra_vars '{"build_environment”:”XXXX”}’ --inventory XXXX --limit XXXX.com --instance_groups=[3]
Error : awx job_templates launch: argument --instance_groups: invalid int value: '[3]'
I tried with many other options but nothing works. Please respond and help me with this.
@kurokobo , can you please check if you can help me on this one ?
kurokobo
(kurokobo)
April 4, 2025, 2:55pm
3
I haven’t been able to investigate this deeply, but I think it’s likely a bug.
The awxkit treats arguments according to the API specifications, and instance_groups
is indicated as a field
type:
However, the field
type seems to be treated as an int
on the awxkit side:
path = os.path.expanduser(v[1:])
parsed[k] = open(path).read()
return parsed
kwargs = {
'help': help_text,
'required': required,
'type': {
'string': str,
'field': int,
'integer': int,
'boolean': strtobool,
'id': functools.partial(pk_or_name, self.v2, k),
'json': json_or_yaml,
'list_of_ids': functools.partial(pk_or_name_list, self.v2, k),
}.get(param['type'], str),
}
meta_map = {
'string': 'TEXT',
'integer': 'INTEGER',
So, actually we need to pass an array to --instance_groups
, but int
is not an array, so there seems to be no way to handle this.
I recommend invoking the job template with the pure REST API instead of awxkit, or assigning the instance groups to the job template first by REST API, and then invoking it by awxkit.
kurokobo
(kurokobo)
April 4, 2025, 3:00pm
4
@djyasin
Hi, I saw that you wrote “I tested” this feature in this issue:
opened 12:23PM - 01 Jan 25 UTC
closed 04:13PM - 26 Feb 25 UTC
type:bug
needs_triage
community
### Please confirm the following
- [X] I agree to follow this project's [code o… f conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html).
- [X] I have checked the [current issues](https://github.com/ansible/awx/issues) for duplicates.
- [X] I understand that AWX is open source software provided for free and that I might not receive a timely response.
- [X] I am **NOT** reporting a (potential) security vulnerability. (These should be emailed to `security@ansible.com` instead.)
### Bug Summary
I've configured "Prompt on launch" on instance Groups. Everything work fine when I launch job template via UI
However when I tried to specific instance group on launch command.
```
awx job_template launch <name> \
--instance_groups="4"
```
I always get below error in return. What is the correct format to specific instance groups on awx cli?
```
{"instance_groups": ["Expected a list of items but got type \"int\"."]}
```
### AWX version
24.6.1
### Select the relevant components
- [ ] UI
- [ ] UI (tech preview)
- [ ] API
- [ ] Docs
- [ ] Collection
- [X] CLI
- [ ] Other
### Installation method
kubernetes
### Modifications
no
### Ansible version
_No response_
### Operating system
_No response_
### Web browser
_No response_
### Steps to reproduce
Create new job template and select "Prompt on launch" on instance Groups".
Use awx cli to launch job template and specific instance group ID e.g. 4.
```
awx job_template launch <name> \
--instance_groups="4"
```
### Expected results
We can submit launch request without issue.
### Actual results
Got below error in return.
```
{"instance_groups": ["Expected a list of items but got type \"int\"."]}
```
### Additional information
_No response_
but I (and @SaravanaSelvaraj ) couldn’t get it to work.
If it seems like we’re going down the wrong path, please let me know.