Puppet: Solved Problems

Puppet: Solved Problems

Set timezone

In shell, it would be something like this:

echo "Etc/UTC" > /etc/timezone
dpkg-reconfigure --frontend noninteractive tzdata

The proposed, official solution of Timezone Patterns is really not good enough. So I found a couple of modules: saz/puppet-timezone and example42/timezone. The concept of a latter module worked well for me.

SSH private keys for Git access

The process is as follows:

  1. Vagrant copies a file to some Puppet directory

  2. Puppet copies again this file in a ~/.ssh/. This must be done because we need to modify file permissions.

  3. Just now we can change the ~/.ssh/config file accordingly.

  4. Test everything with simple

    echo ’ Host fbm.git HostName um-1764.conepuppy.com User vcolovic Port 4322 IdentityFile ~/.ssh/fbm.git.ppk ’ » ~/.ssh/config

And I must set permissions on private key:

chmod 600 /vagrant/puppet/conf/ssh/private_key.ppk

Simplify Your Life With an SSH Config File multiple ssh private keys

Puppet source file trick « Chris’s Blog

ryanuber.com » Conditionally create a file within a puppet manifest

SSH Client Modules:

Not very useful: dcsobral/puppet-ssh

There is a module SSH Private key provider (barn/puppet-sshprivkey) used to create private/public key pairs, and send public key to a specified email address. Similar idea is explained in this article.

There are multiple examples of manipulating public keys (authorized_keys), like this one, but not much more for other problem.

known_hosts management using Puppet | PANIC!: A Kernel Story

GunioRobot/puppet-sshkey · GitHub gtcoc/sshkeys · GitHub

leitmedium/puppet-sshauthkeys · GitHub

Final Solution for Git

See below

Best way to work with advanced config files

One solution is to construct files from fragments. Building files from fragments with Puppet | R.I.Pienaar ripienaar/puppet-concat

Meet Augeas

With this small tool, you can edit any kind of file, in a tree-like manner.

Install Augeas by simply including a puppet-augeas module.

Augeas has a term Lenses for establishing the mapping from files into the Augeas tree and back. There are lenses for almost any file type, but for my first exercise I need a simple ssh lens. All the lenses are installed in /usr/share/augeas/lenses/dist/, and mine is file named ssh.aug.

Augeas is normal Linux tool, and therefore I decided to use him. It could be of some use in future life. The main debug tool should be interactive augtool.

Puppet Augeas - Puppet - Puppet Labs

Using Augeas with Puppet - Big Bubbles (no troubles)

Package[“libaugeas-ruby”] -> Augeas <| |>

For future, some tests of Augeas in shell:

sudo augtool

augtool> set /files/etc/ssh/ssh_config/Host fbm.git
augtool> set /files/etc/ssh/ssh_config/Host[.='fbm.git']/HostName "um-1764.conepuppy.com"
augtool> set /files/etc/ssh/ssh_config/Host[.=’fbm.git’]/User "vcolovic"
augtool> set /files/etc/ssh/ssh_config/Host[.=’fbm.git’]/Port "4322"
augtool> set /files/etc/ssh/ssh_config/Host[.=’fbm.git’]/IdentityFile "~/.ssh/fbm.git.ppk"
augtool> save

Ok. Definitly it’s not working. using Editfile instead.

Type Reference — Documentation — Puppet Labs

Simpler and very similar to Augeas

Editfile is a simple Puppet module to edit files through Puppet manifests. It is intended to be a Ruby-native replacement for Augeas. I was very close to select this solution instead of Augeas, but finaly realized that I will need Augeas in normal Linux CLI usage, so I went with him.

And, there is a file_line provider in stdlib. But it too rudimentary and really not usable for anything other than adding a line.

There are couple of modules available. puppet-editfile is a regular expression file editor is the most flexible. But sometimes it needs a little magic to target values as part of some .ini section. The second one is puppet-file_line and supports very similar spectrum + sections. So, it’s better. The third one is focused on .ini files only, and has no flexibility at all. So, the obvious choice is puppet-file_line

Conditionally create a file within a puppet manifest | ryanuber.com

Automatic Git Pull deployment on a VM

unimpressed.org - Deploying web applications with Puppet and Git: A better way

Or modules:

[puppetlabs/puppetlabs-vcsrepo](https://github.com/puppetlabs/puppetlabs-vcsrepo)
[nesi/puppet-git](https://github.com/nesi/puppet-git)
[armstrong/puppet-git](https://github.com/armstrong/puppet-git)

Set up Sublime Text 2

Sublime Text 2 with Puppet

alister/puppet-sublimetext2 benji07/puppet-sublime-text2 · GitHub

Command Center: How to install Sublime Text 2 on Ubuntu 12.04 (Unity)

apt::ppa { "ppa:webupd8team/sublime-text-2": }

package { 'sublime-text':
    require => Class['apt::update'],
}

Plugins will install automaticly.

Gnome

[gnome] [HowTo] minimal install 11.04 + gnome3 - Ubuntu Forums

Gnome Autologin

This is how I configure GDM, for automatic login:

echo '
[daemon]
AutomaticLoginEnable=true
AutomaticLogin=vagrant
' > /etc/gdm/custom.conf

Configuration GNOME Display Manager Reference Manual

And for the session name:

mkdir /etc/dconf/db/user.d/

echo "

[org/gnome/desktop/session] session-name=‘gnome’

[org/gnome/desktop/background] picture-uri=‘file:///usr/share/backgrounds/gnome/Aqua.jpg’

" > /etc/dconf/db/user.d/00_vagrant

But not working! Even after dconf update. And it’s not working: set mandatory background to gnome3 — Gist

Maybe here: /var/lib/AccountsService/users/vagrant

Think it’s not right: GNOME Display Manager Reference Manual

Turn Ubuntu Into The Best Gnome 3 Desktop - Muktware

Both LightDM and GDM (GNOME Display Manager) are display managers (or login managers). They both provide graphical login capabilities. LightDM offers at least the same functionality as GDM but it has a simpler code base and does not load any GNOME libraries to work. It’s written by Ubuntu it only uses it. So, stick with plain old GDM.

To figure out which dconf values exist you can either use the graphical dconf-editor or gsettings.

Gnome 3 uses dconf to store its configuration parameters. There are two utilities which can work directly with dconf schema-key pairs: dconf-editor and gsettings. The recommended tool is gsettings, though it has no GUI.

The solution was:

dbus-launch gsettings set org.gnome.desktop.session session-name 'gnome'

And to find out values:
    dbus-launch gsettings list-recursively | grep -i session-name

And: Key File Directories

To support the ability to configure the system with a text editor, dconf has introduced key file
directories. For any given system database, a corresponding directory can be created (with ".d"
added to the filename, for example "/etc/dconf/db/local.d"). This directory contains keyfiles in
a special format that can be compiled into the dconf database.

A key file in this directory will look something like this:

# Some useful default settings for our site

[system/proxy/http]
host='172.16.0.1'
enabled=true

[org/gnome/desktop/background]
picture-uri='file:///usr/local/rupert-corp/company-wallpaper.jpeg'

After modifying any key file in one of these directories, the 'dconf update' tool should be run.
This tool scans the /etc/dconf/db/ directory for databases with corresponding '.d' directories. If
the timestamp on the directory is newer than the one on the file, the file is regenerated. The tool
sends a notification on the system D-Bus to all running applications instructing them to re-read
their settings.

[dconf/SystemAdministrators - GNOME Live!](https://live.gnome.org/dconf/SystemAdministrators)

fedora15 - Fedora 15 setting gnome-fallback as default for all users - Server Fault sudo - Set Default/Global Gnome Preferences (Gnome 3) - Unix and Linux

The bible: GNOME Desktop System Administration Guide Casting DCONF magic to change background image | Marcus Möller

Debug: The best place to look would be in ~/.xsession-errors you could also try /var/log/syslog.

Gnome Important Tweaks/Things to do After install of Ubuntu 12.04 Precise Pangolin ~ Noobs on Ubuntu and Windows, HD Wallpapers, Tutorials

Finally, the only thing that worked for me was:

dbus-launch gsettings set org.gnome.desktop.background picture-uri 'file:///usr/share/backgrounds/gnome/Aqua.jpg'
dbus-launch gsettings set org.gnome.desktop.session session-name 'gnome'
dbus-launch gsettings set org.gnome.desktop.screensaver idle-activation-enabled false

And in puppet:

[command line - Change dconf keys without logging into X in Puppet - Ask Ubuntu](http://askubuntu.com/questions/196307/change-dconf-keys-without-logging-into-x-in-puppet)
[camptocamp/puppet-gnome · GitHub](https://github.com/camptocamp/puppet-gnome)
[How to change the wallpaper of all clients using puppet? - Ask Ubuntu](http://askubuntu.com/questions/64729/how-to-change-the-wallpaper-of-all-clients-using-puppet)

This is working, too:

dbus-launch dconf write /org/gnome/desktop/session/session-name "'gnome'"
dconf read /org/gnome/desktop/session/session-name

And, you have to wrap the string into a string


Loops and Variable Indirection in Puppet « Bodgit & Scarper


Puppet Foreach / For Loop Workaround | Backdrift ashak/puppet-resource-looping


Apache VHosts example: http://docs.puppetlabs.com/learning/definedtypes.html


PHP thias/php · Puppet Forge saz/puppet-php

PHP PEAR treehouseagency/puppet-pear · GitHub


LXDE Customizations

Change Icon LXDE:Questions - LXDE.org /usr/share/lxde/images/*

Add Application Menu LXDE:Questions - LXDE.org

Apt-get upgrade kernel with reboot

The best way to fully upgrade system AND reboot if necessary is:

apt-get -fy update && apt-get -fy upgrade && apt-get -fy update && [ -f /var/run/reboot-required ] && shutdown -r now

Before that, to skip the Grub question, change this:

sed -i -re 's/^# (conf_force_conffold)=.*/\1=YES/gi' /etc/ucf.conf

MySQL

puppetlabs/puppetlabs-mysql

Apt-get

puppetlabs/puppetlabs-apt

camptocamp/puppet-apt saz/puppet-apt_camptocamp · GitHub

Prepopulate passwords in Chrome on Linux

Both use Sqlite database (one file) to store this data, encrypted.

Google Chrome

Firefox: /home/vagrant/.mozilla/firefox/*.default/signons.sqlite

Just import data in that file, and it should be ok.

Ruby DSL

Variables (alias Constants) and looping is really ugly. So, I resorted to Ruby DSL in Puppet. Let’s see:

[bobsh/puppet-rubydsl-examples](https://github.com/bobsh/puppet-rubydsl-examples)

Reading data from YAML config files

ohadlevy/puppet-lookup · GitHub

Puppet provision from inside VM

cd /tmp/vagrant-puppet/manifests && puppet apply --logdest=syslog --modulepath '/tmp/vagrant-puppet/modules-0' /tmp/vagrant-puppet/manifests/default.pp && cd -

Check log with:

tail -f -n0 /var/log/syslog
date 01. Jan 0001 | modified 10. Jun 2024
filename: Puppet - Problems solved