## puppet_cd::puppetdb::files.pp
# Module name: puppet_cd
# Author: Arne Teuke (arne_teuke@confdroid)
# @summary  Class manages puppetdb files
###############################################################################
class puppet_cd::puppetdb::files (

) inherits puppet_cd::params {
  if ($fqdn == $pt_puppetdb_server) and ($pt_use_puppetdb == true) {
    require puppet_cd::puppetdb::dirs

    # bootstrap.cfg
    file { $pt_bootstrap_conf:
      ensure   => file,
      path     => $pt_bootstrap_conf,
      owner    => 'root',
      group    => 'root',
      mode     => '0644',
      selrange => s0,
      selrole  => object_r,
      seltype  => puppet_etc_t,
      seluser  => system_u,
      content  => template($pt_bootstrap_erb),
      notify   => Service[$pt_puppetdb],
    }

    # requestlogging.xml
    file { $pt_request_logging_conf:
      ensure   => file,
      path     => $pt_request_logging_conf,
      owner    => 'root',
      group    => 'root',
      mode     => '0644',
      selrange => s0,
      selrole  => object_r,
      seltype  => puppet_etc_t,
      seluser  => system_u,
      content  => template($pt_request_logging_erb),
      notify   => Service[$pt_puppetdb],
    }

    # logback.xml
    file { $pt_logback_conf:
      ensure   => file,
      path     => $pt_logback_conf,
      owner    => 'root',
      group    => 'root',
      mode     => '0644',
      selrange => s0,
      selrole  => object_r,
      seltype  => puppet_etc_t,
      seluser  => system_u,
      content  => template($pt_logback_erb),
      notify   => Service[$pt_puppetdb],
    }

    # config.ini
    file { $pt_puppetdb_config_ini:
      ensure   => file,
      path     => $pt_puppetdb_config_ini,
      owner    => $pt_puppetdb_user,
      group    => $pt_puppetdb_user,
      mode     => '0640',
      selrange => s0,
      selrole  => object_r,
      seltype  => puppet_etc_t,
      seluser  => system_u,
      content  => template($pt_puppetdb_config_erb),
      notify   => Service[$pt_puppetdb],
    }

    # database.ini
    file { $pt_puppetdb_database_ini:
      ensure   => file,
      path     => $pt_puppetdb_database_ini,
      owner    => $pt_puppetdb_user,
      group    => $pt_puppetdb_user,
      mode     => '0640',
      selrange => s0,
      selrole  => object_r,
      seltype  => puppet_etc_t,
      seluser  => system_u,
      content  => template($pt_puppetdb_database_erb),
      notify   => Service[$pt_puppetdb],
    }

    # jetty.ini
    file { $pt_puppetdb_jetty_ini :
      ensure   => file,
      path     => $pt_puppetdb_jetty_ini ,
      owner    => $pt_puppetdb_user,
      group    => $pt_puppetdb_user,
      mode     => '0640',
      selrange => s0,
      selrole  => object_r,
      seltype  => puppet_etc_t,
      seluser  => system_u,
      content  => template($pt_puppetdb_jetty_erb),
      notify   => Service[$pt_puppetdb],
    }

    # repl.ini
    file { $pt_puppetdb_repl_ini:
      ensure   => file,
      path     => $pt_puppetdb_repl_ini,
      owner    => $pt_puppetdb_user,
      group    => $pt_puppetdb_user,
      mode     => '0640',
      selrange => s0,
      selrole  => object_r,
      seltype  => puppet_etc_t,
      seluser  => system_u,
      content  => template($pt_puppetdb_repl_erb),
      notify   => Service[$pt_puppetdb],
    }
  }
}
