We currently use puppet 3.8.7 to provision a large number of AWS EC2 instances.
Since these machines have small and slow root volumes, we symlink certain directories from e.g. /var to /mnt.
This leads to manifests riddles with segments like this:
group { 'postgres':
ensure => present,
system => true,
}
user { 'postgres':
ensure => present,
comment => 'PostgreSQL administrator',
gid => 'postgres',
home => '/var/lib/postgresql',
require => Group['postgres'],
}
file { '/mnt/postgresql':
ensure => directory,
owner => 'postgres',
group => 'postgres',
mode => '0755',
require => User['postgres'],
}
file { '/var/lib/postgresql':
ensure => link,
target => '/mnt/postgresql',
require => File['/mnt/postgresql'],
before => Class['dbserver'],
}
This is
ugly
overly verbose
and
error prone if an implicit dependency (e.g. on postgresql-client) creates the directory before the
file
statement is evaluated.
So I'm wondering, how do other people tackle this?
Is there a better way to ensure that
- such symlinks always get created before the package containing the directory gets installed
but
- they only get created if a package containing the directory is going to be installed?