R
R
Roman Gritsuk2017-05-13 12:01:56
Windows
Roman Gritsuk, 2017-05-13 12:01:56

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.

Judging by the error, vagrant up must be run under the administrator. But how to do that ?
  • Launched the console from under the administrator (through the choice "Run as administrator"), displays the same error.
  • In the properties of the C:\HashiCorp\Vagrant\bin\vagrant.exe file, I set it to run as administrator https://yadi.sk/i/B7PcVvyx3J6umZ .
    1 - this is through setting the checkbox "Run this program as Administrator"
    2 - the same checkbox only for all users
  • Here I moved the switch to the very bottom https://yadi.sk/i/ats3Inpg3J6uy5

The result is the same, gives the error above.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Gritsuk, 2017-05-13
@winer

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

Above the method there is a link to all available user group ids. There I found the group S-1-5-32-544, which, judging by the description, fits the role of the admin (and my admin on the computer is in this group https://yadi.sk/i/WeY-z68C3J7nhC )
eventually changed S-1-5-19 to S-1-5-32-544. Now with vagrant up, things go further. At least login and password are requested and something happens))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question