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
- 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).
groups:
test_group:
variables:
account_type: "development"
groups:
test_group:
vars:
account_type: "development"
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
{
"id": 1111,
"type": "group",
"url": "/api/v2/groups/1111/",
"related": {
"variables": "{\"psrp_proxy_host\": \"host.nett\", \"psrp_proxy_port\": \"1111\",}"
}
Thanks in advanced!