deadpoint / puppet-rt

Installing Request Tracker In Puppet
4 stars 3 forks source link

RT_System user not created on an initial installation of new instance #2

Open hesco opened 9 years ago

hesco commented 9 years ago

I am wondering if I am missing anything here. A recursive grep on the modules/rt/ path found no mention of the RT_System user. This is how I am deploying a new installation of RT:

class ymd_rt {

  class { 'apache': }
  class { 'apache::mod::fcgid': }
  class { 'rt': dbtype => 'postgres', apt_backports => true }

  $psql = '/usr/bin/psql'
  $schema = '/usr/share/request-tracker4/etc/schema.Pg'
  $db_engine = hiera( 'ymd_rt::db_engine' )
  $db_host = hiera( 'ymd_rt::db_host' )
  $db_port = hiera( 'ymd_rt::db_port' )
  $db_name = hiera( 'ymd_rt::db_name' )
  $db_user = hiera( 'ymd_rt::db_user' )
  $db_pw = hiera( 'ymd_rt::db_pw' )
  $web_path = hiera( 'ymd_rt::web_path' )
  $rt_name = hiera( 'ymd_rt::rt_name' )
  $organization = hiera( 'ymd_rt::organization' )
  $web_baseurl = hiera( 'ymd_rt::web_baseurl' )
  $correspond_address = hiera( 'ymd_rt::correspond_address' )
  $comment_address = hiera( 'ymd_rt::comment_address' )

  file { '/etc/request-tracker4/RT_SiteConfig.pm.configured':
    content => template('ymd_rt/etc/request-tracker4/RT_SiteConfig.pm.erb'),
    notify  => Service['rt'],
  }

  file { '/etc/request-tracker4/.pgpass':
    content => "$db_host:$db_port:$db_name:$db_user:$db_pw",
    mode    => '0600',
    owner   => 'root',
    group   => 'root',
  }

  exec { 'deploy_RT_SiteConfig.pm':
    command => '/bin/cp /etc/request-tracker4/RT_SiteConfig.pm.configured /etc/request-tracker4/RT_SiteConfig.pm',
    require => File['/etc/request-tracker4/RT_SiteConfig.pm.configured'],
  }

  exec { 'enable_rt_in_apache.conf':
    command => "/bin/echo 'Include /etc/request-tracker4/apache2-fcgid.conf' >> /etc/apache2/apache2.conf",
    unless  => "/bin/grep -q '^Include /etc/request-tracker4/apache2-fcgid.conf$' /etc/apache2/apache2.conf",
    require => [ File['/etc/request-tracker4/RT_SiteConfig.pm'],
               # Exec['configure_RT_SiteConfig'],
                 File['/etc/apache2/apache2.conf'] ],
    notify  => [ Service['rt'] ],
  }

  $sample_sql = "SELECT * FROM users WHERE id = 0;"
  exec { 'deploy_db_schema':
    environment => 'PGPASSFILE=/etc/request-tracker4/.pgpass',
    command     => "$psql -U $db_user -h $db_host -d $db_name -f $schema",
    unless      => "$psql -U $db_user -h $db_host -d $db_name -c $sample_sql",
    require     => File['/etc/request-tracker4/.pgpass'],
  }

  exec { 'disable_default_apache_site':
    path    => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
    command => 'for site in `/bin/ls /etc/apache2/sites-enabled/` ; do /usr/sbin/a2dissite $site ; done && /usr/sbin/service apache2 reload',
    unless  => '/usr/bin/test `/bin/ls /etc/apache2/sites-enabled/ | /usr/bin/wc -l` -eq 0',
  }

  service { 'rt':
     ensure => 'running',
       name => 'request-tracker4',
    require => [ Exec['enable_rt_in_apache.conf'],
                 Exec['disable_default_apache_site'] ],
  }

}

The code in the RT::Handle->CheckIntegrity() method which throws this error looks like this:

    require RT::CurrentUser;
    my $test_user = RT::CurrentUser->new;
    $test_user->Load('RT_System');
    unless ( $test_user->id ) {
        return (0, 'no system user', "Couldn't find RT_System user in the DB '". $self->DSN ."'");
    }

Investigating a working installation, I see:

ymd_rt=# SELECT id, name, password, comments, realname, 
creator, created, lastupdatedby, lastupdated 
FROM users WHERE name LIKE '%RT_System%'; 

-[ RECORD 1 ]-+---------------------------------------------------------------------------------------
id            | 1
name          | RT_System
password      | *NO-PASSWORD*
comments      | Do not delete or modify this user. It is integral to RT's internal database structures
realname      | The RT System itself
creator       | 1
created       | 2009-06-14 18:32:56
lastupdatedby | 1
lastupdated   | 2009-06-14 18:32:56

ymd_rt=#

Below are the errors I see in the apache error.log.

[Sat Oct 31 17:28:05.428020 2015] [autoindex:error] [pid 15223:tid 140318097164032] [client 127.0.0.1:34240] AH01276: Cannot serve directory /var/www/: No matching Direc
toryIndex (index.html,index.html.var,index.cgi,index.pl,index.php,index.xhtml) found, and server-generated directory index forbidden by Options directive  
[16528] [Sat Oct 31 22:28:14 2015] [warning]: Use of uninitialized value in concatenation (.) or string at /usr/share/request-tracker4/lib/RT/Handle.pm line 240. (/usr/s
hare/request-tracker4/lib/RT/Handle.pm:239)  

RT couldn't connect to the database where tickets are stored.  
If this is a new installation of RT, you should visit the URL below
to configure RT and initialize your database.

If this is an existing RT installation, this may indicate a database
connectivity problem.

The error RT got back when trying to connect to your database was:

Couldn't find RT_System user in the DB ''

[16528] [Sat Oct 31 22:28:14 2015] [warning]: Use of uninitialized value in concatenation (.) or string at /usr/share/request-tracker4/lib/RT/Handle.pm line 240. (/usr/s
hare/request-tracker4/lib/RT/Handle.pm:239)
HTTP::Server::PSGI: Accepting connections at http://0:8080/
hesco commented 9 years ago

This changes the errors, but things are still unresolved. Perhaps after some sleep:

rt=# INSERT INTO users (id, name, password, comments, realname, 
        creator, created, lastupdatedby, lastupdated) 
        VALUES( 1, 'RT_System', '*NO-PASSWORD*', 
        'Do not delete or modify this user. It is integral to the RT internal database structures', 
        'The RT System itself', 1, now(), 1, now() );                                         

INSERT 0 1

rt=# INSERT INTO users (id, name, password, comments, realname, 
        creator, created, lastupdatedby, lastupdated) 
        VALUES( 2, 'Nobody', '*NO-PASSWORD*', 
        'Do not delete or modify this user. It is integral to the RT internal database structures', 
        'The RT System itself', 1, now(), 1, now() );

INSERT 0 1
hesco commented 9 years ago

Poking around in the installation I find this file: /usr/share/request-tracker4/etc/initialdata but again a recursive grep through the code shows nothing which seems to read and use it. This is beginning to smell like an issue with the debian package, and its postinstall script. That file defines complex data structures written in perl, but does nothing to apply them to the database. Perhaps it is the rt4-db-postgresql package which ought to be responsible for this. Still investigating this.

hesco commented 9 years ago

I found this link: https://bestpractical.com/docs/rt/4.0/initialdata.html#Running-an-initialdata-file

and then added this Exec[] resource:

  exec { 'seed_db_schema':
    environment => 'PGPASSFILE=/etc/request-tracker4/.pgpass',
    command     => "/usr/sbin/rt-setup-database-4 --action insert --datafile /usr/share/request-tracker4/etc/initialdata",
    require     => [ File['/etc/request-tracker4/.pgpass'],
                     Exec['deploy_db_schema'] ],
  }

I ran this query twice:

SELECT nextval('users_id_seq');

and the resource got successfully applied, and a manual check of the database shows some expected data in the tables.

But now I face this:

[28481] [Mon Nov  2 00:48:20 2015] [warning]: Use of uninitialized value in concatenation (.) or string at /usr/share/perl5/Plack/Handler/FCGI.pm line 115. (/usr/share/perl5/Plack/Handler/FCGI.pm:115)  
[28481] [Mon Nov  2 00:48:20 2015] [warning]: Use of uninitialized value in quotemeta at /usr/share/perl5/Plack/Handler/FCGI.pm line 117. (/usr/share/perl5/Plack/Handler/FCGI.pm:117)  
[28481] [Mon Nov  2 00:48:20 2015] [warning]: Use of uninitialized value $method in string ne at /usr/share/perl5/HTML/Mason/Utils.pm line 43. (/usr/share/perl5/HTML/Mason/Utils.pm:43)
[28481] [Mon Nov  2 00:48:20 2015] [warning]: Use of uninitialized value $method in string ne at /usr/share/perl5/HTML/Mason/Utils.pm line 43. (/usr/share/perl5/HTML/Mason/Utils.pm:43)  
[28481] [Mon Nov  2 00:48:20 2015] [warning]: The requested host (rt.example.com) does NOT match the configured WebDomain (localhost).  Perhaps you should Set($WebDomain, 'rt.example.com'); in RT_SiteConfig.pm, otherwise your internal links may be broken. (/usr/share/request-tracker4/lib/RT/Interface/Web.pm:1238)
[28481] [Mon Nov  2 00:48:20 2015] [warning]: binmode() on unopened filehandle GEN51 at /usr/share/perl5/Plack/Handler/FCGI.pm line 164. (/usr/share/perl5/Plack/Handler/FCGI.pm:164)  
[28481] [Mon Nov  2 00:48:20 2015] [warning]: print() on unopened filehandle GEN51 at /usr/share/perl5/Plack/Handler/FCGI.pm line 176. (/usr/share/perl5/Plack/Handler/FCGI.pm:176)
[28481] [Mon Nov  2 00:48:20 2015] [warning]: print() on unopened filehandle GEN51 at /usr/share/perl5/Plack/Handler/FCGI.pm line 178. (/usr/share/perl5/Plack/Handler/FCGI.pm:178)  
[28481] [Mon Nov  2 00:48:20 2015] [warning]: print() on unopened filehandle GEN51 at /usr/share/perl5/Plack/Handler/FCGI.pm line 178. (/usr/share/perl5/Plack/Handler/FCGI.pm:178)
[28481] [Mon Nov  2 00:48:20 2015] [warning]: print() on unopened filehandle GEN51 at /usr/share/perl5/Plack/Handler/FCGI.pm line 178. (/usr/share/perl5/Plack/Handler/FCGI.pm:178)  
[28481] [Mon Nov  2 00:48:20 2015] [warning]: print() on unopened filehandle GEN51 at /usr/share/perl5/Plack/Handler/FCGI.pm line 178. (/usr/share/perl5/Plack/Handler/FCGI.pm:178)

I ran a locate RT_SiteConfig.pm, but can not sort out why the logs report: 'configured WebDomain (localhost)'.

hesco commented 9 years ago

WebDomain has been set in the configuration.

Adding this code right after the first error, shows that REQUEST_URI is not defined in the environment: print STDERR Data::Dumper::Dumper $uri, $env; not sure how it is it should have gotten there, or why localhost is used on that line rather than the configured domain. I assume that is a plack thing.