Thursday, November 8, 2018

Span the inventory to multiple files

Below is the basic structure with folders and variable files.



Variable file example.



We can use below command to use this inventory file with variables used as {{}} braces.
Goto the production folder using cd and type below command.


If you get any access denied error, use --sudo  at the end.
The all is available for all members in the inventory file of production.

in group_vars folder, all is for all machines in inventory and other files like db above are created based on the group.

Similarly, host_vars is for machine specific.And file names are created with machine names.

You can run above command for group webservers, and precendence will be taken based on these values.




No comments:

Post a Comment