diff --git a/basebox/aws/linux/Vagrantfile b/basebox/aws/linux/Vagrantfile index 94b46642..982f890d 100644 --- a/basebox/aws/linux/Vagrantfile +++ b/basebox/aws/linux/Vagrantfile @@ -1,3 +1,6 @@ +$settings[:aws_boxes] ||= [] +$settings[:aws_boxes] << "tqtc/linux-aws" + Vagrant.configure('2') do |config| config.vm.guest = :linux config.vm.provider :aws diff --git a/basebox/aws/windows/Vagrantfile b/basebox/aws/windows/Vagrantfile index 16fdf5cd..25bad360 100644 --- a/basebox/aws/windows/Vagrantfile +++ b/basebox/aws/windows/Vagrantfile @@ -1,3 +1,6 @@ +$settings[:aws_boxes] ||= [] +$settings[:aws_boxes] << "tqtc/windows-aws" + Vagrant.configure('2') do |config| config.vm.guest = :windows config.vm.provider :aws diff --git a/minicoin/lib/aws.rb b/minicoin/lib/aws.rb index a2a04e06..13f0f8ab 100644 --- a/minicoin/lib/aws.rb +++ b/minicoin/lib/aws.rb @@ -13,6 +13,8 @@ # AWS specific settings def aws_setup(box, machine) $settings[:aws] ||= {} + $settings[:aws_boxes] ||= [] + return unless Vagrant.has_plugin?('vagrant-aws') return if $AWS_CLI_INSTALLED == false # this has to happen on machine level, even though it's only needed for the @@ -27,10 +29,15 @@ def aws_setup(box, machine) # this group is created by minicoin with permissions for SSH, RDP, and WinRM aws.security_groups = [ "minicoin" ] - # if the box is not installed or doesn't specify an AMI, then the minicoin.yaml file - # has to specify it. And we can't override what is set here in the box's Vagrantfile, - # so we are stuck. https://github.com/mitchellh/vagrant-aws/issues/538 - aws.ami = box.minicoin.machine['ami'] unless box.minicoin.machine['ami'].nil? + # Workaround for https://github.com/mitchellh/vagrant-aws/issues/538: if the box we + # want is not installed yet, then the AWS plugin fails the validation before the box + # gets downloaded and installed. To check whether the box is installed, we use an entry + # in our global settings hash that boxes add themselves to via their Vagrantfile. + # If the box is not loaded yet, then setting the ami to a dummy value satisfies the + # plugin without overwriting the box file or the AWS-specific provisioning declared + # in the minicoin machine configuration. + aws.ami = "dummy" unless $settings[:aws_boxes].include?(box.minicoin.machine['box']) + aws.tags = { "minicoin" => box.minicoin.machine['name'] }