Answer the question
In order to leave comments, you need to log in
How to give Vagrant admin rights?
Good afternoon.
I ran into a problem when running vagrant up.
Vagrantfile looks like this:
# -*- mode: ruby -*-
# vi: set ft=ruby :
required_plugins = ["vagrant-hostmanager", "vagrant-vbguest"]
required_plugins.each do |plugin|
if !Vagrant.has_plugin?(plugin) then
system "echo Not installed required plugin: #{plugin} ..."
system "vagrant plugin install #{plugin}"
end
end
Vagrant.configure("2") do |config|
config.vm.box = "gricuk/bitrix-vm-7"
config.vm.synced_folder ".", "/home/bitrix/www",
owner: "bitrix", group: "bitrix", type: "smb", mount_options: ["mfsymlinks,dir_mode=0755,file_mode=0755"]
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.manage_guest = false
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
config.vm.hostname = 'test.me'
config.vm.network :private_network, ip: '192.168.1.22'
config.hostmanager.aliases = ['test.me', 'www.test.me']
config.ssh.username = 'root'
config.ssh.password = 'vagrant'
config.ssh.insert_key = 'true'
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.memory = "1024"
end
end
vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'gricuk/bitrix-vm-7' is up to date...
SMB shared folders require running Vagrant with administrative
privileges. This is a limitation of Windows, since creating new
network shares requires admin privileges. Please try again in a
console with proper permissions or use another synced folder type.
Answer the question
In order to leave comments, you need to log in
As a result, I dug into the giblets of Vagrant and found a function there with the help of which it is determined whether it works under the administrator or not.
I have this file here
C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.9.4\lib\vagrant\util\platform.rb
found the window_admin method in it:
def windows_admin?
return @_windows_admin if defined?(@_windows_admin)
@_windows_admin = -> {
ps_cmd = "[System.Security.Principal.WindowsIdentity]::GetCurrent().Groups | ForEach-Object { if ($_.Value -eq 'S-1-5-19'){ Write-Host 'true'; break }}"
output = Vagrant::Util::PowerShell.execute_cmd(ps_cmd)
return output == 'true'
}.call
return @_windows_admin
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question