I have, what I think, is a complex task.
I have 1 machine we'll call a server and a whole bunch of other machines, hostX. They all run Ubuntu 16.04 server. Each host runs a simple bash script at startup, but that script currently has hard coded values. I would like to use variables within that script, but the variable values should be stored in files/a file on the server, allowing me to change values in one central place and affect a host, or a group of hosts. I'm happy that I'll have to either reboot, or restart the script on each host after a change, that's no problem. The issue I have is that I don't know how to use a variable from a remote machine, all I can find is info about running a script on a remote machine. I want it to run locally, but pull info from the remote.
So here's my work flow, in my head.
Host1 boots and looks at the contents of host1.cfg
located on the server.
host1.cfg
looks like this:
NAME=John
ADDRESS='10 The High Street'
AGE=25
Host1 runs:
echo server:$HOSTNAME.cfg:$NAME & $ADDRESS & $AGE
Or maybe have a central HOST.CFG
file with:
[HOST1]
NAME=John
ADDRESS='10 The High Street'
AGE=25
[HOST2]
NAME=Mike
ADDRESS='30 The Avenue'
AGE=80
Does that make sense?
rsync
orscp
to copy the config file over and then use it locally. Or read it with e.g.wget
orcurl
: https://stackoverflow.com/questions/8978261/how-can-i-cat-a-remote-file-to-read-the-parameters-in-bash – dessert Dec 09 '17 at 12:07Thanks
– Preston Cole Dec 09 '17 at 12:13