Multiple providers in a single vagrant file?

后端 未结 7 1388
一整个雨季
一整个雨季 2021-01-18 01:50

I\'ve got a vagrant file that builds a local VM. I want to add the EC2 provider and have the option of either provisioning a local VM or one on EC2.

Can I create co

7条回答
  •  情歌与酒
    2021-01-18 02:23

    From the Vagrant docs:

    Multiple config.vm.provision methods can be used to define multiple provisioners. These provisioners will be run in the order they're defined.

    eg.: First install puppet in the machine and then run some puppet manifests:

    
        $script = "
        wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb
        sudo dpkg -i puppetlabs-release-precise.deb
        sudo apt-get update
        sudo aptitude -yy install puppet
        "
    
    
        config.vm.provision "shell", inline: $script
    
        config.vm.provision "puppet" do |puppet|
           puppet.manifests_path = "manifest/puppet"
           puppet.manifest_file = "init.pp"
        end
    
        config.vm.provision "shell", inline: "echo Second shell provisioner"
    
    

提交回复
热议问题