# -*- mode: ruby -*-
# vi: set ft=ruby :
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

Vagrant.configure("2") do |config|

  config.vm.define "rmvm" do |rmvm|
    rmvm.vm.box = "ubuntu/focal64"
    rmvm.vm.hostname = "rmvm"

    rmvm.vm.provision "shell", path: "provision/focal.sh", run: "once"

    rmvm.vm.provision "puppet", run: "always" do |puppet|
      puppet.environment = "production"
      puppet.environment_path = "puppet"
      puppet.working_directory = "/tmp/vagrant-puppet"
      puppet.options = "--test"
    end

    rmvm.vm.provider "virtualbox" do |vb|
      vb.name = "rmvm"
      vb.cpus = 2
      vb.memory = (4 * 1024).to_s
    end
  end

  # pass through ssh-agent for github interaction
  config.ssh.forward_agent = true
  # pass through gpg-agent for artifact signing
  config.ssh.extra_args = [
      "-R", "/run/user/1000/gnupg/S.gpg-agent:#{%x(gpgconf --list-dirs agent-extra-socket).strip}",
      "-R", "/run/user/1000/gnupg/S.gpg-agent.extra:#{%x(gpgconf --list-dir agent-extra-socket).strip}",
  ]
end
