I know I can assign hosts with fabric by doing this:
env.hosts = ['host1', 'host2']
But can I do this?
myList = ['host1', 'host2']
env.hosts = myList
I am getting a list of 'public_dns_name's using Boto (from Amazon AWS) and then want to run commands on those servers. The server list can be dynamic so I need to be able to assign the hosts environment variable rather than statically. Can anyone suggest a solution?
myHosts = []
for i in myInstances:
publicDnsAddress = i.public_dns_name
myHosts.append(i.public_dns_name)
print ("public dns address: " + publicDnsAddress)
print ("myHosts = " + str(myHosts))
env.hosts=myHosts
env.user='myUser'
run("/scripts/remote_script.py")
I get this error:
No hosts found. Please specify (single) host string for connection:
If the host names were bad I would expect at least a connection error rather than a message saying it could find no hosts. Granted I may be calling this thing wrong but then again, that is why I am asking for help.