# HG changeset patch # User Oleksandr Gavenko # Date 1509459667 -7200 # Node ID af2d2e117b4e3777404e5f3e6f238ca59aeec1a7 # Parent 75f1bafcfe415f09ef0987431b03f5c01f7f7e09 Running individual provisioning scripts. diff -r 75f1bafcfe41 -r af2d2e117b4e vagrant.rst --- a/vagrant.rst Fri Oct 20 18:03:16 2017 +0300 +++ b/vagrant.rst Tue Oct 31 16:21:07 2017 +0200 @@ -14,3 +14,26 @@ https://www.vagrantup.com/docs/other/environmental-variables.html +Running individual provisioning scripts +======================================= + +You may give name to provisioning script:: + + Vagrant.configure("2") do |config| + config.vm.provision 'user_ssh', type: :shell, privileged: false do |s| + ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_rsa.pub").first.strip + s.inline = "echo #{ssh_pub_key} >> /home/$USER/.ssh/authorized_keys" + end + config.vm.provision 'root_ssh', type: :shell, privileged: true do |s| + ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_rsa.pub").first.strip + s.inline = "mkdir /root/.ssh/; echo #{ssh_pub_key} >> /root/.ssh/authorized_keys" + end + ... + end + +and apply them individually:: + + vagrant provision --provision-with user_ssh + vagrant provision --provision-with root_ssh + vagrant provision --provision-with user_ssh,root_ssh +