How do I run a function on multiple servers that contain my variable?
Ex:
I need to run this command on several servers.
server = ["server1com", "server2com", "server3com"]
{:ok, conn} = SSHEx.connect ip: '#{server}', user: 'myuser'
SSHEx.cmd! conn, 'mkdir -p /path/to/newdir'
How do I put this command in a loop, until the server list runs out?
Would it be this?
Note: It doesn’t work for me.
server = ["server1com", "server2com", "server3com"]
Enum.each(server, fn(_x) ->
{:ok, conn} = SSHEx.connect ip: '#{server}', user: 'myuser'
SSHEx.cmd! conn, 'mkdir -p /path/to/newdir'
end)