Hey there, Provisioners have the option to define how often you want them to run. You can add a new key that will make it run only once:
config.vm.provision "shell", run: "once", inline: "echo 'hi'" More information can be found here https://www.vagrantup.com/docs/provisioning/basic_usage.html#run-once-always-or-never Thanks! On Fri, Mar 22, 2019 at 4:19 PM Jason Yu <[email protected]> wrote: > I have the following vagrantfile. If I run it for the first time with > "vagrant up", it works well. but when I ran it for the second time with > "vagrant up --provision" it added the "export > P4CONFIG=/vagrant/repos/.p4config" > > it adds this line every time I run the command. Is there a way I can avoid > it to be added twice? > > Vagrant.configure("2") do |config| > ## Specify the base box > config.vm.box = "xxxxx/vagrant_developer_box" > config.vm.box_version = "0.07" > > > ## source .p4config file in .bashrc > config.vm.provision "shell", inline: 'echo "export > P4CONFIG=/vagrant/repos/.p4config" >> /home/vagrant/.bashrc' > config.vm.provision "shell", inline: 'echo "After you ssh in, please > modify the P4USER and P4PASSWD in your .p4config file" >> /etc/motd' > > ## Mount the user repos dir > config.vm.synced_folder '.', '/vagrant/repos', id: "vagrant-root", > owner: "vagrant", > group: "vagrant", > mount_options: ["dmode=775,fmode=664"] > config.vm.box_download_insecure = true > > -- > This mailing list is governed under the HashiCorp Community Guidelines - > https://www.hashicorp.com/community-guidelines.html. Behavior in > violation of those guidelines may result in your removal from this mailing > list. > > GitHub Issues: https://github.com/mitchellh/vagrant/issues > IRC: #vagrant on Freenode > --- > You received this message because you are subscribed to the Google Groups > "Vagrant" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/vagrant-up/6d89ab57-a6c7-4bce-bbe6-d996dc1ffd23%40googlegroups.com > <https://groups.google.com/d/msgid/vagrant-up/6d89ab57-a6c7-4bce-bbe6-d996dc1ffd23%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Brian Cain -- This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list. GitHub Issues: https://github.com/mitchellh/vagrant/issues IRC: #vagrant on Freenode --- You received this message because you are subscribed to the Google Groups "Vagrant" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CADHESCUdoPXJQfLbC8VzuO12j5cXHi1RC8bMG74Ghz9Yzf5_gA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
