Browse Source

Puppet script upgrade to LV 5.X

In order to allow IDP upgrade from
LV 4.x to LV 5.X
(https://review.openstack.org/#/c/305521/)
puppet and shell scripts
were update to support diferent versions
or laravel through config variable $laravel_version
( default value to version 4 so production would not
get affected ).

Change-Id: I76a7093f3c88c72256f638d5c56cc8799643b69d
Sebastian Marcet 2 years ago
parent
commit
75c6ce708b

+ 51
- 24
files/functions View File

@@ -51,26 +51,42 @@ function site_init {
51 51
     chown -R $FILE_OWNER:$FILE_GROUP $target_dir
52 52
     umask 0022
53 53
     # link configuration files managed by puppet
54
-    ln -sf /etc/openstackid/environment.php $target_dir/bootstrap/environment.php
55
-    ln -sf /etc/openstackid/recaptcha.php $target_dir/app/config/packages/greggilbert/recaptcha/$LARAVEL_ENV/config.php
56
-    ln -sf /etc/openstackid/database.php $target_dir/app/config/$LARAVEL_ENV/database.php
57
-    ln -sf /etc/openstackid/app.php $target_dir/app/config/$LARAVEL_ENV/app.php
58
-    ln -sf /etc/openstackid/log.php $target_dir/app/config/$LARAVEL_ENV/log.php
59
-    ln -sf /etc/openstackid/server.php $target_dir/app/config/$LARAVEL_ENV/server.php
60
-    ln -sf /etc/openstackid/mail.php $target_dir/app/config/$LARAVEL_ENV/mail.php
61
-    # convert app/storage into symlink and set permissions
62
-    mv $target_dir/app/storage $SITE_ROOT/
63
-    chmod 02770 $SITE_ROOT/storage
64
-    find $SITE_ROOT/storage/ -type d -exec chmod 0775 {} \;
65
-    find $SITE_ROOT/storage/ -type f -exec chmod 0664 {} \;
66
-    rm -rf $target_dir/app/storage
67
-    ln -s $SITE_ROOT/storage $target_dir/app
54
+
55
+    if [[ $LARAVEL_VERSION -eq 4 ]]; then
56
+        ln -sf /etc/openstackid/environment.php $target_dir/bootstrap/environment.php
57
+        ln -sf /etc/openstackid/recaptcha.php $target_dir/app/config/packages/greggilbert/recaptcha/$LARAVEL_ENV/config.php
58
+        ln -sf /etc/openstackid/database.php $target_dir/app/config/$LARAVEL_ENV/database.php
59
+        ln -sf /etc/openstackid/app.php $target_dir/app/config/$LARAVEL_ENV/app.php
60
+        ln -sf /etc/openstackid/log.php $target_dir/app/config/$LARAVEL_ENV/log.php
61
+        ln -sf /etc/openstackid/server.php $target_dir/app/config/$LARAVEL_ENV/server.php
62
+        ln -sf /etc/openstackid/mail.php $target_dir/app/config/$LARAVEL_ENV/mail.php
63
+        # convert app/storage into symlink and set permissions
64
+        mv $target_dir/app/storage $SITE_ROOT/
65
+        chmod 02770 $SITE_ROOT/storage
66
+        find $SITE_ROOT/storage/ -type d -exec chmod 0775 {} \;
67
+        find $SITE_ROOT/storage/ -type f -exec chmod 0664 {} \;
68
+        rm -rf $target_dir/app/storage
69
+        ln -s $SITE_ROOT/storage $target_dir/app
70
+    fi
71
+
72
+    if [[ $LARAVEL_VERSION -eq 5 ]]; then
73
+       ln -sf /etc/openstackid/.env $target_dir/.env
74
+       # convert app/storage into symlink and set permissions
75
+       mv $target_dir/storage $SITE_ROOT/
76
+       chmod 02770 $SITE_ROOT/storage
77
+       find $SITE_ROOT/storage/ -type d -exec chmod 0775 {} \;
78
+       find $SITE_ROOT/storage/ -type f -exec chmod 0664 {} \;
79
+       rm -rf $target_dir/storage
80
+       ln -s $SITE_ROOT/storage $target_dir
81
+    fi
82
+
68 83
     # populate application database
69 84
     cd $target_dir
70 85
     php artisan migrate --env=$LARAVEL_ENV
71 86
     if [[ $USE_DB_SEEDING -eq 1 ]]; then
72 87
         php artisan db:seed --env=$LARAVEL_ENV
73 88
     fi
89
+
74 90
     update_node
75 91
     install_bower
76 92
     # activate site
@@ -181,17 +197,28 @@ function site_update {
181 197
     fi
182 198
     chown -R $FILE_OWNER:$FILE_GROUP $target_dir
183 199
     umask 0022
200
+
184 201
     # link configuration files managed by puppet
185
-    ln -sf /etc/openstackid/environment.php $target_dir/bootstrap/environment.php
186
-    ln -sf /etc/openstackid/recaptcha.php $target_dir/app/config/packages/greggilbert/recaptcha/$LARAVEL_ENV/config.php
187
-    ln -sf /etc/openstackid/database.php $target_dir/app/config/$LARAVEL_ENV/database.php
188
-    ln -sf /etc/openstackid/app.php $target_dir/app/config/$LARAVEL_ENV/app.php
189
-    ln -sf /etc/openstackid/log.php $target_dir/app/config/$LARAVEL_ENV/log.php
190
-    ln -sf /etc/openstackid/server.php $target_dir/app/config/$LARAVEL_ENV/server.php
191
-    ln -sf /etc/openstackid/mail.php $target_dir/app/config/$LARAVEL_ENV/mail.php
192
-    # link shared app/storage directory
193
-    rm -rf $target_dir/app/storage
194
-    ln -s $SITE_ROOT/storage $target_dir/app
202
+    if [[ $LARAVEL_VERSION -eq 4 ]]; then
203
+        ln -sf /etc/openstackid/environment.php $target_dir/bootstrap/environment.php
204
+        ln -sf /etc/openstackid/recaptcha.php $target_dir/app/config/packages/greggilbert/recaptcha/$LARAVEL_ENV/config.php
205
+        ln -sf /etc/openstackid/database.php $target_dir/app/config/$LARAVEL_ENV/database.php
206
+        ln -sf /etc/openstackid/app.php $target_dir/app/config/$LARAVEL_ENV/app.php
207
+        ln -sf /etc/openstackid/log.php $target_dir/app/config/$LARAVEL_ENV/log.php
208
+        ln -sf /etc/openstackid/server.php $target_dir/app/config/$LARAVEL_ENV/server.php
209
+        ln -sf /etc/openstackid/mail.php $target_dir/app/config/$LARAVEL_ENV/mail.php
210
+        # link shared app/storage directory
211
+        rm -rf $target_dir/app/storage
212
+        ln -s $SITE_ROOT/storage $target_dir/app
213
+    fi
214
+
215
+    if [[ $LARAVEL_VERSION -eq 5 ]]; then
216
+        ln -sf /etc/openstackid/.env $target_dir/.env
217
+        # link shared app/storage directory
218
+        rm -rf $target_dir/storage
219
+        ln -s $SITE_ROOT/storage $target_dir
220
+    fi
221
+
195 222
     # populate application database
196 223
     cd $target_dir
197 224
     php artisan migrate --env=$LARAVEL_ENV

+ 148
- 90
manifests/init.pp View File

@@ -29,6 +29,7 @@ class openstackid (
29 29
   $ss_db_name = '',
30 30
   $redis_port = '',
31 31
   $redis_host = '',
32
+  $redis_db   = 0,
32 33
   $redis_password = '',
33 34
   $vhost_name = $::fqdn,
34 35
   $robots_txt_source = '',
@@ -62,19 +63,33 @@ class openstackid (
62 63
   $email_smtp_server_password = '',
63 64
   $use_db_seeding = false,
64 65
   $docroot = '/srv/openstackid/w/public',
66
+  $laravel_version = 4,
67
+  $app_log_level = 'error',
68
+  $app_log_email_level = 'error',
69
+  $db_log_enabled = false,
70
+  $banning_enabled = true,
71
+  $app_debug = false,
72
+  $app_locale = 'en',
73
+  $curl_verify_ssl_cert = true,
74
+  $curl_allow_redirect = false,
75
+  $curl_timeout = 60,
76
+  $assets_base_url = 'https://www.openstack.org/',
77
+  $cache_driver = 'redis',
78
+  $session_driver = 'redis',
79
+  $session_cookie_secure = false,
65 80
 ) {
66 81
 
67 82
   # php packages needed for openid server
68 83
   $php5_packages = [
69
-      'php5-common',
70
-      'php5-curl',
71
-      'php5-cli',
72
-      'php5-mcrypt',
73
-      'php5-mysqlnd',
74
-      'php5-fpm',
75
-      'php5-json',
76
-      'php5-gmp',
77
-    ]
84
+    'php5-common',
85
+    'php5-curl',
86
+    'php5-cli',
87
+    'php5-mcrypt',
88
+    'php5-mysqlnd',
89
+    'php5-fpm',
90
+    'php5-json',
91
+    'php5-gmp',
92
+  ]
78 93
 
79 94
   package { $php5_packages:
80 95
     ensure => present,
@@ -138,81 +153,99 @@ class openstackid (
138 153
     mode   => '0755',
139 154
   }
140 155
 
141
-  file { '/etc/openstackid/database.php':
142
-    ensure  => present,
143
-    content => template('openstackid/database.php.erb'),
144
-    owner   => 'root',
145
-    group   => 'www-data',
146
-    mode    => '0640',
147
-    require => [
148
-      File['/etc/openstackid'],
149
-    ]
150
-  }
156
+  if($laravel_version == 4 ){
151 157
 
152
-  file { '/etc/openstackid/app.php':
153
-    ensure  => present,
154
-    content => template('openstackid/app.php.erb'),
155
-    owner   => 'root',
156
-    group   => 'www-data',
157
-    mode    => '0640',
158
-    require => [
159
-      File['/etc/openstackid'],
160
-    ]
161
-  }
158
+      # laravel 4.X configuration files
159
+      file { '/etc/openstackid/database.php':
160
+        ensure  => present,
161
+        content => template('openstackid/lv4/database.php.erb'),
162
+        owner   => 'root',
163
+        group   => 'www-data',
164
+        mode    => '0640',
165
+        require => [
166
+          File['/etc/openstackid'],
167
+        ]
168
+      }
162 169
 
163
-  file { '/etc/openstackid/log.php':
164
-      ensure  => present,
165
-      content => template('openstackid/log.php.erb'),
166
-      owner   => 'root',
167
-      group   => 'www-data',
168
-      mode    => '0640',
169
-      require => [
170
-        File['/etc/openstackid'],
171
-      ]
172
-  }
170
+      file { '/etc/openstackid/app.php':
171
+        ensure  => present,
172
+        content => template('openstackid/lv4/app.php.erb'),
173
+        owner   => 'root',
174
+        group   => 'www-data',
175
+        mode    => '0640',
176
+        require => [
177
+          File['/etc/openstackid'],
178
+        ]
179
+      }
173 180
 
174
-  file { '/etc/openstackid/environment.php':
175
-      ensure  => present,
176
-      content => template('openstackid/environment.php.erb'),
177
-      owner   => 'root',
178
-      group   => 'www-data',
179
-      mode    => '0640',
180
-      require => [
181
-        File['/etc/openstackid'],
182
-      ]
183
-  }
181
+      file { '/etc/openstackid/log.php':
182
+        ensure  => present,
183
+        content => template('openstackid/lv4/log.php.erb'),
184
+        owner   => 'root',
185
+        group   => 'www-data',
186
+        mode    => '0640',
187
+        require => [
188
+          File['/etc/openstackid'],
189
+        ]
190
+      }
184 191
 
185
-  file { '/etc/openstackid/recaptcha.php':
192
+      file { '/etc/openstackid/environment.php':
186 193
         ensure  => present,
187
-        content => template('openstackid/recaptcha.php.erb'),
194
+        content => template('openstackid/lv4/environment.php.erb'),
188 195
         owner   => 'root',
189 196
         group   => 'www-data',
190 197
         mode    => '0640',
191 198
         require => [
192 199
           File['/etc/openstackid'],
193 200
         ]
194
-  }
201
+      }
195 202
 
196
-  file { '/etc/openstackid/server.php':
203
+      file { '/etc/openstackid/recaptcha.php':
197 204
         ensure  => present,
198
-        content => template('openstackid/server.php.erb'),
205
+        content => template('openstackid/lv4/recaptcha.php.erb'),
199 206
         owner   => 'root',
200 207
         group   => 'www-data',
201 208
         mode    => '0640',
202 209
         require => [
203 210
           File['/etc/openstackid'],
204 211
         ]
205
-  }
212
+      }
213
+
214
+      file { '/etc/openstackid/server.php':
215
+        ensure  => present,
216
+        content => template('openstackid/lv4/server.php.erb'),
217
+        owner   => 'root',
218
+        group   => 'www-data',
219
+        mode    => '0640',
220
+        require => [
221
+          File['/etc/openstackid'],
222
+        ]
223
+      }
224
+
225
+      file { '/etc/openstackid/mail.php':
226
+        ensure  => present,
227
+        content => template('openstackid/lv4/mail.php.erb'),
228
+        owner   => 'root',
229
+        group   => 'www-data',
230
+        mode    => '0640',
231
+        require => [
232
+          File['/etc/openstackid'],
233
+        ]
234
+      }
206 235
 
207
-  file { '/etc/openstackid/mail.php':
208
-    ensure  => present,
209
-    content => template('openstackid/mail.php.erb'),
210
-    owner   => 'root',
211
-    group   => 'www-data',
212
-    mode    => '0640',
213
-    require => [
214
-      File['/etc/openstackid'],
215
-    ]
236
+  }
237
+  else
238
+  {
239
+      file { '/etc/openstackid/.env':
240
+        ensure  => present,
241
+        content => template('openstackid/lv5/.env.erb'),
242
+        owner   => 'root',
243
+        group   => 'www-data',
244
+        mode    => '0640',
245
+        require => [
246
+          File['/etc/openstackid'],
247
+        ]
248
+    }
216 249
   }
217 250
 
218 251
   $docroot_dirs = [ '/srv/openstackid' ]
@@ -229,7 +262,7 @@ class openstackid (
229 262
     mpm_module    => false,
230 263
   }
231 264
 
232
-  # apache mpm event connectio tweaking
265
+  # apache mpm event connection tweaking
233 266
   class {'::apache::mod::event':
234 267
     serverlimit         => 128,
235 268
     startservers        => 3,
@@ -314,24 +347,60 @@ class openstackid (
314 347
     require => Deploy['deploytool'],
315 348
   }
316 349
 
350
+  if($laravel_version == 4 ){
351
+
352
+    $deploy_site_requires =  [
353
+        File['/opt/deploy/conf.d/openstackid.conf'],
354
+        Apache::Vhost::Custom[$vhost_name],
355
+        File['/etc/openstackid/recaptcha.php'],
356
+        File['/etc/openstackid/database.php'],
357
+        File['/etc/openstackid/log.php'],
358
+        File['/etc/openstackid/environment.php'],
359
+        File['/etc/openstackid/server.php'],
360
+        File['/etc/openstackid/app.php'],
361
+        Package['curl'],
362
+        Package[$php5_packages] ,
363
+        Class['::nodejs'],
364
+    ]
365
+
366
+    $update_site_requires = [
367
+        File['/opt/deploy/conf.d/openstackid.conf'],
368
+        Apache::Vhost::Custom[$vhost_name],
369
+        File['/etc/openstackid/recaptcha.php'],
370
+        File['/etc/openstackid/database.php'],
371
+        File['/etc/openstackid/app.php'],
372
+        File['/etc/openstackid/log.php'],
373
+        File['/etc/openstackid/environment.php'],
374
+        File['/etc/openstackid/server.php'],
375
+        Package[$php5_packages] ,
376
+        Class['::nodejs'],
377
+    ]
378
+  }
379
+  else{
380
+    $deploy_site_requires =  [
381
+        File['/opt/deploy/conf.d/openstackid.conf'],
382
+        Apache::Vhost::Custom[$vhost_name],
383
+        File['/etc/openstackid/.env'],
384
+        Package['curl'],
385
+        Package[$php5_packages] ,
386
+        Class['::nodejs'],
387
+    ]
388
+
389
+    $update_site_requires = [
390
+        File['/opt/deploy/conf.d/openstackid.conf'],
391
+        Apache::Vhost::Custom[$vhost_name],
392
+        File['/etc/openstackid/.env'],
393
+        Package[$php5_packages] ,
394
+        Class['::nodejs'],
395
+    ]
396
+  }
397
+
317 398
   exec { 'deploy-site':
318 399
     path      => '/usr/local/bin:/usr/bin:/bin',
319 400
     command   => '/opt/deploy/deploy.sh init openstackid',
320 401
     onlyif    => '/opt/deploy/deploy.sh status openstackid | grep N/A',
321 402
     logoutput => on_failure,
322
-    require   => [
323
-      File['/opt/deploy/conf.d/openstackid.conf'],
324
-      Apache::Vhost::Custom[$vhost_name],
325
-      File['/etc/openstackid/recaptcha.php'],
326
-      File['/etc/openstackid/database.php'],
327
-      File['/etc/openstackid/log.php'],
328
-      File['/etc/openstackid/environment.php'],
329
-      File['/etc/openstackid/server.php'],
330
-      File['/etc/openstackid/app.php'],
331
-      Package['curl'],
332
-      Package[$php5_packages] ,
333
-      Class['::nodejs'],
334
-    ],
403
+    require   => $deploy_site_requires,
335 404
   }
336 405
 
337 406
   exec { 'update-site':
@@ -339,18 +408,7 @@ class openstackid (
339 408
     command   => '/opt/deploy/deploy.sh update openstackid',
340 409
     onlyif    => '/opt/deploy/deploy.sh status openstackid | grep UPDATE',
341 410
     logoutput => on_failure,
342
-    require   => [
343
-      File['/opt/deploy/conf.d/openstackid.conf'],
344
-      Apache::Vhost::Custom[$vhost_name],
345
-      File['/etc/openstackid/recaptcha.php'],
346
-      File['/etc/openstackid/database.php'],
347
-      File['/etc/openstackid/app.php'],
348
-      File['/etc/openstackid/log.php'],
349
-      File['/etc/openstackid/environment.php'],
350
-      File['/etc/openstackid/server.php'],
351
-      Package[$php5_packages] ,
352
-      Class['::nodejs'],
353
-    ],
411
+    require   => $update_site_requires,
354 412
   }
355 413
 
356 414
   # system configuration tweaking

templates/app.php.erb → templates/lv4/app.php.erb View File


templates/database.php.erb → templates/lv4/database.php.erb View File

@@ -87,7 +87,7 @@ return array(
87 87
      'default' => array(
88 88
      'host' => '<%= @redis_host %>',
89 89
      'port' => <%= @redis_port %>,
90
-     'database' => 0,
90
+     'database' => <%= @redis_db %>,
91 91
      'password' => '<%= @redis_password %>'
92 92
     ),
93 93
   ),

templates/environment.php.erb → templates/lv4/environment.php.erb View File


templates/log.php.erb → templates/lv4/log.php.erb View File


templates/mail.php.erb → templates/lv4/mail.php.erb View File


templates/recaptcha.php.erb → templates/lv4/recaptcha.php.erb View File


templates/server.php.erb → templates/lv4/server.php.erb View File


+ 60
- 0
templates/lv5/.env.erb View File

@@ -0,0 +1,60 @@
1
+APP_ENV="<%= @id_environment %>"
2
+APP_DEBUG=<%= @app_debug %>
3
+APP_KEY="<%= @app_key %>"
4
+APP_URL="<%= @app_url %>"
5
+APP_LOG=daily
6
+APP_TIMEZONE="<%= @app_timezone %>"
7
+APP_LOCALE="<%= @app_locale %>"
8
+APP_VERSION="<%= @app_version %>"
9
+
10
+DB_HOST="<%= @id_mysql_host %>"
11
+DB_DATABASE="<%= @id_db_name %>"
12
+DB_USERNAME="<%= @id_mysql_user %>"
13
+DB_PASSWORD="<%= @id_mysql_password %>"
14
+
15
+SS_DB_DRIVER=mysql
16
+SS_DB_HOST="<%= @ss_mysql_host %>"
17
+SS_DATABASE="<%= @ss_db_name %>"
18
+SS_DB_USERNAME="<%= @ss_mysql_user %>"
19
+SS_DB_PASSWORD="<%= @ss_mysql_password %>"
20
+
21
+REDIS_HOST="<%= @redis_host %>"
22
+REDIS_PORT=<%= @redis_port %>
23
+REDIS_DB=<%= @redis_db %>
24
+REDIS_PASSWORD="<%= @redis_password %>"
25
+
26
+CACHE_DRIVER="<%= @cache_driver %>"
27
+
28
+SESSION_DRIVER="<%= @session_driver %>"
29
+SESSION_COOKIE_SECURE=<%= @session_cookie_secure %>
30
+
31
+MAIL_DRIVER=<%= @email_driver %>
32
+MAIL_HOST=<%= @email_smtp_server %>
33
+MAIL_PORT=<%= @email_smtp_server_port %>
34
+MAIL_USERNAME="<%= @email_smtp_server_user %>"
35
+MAIL_PASSWORD="<%= @email_smtp_server_password %>"
36
+
37
+CORS_ALLOWED_HEADERS="origin, content-type, accept, authorization, x-requested-with"
38
+CORS_ALLOWED_METHODS="GET, POST, OPTIONS, PUT, DELETE"
39
+CORS_USE_PRE_FLIGHT_CACHING=false
40
+CORS_MAX_AGE=3200
41
+CORS_EXPOSED_HEADERS=
42
+
43
+CURL_TIMEOUT=<%= @curl_timeout %>
44
+CURL_ALLOWS_REDIRECT=<%= @curl_allow_redirect %>
45
+CURL_VERIFY_SSL_CERT=<%= @curl_verify_ssl_cert %>
46
+
47
+ASSETS_BASE_URL="<%= @assets_base_url %>"
48
+SSL_ENABLED=<%= @ssl_enable %>
49
+DB_LOG_ENABLED=<%= @db_log_enabled %>
50
+
51
+BANNING_ENABLE=<%= @banning_enabled %>
52
+
53
+LOG_EMAIL_TO="<%= @id_log_error_to_email %>"
54
+LOG_EMAIL_FROM="<%= @id_log_error_from_email %>"
55
+LOG_LEVEL="<%= @app_log_level %>"
56
+LOG_EMAIL_LEVEL="<%= @app_log_email_level %>"
57
+
58
+RECAPTCHA_PUBLIC_KEY="<%= @id_recaptcha_public_key %>"
59
+RECAPTCHA_PRIVATE_KEY="<%= @id_recaptcha_private_key %>"
60
+RECAPTCHA_TEMPLATE="<%= @id_recaptcha_template %>"

+ 2
- 1
templates/openstackid.conf.erb View File

@@ -3,4 +3,5 @@ SOURCE_TARBALL=http://tarballs.openstack.org/openstackid/openstackid-<%= @openst
3 3
 LARAVEL_ENV=<%= @id_environment %>
4 4
 RELEASE_NAME=openstackid-<%= @openstackid_release %>.tar.gz
5 5
 SOURCE_ROOT=http://tarballs.openstack.org/openstackid/
6
-USE_DB_SEEDING=<%= @use_db_seeding?1:0 %>
6
+USE_DB_SEEDING=<%= @use_db_seeding?1:0 %>
7
+LARAVEL_VERSION=<%= @laravel_version %>

Loading…
Cancel
Save