What's the best way to copy over a file depending on a hostname?
I need to copy over files with different content but with the same filename to several machines.
I have several files:
file.role1
file.role2
file.role3
Depending on hostname and/or role, I'd like like to copy file.roleX
and rename it to file
Thanks.
There are many ways to do this. Simplest:
Alternative, more compact:
Or, using a template:
where the template can be something like this:
If you want different files in different roles, why don't you simply put this:
in each role's code?
There is no preferred way to do it - it depends on what you are actually trying to accomplish.