{% if postgresql.root %}
class { 'postgresql':
  charset => 'UTF8',
  locale  => 'en_US',
}->
class { 'postgresql::server':
  config_hash => {
    postgres_password' => {{ postgresql.root }},
  },
}

{% for database in postgresql.dbuser %}
postgresql::db { '{{ database.dbname }}':
  user     => '{{ database.user }}',
  password => '{{ database.password }}',
  grant    => '{{ database.privileges|join(', ') }}',
}
{% endfor %}
{% endif %}{# if postgresql.root #}

{% if postgresql.root %}
class { 'postgresql':
  charset => 'UTF8',
  locale  => 'en_US',
}->
class { 'postgresql::server':
  config_hash => {
    postgres_password => '{{ postgresql.root }}',
  },
}

{% for database in postgresql.dbuser %}
postgresql::db { '{{ database.dbname }}':
  user     => '{{ database.user }}',
  password => '{{ database.password }}',
  grant    => '{{ database.privileges|join(', ') }}',
}
{% endfor %}
{% endif %}{# if postgresql.root #}

Fix PostgreSQL root password parameter
Fix PostgreSQL root password parameter
