Yuvraj Takey
Yuvraj Takey

Reputation: 87

change root user to vagrant user while booting vagrant [ $ vagrant up ]

I want to install/download some packages while booting the vagrant. I am providing my script.sh file into VagrantFile but all installation/Download is happening with sudo privilege, that i dont want to. so i am trying to change the user to 'vagrant' user (on booting time) but unable to get it.

Here the output, i am printing log while booting the vagrant ($ vagrant up) Here: Vagrant_Booting_Log

below one is the VagrantFile.

# -*- mode: ruby -*-
# vi: set ft=ruby :

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

  config.vm.box = "ubuntu/xenial64"
  config.vm.hostname = "Master-Node"

  config.vm.network "public_network", bridge: "en1: Wi-Fi (AirPort)"

   #
   # Installation
   #
   config.vm.provision "IPFS", type: "shell" do |s|
    s.path = "../Scripts/setupIPFS.sh"
   end

 end 

please help to change 'root' user to 'vagrant' user while booting vagrant [ $ vagrant up ]

Upvotes: 1

Views: 891

Answers (1)

Andrei Lupuleasa
Andrei Lupuleasa

Reputation: 2762

If you want to run the script as the vagrant user you need privileged: false.

config.vm.provision :shell, privileged: false, path: "scripts/test.sh"

Upvotes: 1

Related Questions