I'm trying to leverage the provisioning feature of this plugin to collect the user input during provisioning but I am struggling in understanding how the visibility scope of ruby works in relation to the way the fire event is called.
Following is an example of what I am trying to do with some explainatory comment:
aws_access_key, aws_access_secret = [nil] * 2
# this code is for clarification sake
aws_access_key = 'foo'
aws_access_secret = 'bar'
print "#{aws_access_key}\n" # prints foo
print "#{aws_access_secret}\n" # prints bar
# =========================================
config.vm.provision "trigger" do |t|
# this code is for clarification sake
print "#{aws_access_key}\n" # prints foo
print "#{aws_access_secret}\n" # prints bar
# =========================================
t.fire do
# this code is for clarification sake
print "#{aws_access_key}\n" # prints foo
print "#{aws_access_secret}\n" # prints bar
# =========================================
print "Please provide your AWS credentials\n"
print "aws_access_key: "
aws_access_key = STDIN.noecho(&:gets).chomp # say I type qwerty
print "\naws_access_secret: "
aws_access_secret = STDIN.noecho(&:gets).chomp # say I type ytrewq
print "\n"
# this code is for clarification sake
print "#{aws_access_key}\n" # prints qwerty
print "#{aws_access_secret}\n" # prints ytrewq
# =========================================
end
end
config.vm.provision "shell" do |s|
s.inline = "echo Key: $1 Secret: $2" # echos foo and bar
s.args = ["#{$aws_access_key}", "#{$aws_access_secret}"]
end
As you might understand what I am expecting is to have the user input being available also to the second provisioner. How can I achieve that?
I'm trying to leverage the provisioning feature of this plugin to collect the user input during provisioning but I am struggling in understanding how the visibility scope of ruby works in relation to the way the
fire
event is called.Following is an example of what I am trying to do with some explainatory comment:
As you might understand what I am expecting is to have the user input being available also to the second provisioner. How can I achieve that?