# Variable Management

**URL:** <https://forum.ansible.com/t/variable-management/34173>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [November 10, 2020, 9:05am UTC](https://forum.ansible.com/t/variable-management/34173 "2020-11-10T09:05:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marco\_Aurelio](https://avatars.discourse-cdn.com/v4/letter/m/3ec8ea/32.png) [@Marco\_Aurelio](https://forum.ansible.com/u/Marco_Aurelio)\
**Post date:** [November 10, 2020, 9:05am UTC](https://forum.ansible.com/t/variable-management/34173/1 "2020-11-10T09:05:47Z")

</div>

Hello everyone!

We’re currently preparing to set up our configuration management with Ansible from scratch. We have decided on using dynamic inventory for AWS with the _amazon.aws.aws\_ec2_ inventory plugin, grouping instances by their tags.

We need to install monit (which collects some metrics for monitoring) on all instances, but with different values for each of them. The point is, some values are common for all instances and some are specific.

For example, all instances should have a check for disk usage on the root mountpoint, but only a subset of hosts should check for the /var/cache mountpoint.

The monit role we want to use, however, wouldn’t allow us to specify common and specific values because it only accepts one variable with a list of checks.

That means if we set it up in the following way (pseudocode):

_# group\_vars/tag\_project\_myproject_  
_# All hosts are in this group_

_monit\_checks:_  
_- root filesystem_

_# group\_vars/tag\_group\_subset_  
_# not all hosts are in this group_

_monit\_checks:_  
_- var filesystem_

Only one of the values would apply. We don’t want to concern ourselves with merging variables inside our playbooks, as that feels hacky and cumbersome. What would be the appropriate way to achieve this with Ansible, that is, **how can we avoid duplicating the same variables on multiple hosts and specifying one common set of variables and performing overwrites as needed**?

Thank you!

Best,

Marco Godinho
