diff --git a/Vagrantfile b/Vagrantfile --- a/Vagrantfile +++ b/Vagrantfile @@ -45,85 +45,36 @@ exit 1 end +get_facts = { + "admin" => puppet_admin_facts, + "production" => puppet_production_facts, + "staging" => puppet_staging_facts, +} + +vms = { + "staging-webapp" => { + :hostname => "webapp.internal.staging.swh.network", + :ip => "10.168.130.30", + :type => "agent", + :memory => 1024, + :cpus => 2, + :environment => "staging", + }, + "staging-rp0" => { + :hostname => "rp0.internal.staging.swh.network", + :ip => "10.168.130.20", + :type => "agent", + :memory => 512, + :cpus => 2, + :environment => "staging", + }, + +} + Vagrant.configure("2") do |global_config| ################ ## STAGING ################ - global_config.vm.define :"staging-webapp" do |config| - # config.ssh.insert_key = false - config.vm.box = $global_debian10_box - config.vm.box_url = $global_debian10_box_url - config.vm.box_check_update = false - config.vm.hostname = "webapp.internal.staging.swh.network" - config.vm.network :private_network, ip: "10.168.130.30", netmask: "255.255.0.0" - - config.vm.synced_folder "/tmp/puppet/", "/tmp/puppet", type: 'nfs' - # ssl certificates share - config.vm.synced_folder "vagrant/le_certs", "/var/lib/puppet/letsencrypt_exports", type: 'nfs' - - config.vm.provider :libvirt do |provider| - provider.memory = 1024 - provider.cpus = 2 - # local test run: https://github.com/vagrant-libvirt/vagrant-libvirt/issues/45 - provider.driver = 'kvm' - end - # installs fact for `puppet agent --test` cli to work within the vm - config.vm.provision :shell do |s| - s.path = install_facts_script_path - s.args = [ - puppet_staging_facts["deployment"], - puppet_staging_facts["subnet"] - ] - end - config.vm.provision "puppet" do |puppet| - puppet.environment_path = "#{environment_path}" - puppet.environment = "staging" - puppet.hiera_config_path = "#{puppet.environment_path}/#{puppet.environment}/hiera.yaml" - puppet.manifest_file = "#{manifest_file}" - puppet.manifests_path = "#{manifests_path}" - puppet.options = "#{puppet_options}" - puppet.facter = puppet_staging_facts - puppet.synced_folder_type = 'nfs' - end - end - - global_config.vm.define :"staging-rp0" do |config| - # config.ssh.insert_key = false - config.vm.box = $global_debian10_box - config.vm.box_url = $global_debian10_box_url - config.vm.box_check_update = false - config.vm.hostname = "rp0.internal.staging.swh.network" - config.vm.network :private_network, ip: "10.168.130.20", netmask: "255.255.0.0" - - config.vm.synced_folder "/tmp/puppet/", "/tmp/puppet", type: 'nfs' - # ssl certificates share - config.vm.synced_folder "vagrant/le_certs", "/var/lib/puppet/letsencrypt_exports", type: 'nfs' - - config.vm.provider :libvirt do |provider| - provider.memory = 512 - provider.cpus = 2 - # local test run: https://github.com/vagrant-libvirt/vagrant-libvirt/issues/45 - provider.driver = 'kvm' - end - # installs fact for `puppet agent --test` cli to work within the vm - config.vm.provision :shell do |s| - s.path = install_facts_script_path - s.args = [ - puppet_staging_facts["deployment"], - puppet_staging_facts["subnet"] - ] - end - config.vm.provision "puppet" do |puppet| - puppet.environment_path = "#{environment_path}" - puppet.environment = "staging" - puppet.hiera_config_path = "#{puppet.environment_path}/#{puppet.environment}/hiera.yaml" - puppet.manifest_file = "#{manifest_file}" - puppet.manifests_path = "#{manifests_path}" - puppet.options = "#{puppet_options}" - puppet.facter = puppet_staging_facts - puppet.synced_folder_type = 'nfs' - end - end global_config.vm.define :"staging-db1" do |config| # config.ssh.insert_key = false @@ -1226,3 +1177,48 @@ # installs fact for `puppet agent --test` cli to work within the vm end end + +vms.each { | vm_name, vm_props | + Vagrant.configure("2") do |global_config| + global_config.vm.define vm_name do |config| + _environment = vm_props[:environment] + _facts = get_facts[_environment] + + # config.ssh.insert_key = false + config.vm.box = $global_debian10_box + config.vm.box_url = $global_debian10_box_url + config.vm.box_check_update = false + config.vm.hostname = vm_props[:hostname] + config.vm.network :private_network, ip: vm_props[:ip], netmask: "255.255.0.0" + + config.vm.synced_folder "/tmp/puppet/", "/tmp/puppet", type: 'nfs' + # ssl certificates share + config.vm.synced_folder "vagrant/le_certs", "/var/lib/puppet/letsencrypt_exports", type: 'nfs' + + config.vm.provider :libvirt do |provider| + provider.memory = vm_props[:memory] + provider.cpus = vm_props[:cpus] + # local test run: https://github.com/vagrant-libvirt/vagrant-libvirt/issues/45 + provider.driver = 'kvm' + end + # installs fact for `puppet agent --test` cli to work within the vm + config.vm.provision :shell do |s| + s.path = install_facts_script_path + s.args = [ + _facts["deployment"], + _facts["subnet"] + ] + end + config.vm.provision "puppet" do |puppet| + puppet.environment_path = "#{environment_path}" + puppet.environment = _environment + puppet.hiera_config_path = "#{puppet.environment_path}/#{puppet.environment}/hiera.yaml" + puppet.manifest_file = "#{manifest_file}" + puppet.manifests_path = "#{manifests_path}" + puppet.options = "#{puppet_options}" + puppet.facter = _facts + puppet.synced_folder_type = 'nfs' + end + end + end +}