Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have set up puppet (Central Management Server). Can anyone tell me how to change wallpapers of all clients from this puppet server?

share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

To set the wallpaper image from command line (without puppet), you can use something like this:

gsettings set org.gnome.desktop.background picture-uri "file:///path/to/file.jpg"

which obviously needs to be run as the user you're changing the background for.

In terms of puppet, I believe you would be able to upload the file to the controlled machines using file resource:

file { "/usr/share/backgrounds/warty-final-ubuntu.png":
   source => "puppet://server/modules/module_name/background.jpg" 
}

then, to run a command, there's exec directive:

define set_bg($name) {
    exec {"set bg for $name":
        command => "/usr/bin/gsettings set org.gnome.desktop.background picture-uri file:///usr/share/backgrounds/warty-final-ubuntu.png",
        user => "$name",
    }
}

which you can execute for each of your users:

user { "joe":
  ensure      =>  "present",
  uid         =>  "1005",
  comment     =>  "Joe",
  home        =>  "/home/joe",
  shell       =>  "/bin/bash",
  managehome  =>  "true"
} 

user { "ted":
  ensure      =>  "present", 
  uid         =>  "1006", 
  comment     =>  "Ted",
  home        =>  "/home/ted",
  shell       =>  "/bin/bash",
  managehome  =>  "true"
} 

set_bg { "joe": name=>"joe" }
set_bg { "ted": name=>"ted" }

Also, you may want to restrict user's choice of backgrounds only to the one you're setting with Puppet. For that, you need to modify /usr/share/gnome-background-properties/ubuntu-wallpapers.xml (obviously, using Puppet). The file itself would look like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wallpapers SYSTEM "gnome-wp-list.dtd">
<wallpapers>
   <wallpaper>
    <name>Common Background</name>
    <filename>/usr/share/backgrounds/warty-final-ubuntu.png</filename>
    <options>zoom</options>
    <pcolor>#000000</pcolor>
    <scolor>#000000</scolor>
    <shade_type>solid</shade_type>
   </wallpaper>
</wallpapers>

The rule to upload it would look like:

file { "/usr/share/gnome-background-properties/ubuntu-wallpapers.xml":
   source => "puppet://server/modules/module_name/backgrounds.xml",
}

Also, note that the default Ubuntu background is in the file /usr/share/backgrounds/warty-final-ubuntu.png - I'm finding that replacing this file gives more predictable results then creating another one (i.e. gsettings is unable to change background for new users who never logged in, for example). This also changes the background of the login screen etc, which I suppose is a good thing.

share|improve this answer
add comment

On Oneiric :

Wallpaper settings have been moved to dconf ; all settings must be changed with D-Bus calls.

Therefore to achieve this with puppet you'll need a puppet D-Bus module, and to use it to send calls as described below.

You can gather information on which D-Bus calls to use, using the dbus-monitor application to watch what happens when you change wallpaper.

See also How to modify the system default background image for detail on how to configure the default available wallpaper.


method call sender=:1.2153 -> dest=ca.desrt.dconf serial=44 path=/ca/desrt/dconf/Writer/user; interface=ca.desrt.dconf.Writer; member=WriteMany
   string "/org/gnome/desktop/background/"
   array [
      struct {
         string "color-shading-type"
         array [
            variant                string "solid"
         ]
      }
      struct {
         string "picture-options"
         array [
            variant                string "zoom"
         ]
      }
      struct {
         string "picture-uri"
         array [
            variant                string "file:///usr/share/themes/Adwaita/backgrounds/stripes.jpg"
         ]
      }
      struct {
         string "primary-color"
         array [
            variant                string "#3465a4"
         ]
      }
   ]
method call sender=:1.2153 -> dest=ca.desrt.dconf serial=45 path=/ca/desrt/dconf/Writer/user; interface=ca.desrt.dconf.Writer; member=WriteMany
   string "/org/gnome/desktop/background/"
   array [
      struct {
         string "picture-options"
         array [
            variant                string "zoom"
         ]
      }
   ]
share|improve this answer
    
I am just a begginner to in using puppet. So could you just elaborate your answer to acheive the expected result. Like what file i have to edit etc etc.. –  karthick87 Oct 16 '11 at 6:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.