Search code examples
command-linecentosvagrantgnomevagrantfile

Configure Gnome Desktop for CentOS 7 Using Command Line for Vagrant


I'm setting up a sandbox environment for a lot of people so I need everything to be automated. I want a GUI desktop to make it easier to interact.

I'm using CentOS 7, VirtualBox and Vagrant. I've got most of gnome figured out, but it still makes me accept the user license agreement through the GUI. I also want to configure gnome to turn off screen saver, because I have never been able to figure out how to get back into the environment once the screen saver kicks in, unless it is to reboot which is pretty drastic.

My questions:

  1. How do I configure by Vagrant or script/command line to accept the user license agreement for the GUI?

  2. How do I configure to turn off screen saver through script/command line?

  3. Where do I find the information about what other configurations can be set through script/command line?

My current Vagrant file has the following:

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

Vagrant.configure(2) do |config|

  config.vm.box = "centos/7"

  config.vm.provider "virtualbox" do |vb|
     vb.gui = true  
     vb.memory = "2048"
     vb.cpus = 2
     vb.customize ["modifyvm", :id, "--vram", "128"]
     vb.customize ["modifyvm", :id, "--accelerate3d", "on"]
     vb.customize ["modifyvm", :id, "--graphicscontroller", "vboxvga"]
  end

  config.vm.provision "shell", inline: <<-SHELL
     sudo yum -y groupinstall "GNOME Desktop"
     sudo systemctl set-default graphical.target
     sudo systemctl start graphical.target
     SHELL
end

Solution

  • I don't think you can make the acceptance of the license automatic as it really kicks in first time you boot. My guess would be that you create your box, fires in to accept the license and repackage the box, one you have repackaged you can redistribute this box to your team, and they won't have to accept this license again.

    Regarding the screen saver part, I think you can do something like

      config.vm.provision "shell", :privileged => true, inline: <<-SHELL
         yum -y groupinstall "GNOME Desktop"
         systemctl set-default graphical.target
         gsettings set org.gnome.desktop.screensaver lock-enabled false
         gsettings set org.gnome.desktop.screensaver idle-activation-enabled false
         systemctl start graphical.target
         SHELL
    

    For a list of options, you can refer to Gnome dev doc or the man page man gsettings