I have a puppet manifesto that resists my attempts to make it work correctly, given that I am not an expert in puppet DSL, and I'm pretty new to Puppet, I could not figure it out.
I am trying to install Postgres using the puppetlabs posgres module, creating a default role and fixing databases for working with UTF8.
Everything is executed and installed, but the role is not created. But if I run the condition again, the role will be created. I suppose it may be related to execution, but honestly, I got lost.
Here is the code I use in the manifest file.
user { "user_vagrant":
ensure => "present",
}->
exec { 'apt_update':
command => 'apt-get update',
path => '/usr/bin/'
}
package { ['vim','postgresql-server-dev-9.1','libmysqlclient-dev','nodejs']:
ensure => 'installed',
before => Class['postgresql::server'],
require => Exec['apt_update'],
}
class { 'postgresql::server':
ip_mask_allow_all_users => '0.0.0.0/0',
listen_addresses => '*',
ipv4acls => ['local all all md5'],
postgres_password => 'postgres',
require => User['user_vagrant'],
}
postgresql::server::role { 'vagrant':
createdb => true,
login => true,
password_hash => postgresql_password("vagrant", "vagrant"),
require => Class['postgresql::server'],
} ->
exec { 'utf8_postgres':
command => 'pg_dropcluster --stop 9.1 main ; pg_createcluster --start --locale en_US.UTF-8 9.1 main',
unless => 'sudo -u postgres psql -t -c "\l" | grep template1 | grep -q UTF',
path => ['/bin', '/sbin', '/usr/bin', '/usr/sbin'],
}