# Add Variable to Groups of Inventories in the inventories for AAP/AWX

**URL:** <https://forum.ansible.com/t/add-variable-to-groups-of-inventories-in-the-inventories-for-aap-awx/6274>\
**Category:** Get Help\
**Tags:** windows, aws, awx\
**Created:** [June 10, 2024, 12:05pm UTC](https://forum.ansible.com/t/add-variable-to-groups-of-inventories-in-the-inventories-for-aap-awx/6274 "2024-06-10T12:05:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![valkiriaaquatica](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/valkiriaaquatica/32/1308_2.png) [@valkiriaaquatica](https://forum.ansible.com/u/valkiriaaquatica)\
**Post date:** [June 10, 2024, 12:05pm UTC](https://forum.ansible.com/t/add-variable-to-groups-of-inventories-in-the-inventories-for-aap-awx/6274/1 "2024-06-10T12:05:52Z")

</div>

Hi, using AAP there is this module ansible.controller.group that lets you create,delete, update groups and add variables to the groups.  
For the moment I have used it for creating specific windows groups with special vars as si shown below in the example

```auto
- name: Add groups with vars
  ansible.controller.group:  
    name: "windows_group"
    description: "I am a group_var for Windows"
    inventory: "AWS"
    state: present
    variables:
      psrp_proxy_host: "host.net"
      psrp_proxy_port: "12345"
      another_variable: "windows"

```

The thing is that i was looking to instead with a playbook this was possible to do in the same inventory, I mean, the creation of the group is fine but I do not find any way of adding the variables to the group. I’ve tried with the followings (in amazon.aws.aws\_ec2 but the group creation comes from the default Ansible Python code that uses all inventories, so should be the same for most inventories).

```auto
groups:
  test_group:
    variables:
      account_type: "development"

```

```auto
groups:
  test_group:
    vars:
      account_type: "development"

```

```auto
groups:
  test_group:
      account_type: "development"

```

They are creating the groups but no adding the vars. I wrote “variables” as the dictionary because queryig the AAP API I got this response of a group that has variables

{

```auto

    "id": 1111,
    "type": "group",
    "url": "/api/v2/groups/1111/",
    "related": {
    "variables": "{\"psrp_proxy_host\": \"host.nett\", \"psrp_proxy_port\": \"1111\",}"
}

```

Thanks in advanced!
