Ansible define an inventory list variable, looping through another list variable

Viewed 37

Imagine having a list in your inventory:

# inventory vars

list_a:
  - name: tttt
  - name: bbbb

Is there any possible solution to create a new variable using list_a to iterate on?

# inventory vars

list_a:
  - name: tttt
  - name: bbbb

list_b:
  - domain: "{{item.name}}.com"
    port: 833
special_syntax_loop_on: list_a # any way to iterate on this?

Note1: Using set_fact in a playbook will solve this issue, but as this project is very big, writing a small portion of code that changes such important variable in a unkown sub file to other developers, will create much complexity, so the solution must use the top level inventory file...

Note2: If you asked yourself, why didn't he just put .com on the list_a in the first place? cause this is a simplified version of the problem, there is a variable named nginx and this is defined on multiple group_vars inventory files, therefor one variable with different contents, and the problem here is that my prometheus server needs to know all of these values, so I am trying to create a list of servers and domains in my prometheus variable and the create respective nginx variable list in each group_vars from the prometheus variable...

0 Answers
Related