I'm trying to put together a fabric script that creates a virtual instance via an API and then runs puppet on that instance. I've got a task that creates the VM, and a task that can 'bootstrap' the VM. However, I'm having difficulty linking these together, because I'm not sure how to pass the some data generated in the first task into the second task as the hostname. E.g.
def createVM():
newhostname = local('/usr/bin/createVM')
bootstrap(newhostname)
def bootstrap(hostname):
env.hosts = [hostname]
run('puppet agent -t')
This doesn't appear to work, and I get prompted for the hostname to run the fabric script on, if I just execute fab createVM
.
What's the best way of doing this?