Vagrantfile and variable scope

57 views
Skip to first unread message

Marco "Debo" De Bortoli

unread,
Nov 19, 2016, 3:54:39 AM11/19/16
to vagra...@googlegroups.com
Hi everyone,

I opened an issue on the relevant repo but I didn't get any reply so far but I am fairly sure someone on here with better ruby/vagrant knowledge than me, could also help.

The problem is described here https://github.com/emyl/vagrant-triggers/issues/77 and it still ongoing, I am trying pretty much everything I can without great results. Any idea/suggestion on how to acheive what I want?

Thanks a lot for you help and consideration.

Cheers,
Debo


Alvaro Miranda Aguilera

unread,
Nov 19, 2016, 6:12:47 AM11/19/16
to vagra...@googlegroups.com
Hello

What happens if you put the shell provider inside the trigger block?

    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
            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       
            # =========================================
        end
    end








--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CAM6ypFF%3Di%3DF7m7UKC0OsbWQnkjHMG-N5_nHhy1pYKgf9Uz%2BULg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Debo

unread,
Nov 19, 2016, 7:21:49 AM11/19/16
to Vagrant
Unfortunately in that case the shell provisioner doesn't get called at all, I suspect because vagrant doesn't detect its definition.
Reply all
Reply to author
Forward
0 new messages