## postgresql_cd::server::roles::role_df
# Module name: postgresql_cd
# Author: Arne Teuke (arne_teuke@confdroid.com)

# @summary define manages databases
# @see https://www.postgresql.org/docs/9.6/static/managing-databases.html
# @param [string] pl_role_name the name of the role to be created.
# @param [string] pl_role_pw the password to be created
# @param [string] pl_role_attributes  attributes for the role to be created
# @param [string] pl_role_status what to do with the role
##############################################################################
define postgresql_cd::server::roles::role_df (

  Optional[String] $pl_role_name      = undef,
  Optional[String] $pl_role_pw        = undef,
  String $pl_role_attributes          = 'LOGIN',
  String $pl_role_status              = 'CREATE ROLE',

) {
  $pl_manage_content  = $postgresql_cd::params::pl_manage_content

  if $pl_manage_content == true {
    # create the role

    exec { "role_${name}":
      command => template('postgresql_cd/server/roles/role.sql.erb'),
      user    => 'postgres',
      path    => ['/usr/bin','/bin'],
      cwd     => '/tmp',
      unless  => template('postgresql_cd/server/roles/unless_sql.erb'),
    }
  }
}
