ansible concatenate variables

Hello,

I have simple question about concatenating variables in Ansible.

I am using a role https://github.com/singleplatform-eng/ansible-users . I would like to define root user in group_vars/all . It works well.

The problem is, when I would like to specify additional users for group of machines, or single host. If I define users variable, then the users in group_vars/all variable is not seen.

Is there any way to concatenate the variables in this scenerio?

Best Regards,

Krzysztof Kulaj

Variables are lazy loaded so :

vars:
  x: '{{ x + [1] }}'

will not work since the value of x is not known before you try to use
x creating a self referential loop.

But you can get around it with `set_fact` as we evaluate variables at
the time of module execution and set_fact is a module that sets a new
variable:

set_fact:
    x : '{{ x + [1] }}'

this defines a 'new x' that is the 'old x + [1]' (add a list with the
number 1 as an element, assumes x is already a list, you might use