we want to use etcd with the "watch" function to change our "/etc/hosts" file. A node should change the value and the watch should then write the change in "/etc/hosts".
Node1 Input:
etcdctl put master-server "192.168.10.1 master-server.int.server.io"
Node2 Watch:
etcdctl watch master-server | head -3 | tail -1 | tee >> hosts.file
Node2 Output:
192.168.10.1 master-server.int.server.io
This works fine but now i want a output with multiple lines like this: Node 2 Output:
192.168.10.1 master-server.int.server.io
192.168.10.2 slave1-server.int.server.io
192.168.10.3 slave2-server.int.server.io
My thought was:
etcdctl put master-server "192.168.10.1 master-server.int.server.io \n192.168.10.2 slave1-server.int.server.io \n192.168.10.3 slave2-server.int.server.io"
But it doesnt work.
The Output is:
192.168.10.1 master-server.int.server.io \n192.168.10.2 slave1-server.int.server.io \n192.168.10.3 slave2-server.int.server.io
Does anyone know the best way to handle my problem? And how do I get multiple lines into a value?
Thanks for your Help.
Does the following do what you want?
and to read it back: