This may be a stupid idea but I have two identical playgrounds for my ansible script.
I want to create a playbook with a Inventory containing two groups and choose the ip from the host via group is this possible? I'm needing it because the frontend and backend needed the same host_vars in both groups but are different server.
host_vars:
frontend.yml ( in host_vars):
frontent_property=look good
backend .yml ( in host_vars):
backend_property=handle requests
group_vars:
integration.yml ( in group_vars):
integration_property=have fun
production.yml ( in group_vars):
production_property=do business
Inventory:
frontend
backend
[integration]
frontend ansible_host=10.0.0.5
backend ansible_host=10.0.0.6
[production]
frontend ansible_host=10.1.0.5
backend ansible_host=10.1.0.6
Playbook:
- hosts: integration
gather_facts: false
tasks:
- debug:
msg: "{{ ansible_host }}"
- hosts: production
gather_facts: false
tasks:
- debug:
msg: "{{ ansible_host }}"
This didn't work (both are running against the integrations ips )- is there another solution to solve this?
I have found a solution but now I'm loosing the host_vars :
group_vars: frontend.yml ( in group_vars):
frontent_property=look good
backend.yml ( in group_vars):
backend_property=handle requests
integration.yml ( in group_vars):
integration_property=have fun
production.yml ( in group_vars):
production_property=do business
Inventory:
10.0.0.5
10.0.0.6
10.1.0.5
10.1.0.6
[frontend]
10.0.0.5
10.1.0.5
[backend]
10.0.0.6
10.1.0.6
[integration]
frontend
backend
[production]
frontend
backend
But its more likly that I made a mistake, because I'm not using the :children specifier (Group in Group) so I don't think that the group values from [backend] are accessible from the scope [integration]/production or am I wrong?