Puppet Class: twlight::configsys

Inherits:
twlight
Defined in:
manifests/configsys.pp

Overview



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'manifests/configsys.pp', line 1

class twlight::configsys inherits twlight {

  # Create user to execute virtual environment and gunicorn
  user { $unixname:
    ensure     => present,
    comment    => 'twlight user',
    shell      => '/bin/bash',
    managehome => true,
  }

  # Delete the database so we can change the block size
  $ib1_files = ['ibdata1', 'ib_logfile0', 'ib_logfile1']

  $ib1_files.each |String $ib1_file| {
    File {"/var/lib/mysql/${ib1_file}":
      ensure  => 'absent',
    }
  }

  # config mariadb server using another module
  class {'::mysql::server':
    package_manage          => false,
    service_name            => 'mysql',
    root_password           => $mysqlroot_pw,
    remove_default_accounts => true,
    override_options        => $mysql_override_options,
    restart                 => true,
    require                 => Package['mariadb-server'],
  }

  case $operatingsystemrelease {
    /^8.*/: {
      # needed since libmariadb-client-lgpl-dev is providing client development files.
      file { '/usr/bin/mysql_config':
        ensure  => 'link',
        target  => '/usr/bin/mariadb_config',
        require => Package['libmariadb-client-lgpl-dev'],
      }
    }
    /^9.*/: {
      # needed since MYSQL-python has issues with libmariadb-dev
      # https://github.com/DefectDojo/django-DefectDojo/issues/407
      exec { 'hack_libmariadb_dev':
        command     => "/bin/sed '/st_mysql_options options;/a unsigned int reconnect;' /usr/include/mysql/mysql.h -i.bkp",
        require     => Package['libmariadb-dev'],
      }
    }
  }

  # Load timezone tables into mysql on refresh
  exec { 'mysql_tzinfo':
    command     => "/usr/bin/mysql_tzinfo_to_sql /usr/share/zoneinfo | /usr/bin/mysql --user root --password=${mysqlroot_pw} mysql",
  }

  class {'::mysql::client':
    package_manage          => false,
    require => Package['mariadb-client'],
  }

  # Create twlight database
  # CREATE DATABASE twlight;
  # GRANT ALL PRIVILEGES on twlight.* to twlight@'localhost' IDENTIFIED BY '<password>';
  mysql::db { 'twlight':
    user     => 'twlight',
    password => $mysqltwlight_pw,
    host     => 'localhost',
    grant    => ['ALL'],
    #require => Package['mariadb-client', 'mariadb-server'],
  }

  # Create twlight test database
  # CREATE DATABASE test_twlight;
  # GRANT ALL PRIVILEGES on test_twlight.* to test_twlight@'localhost' IDENTIFIED BY '<password>';
  mysql::db { 'test_twlight':
    user     => 'twlight',
    password => $mysqltwlight_pw,
    host     => 'localhost',
    grant    => ['ALL'],
    #require => Package['mariadb-client', 'mariadb-server'],
  }

  # www dir
  file { '/var/www':
    ensure => 'directory',
    owner  => '33',
    group  => '33',
    mode   => '0755',
  }

  # www/html dir
  file { '/var/www/html':
    ensure => 'directory',
    owner  => '33',
    group  => '33',
    mode   => '0755',
  }

  # nginx config
  file {'/etc/nginx/nginx.conf':
    mode   => '0644',
    owner  => '33',
    group  => '33',
    source => 'puppet:///modules/twlight/nginx.conf.webserver',
    notify => Exec['nginx_reload']
  }

  # remove default nginx site
  file {'/etc/nginx/sites-enabled/default':
    ensure => 'absent',
    notify => Exec['nginx_reload']
  }

  # nginx is running
  service { 'nginx':
    ensure => 'running',
  }
}