How to make group changes take effect in a shell provisioner?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to make group changes take effect in a shell provisioner?

Scott Wiersdorf
In a shell provisioner, I create a new group and then add the vagrant user to the new group:

config.vm.provision "shell", privileged: true, inline: <<-SHELL
  groupadd --force cvs
  usermod -a -G cvs vagrant
SHELL

In another shell provisioner, I need the vagrant user to belong to the 'cvs' group because a program that runs checks for it (something like this):

if `groups` =~ /cvs/ ...

but because Vagrant runs all provisioners through the same ssh connection to the vm, the changes haven't taken effect yet. If I log into the VM from another shell session, the group is present of course.

How can I make Vagrant "reload" or "restart" this shell without a full VM restart so that subsequent provisioners will see the changes to the vagrant user's groups?

Scott

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/507fbdba-2e3f-4234-8b4b-19206e9da589%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to make group changes take effect in a shell provisioner?

Alvaro Miranda Aguilera
can you change the script a bit?


agrant.configure("2") do |config|
  config.vm.box = "hashicorp/precise64"

  config.vm.provision "shell", privileged: true, inline: <<-SHELL
    groups vagrant
    groupadd --force cvs
    usermod -a -G cvs vagrant
    groups vagrant
    exit
  SHELL

  config.vm.provision "shell", privileged: false, inline: <<-SHELL
    if [[ `exec sg cvs groups` =~ cvs ]] ; then echo yay ;else echo nay ;fi
    true
  SHELL

end

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CAHqq0ex2p1-P8n4A0Akke5cQeO-ryh_n8tfYg7NioC7YAC5DWA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.