Skip to content
Snippets Groups Projects
Commit d8c2092f authored by Matthieu FAURE's avatar Matthieu FAURE
Browse files

REFACTOR parameter names

parent 22e1c280
No related branches found
No related tags found
No related merge requests found
......@@ -2,36 +2,43 @@
#
# @summary Install and configure Comptoir Du Libre
#
# @param comptoir_user Username of Unix account holding Comptoir du Libre application
# @param comptoir_repos_url URL of Comptoir repos in HTTPS mode (not in git mode)
# @param comptoir_revision Revision of Comptoir repos as understood by module VCSRepos, may be a branch, a tag, a SHA-1
# @param comptoir_db_password Password for the database user
# @param system_user Username of Unix account holding Comptoir du Libre application
# @param refspec Revision of Comptoir repos as understood by module VCSRepos, may be a branch, a tag, a SHA-1
# @param comptoir_db_user Database username owning the database for the application
# @param comptoir_db_user Database username owning
# @param comptoir_db_password PAssword for the user of the database
# @param comptoir_db_name Database name to be used for the application
# @param comptoir_db_host Name of the database host, must an FQDN or an IP address
# @param comptoir_db_port Port of the database host, must an integer
# @param apache_user System user running Apache, typically www-data
# @param debug Install Comptoir in dev mode with debug activated
#
# @example
# include comptoir
class comptoir (
String $comptoir_user = 'comptoir',
Stdlib::Httpsurl $comptoir_repos_url = 'https://gitlab.adullact.net/Comptoir/Comptoir-srv.git',
String $comptoir_revision = 'master',
String $comptoir_db_user = 'comptoir',
String $comptoir_db_name = 'comptoir',
String $comptoir_db_password = 'comptoir',
String $comptoir_db_host = 'localhost',
String $comptoir_db_port = '5432',
String $apache_user = 'www-data',
Boolean $debug = false,
# Mandatory parameter: DB password
String $comptoir_db_password,
# Comptoir app parameters
String $system_user = 'comptoir',
String $refspec = 'master',
Boolean $debug = false,
# DB parameters
String $comptoir_db_host = 'localhost',
String $comptoir_db_port = '5432',
String $comptoir_db_username = 'comptoir',
String $comptoir_db_name = 'comptoir',
) {
# #############################################################################
# Variables
$comptoir_repos_url = 'https://gitlab.adullact.net/Comptoir/Comptoir-srv.git'
# Inner variables
$_comptoir_dir = join( [ '/home/', $comptoir_user, '/', basename($comptoir_repos_url, '.git') ])
$_comptoir_dir = join([ '/home/', $system_user, '/', basename($comptoir_repos_url, '.git') ])
$_sql_create_tables_and_procedure = 'config/SQL/COMPTOIR_DB_create_tables_and_procedures.sql'
$_file_app_php = "${_comptoir_dir}/config/app.php"
$_file_comptoir_php = "${_comptoir_dir}/config/comptoir.php"
$_psql_create_table_cmd = "\\i ${_comptoir_dir}/${_sql_create_tables_and_procedure}"
$_my_sed = '/bin/sed -i -e'
$_sed_barman_dev =
......@@ -42,8 +49,8 @@ class comptoir (
ensure => present,
provider => git,
source => $comptoir_repos_url,
revision => $comptoir_revision,
user => $comptoir_user,
revision => $refspec,
user => $system_user,
force => true, # See https://forge.puppet.com/puppetlabs/vcsrepo#force
}
......@@ -56,14 +63,14 @@ class comptoir (
postgresql_psql { 'Create SQL tables & procedures':
command => $_psql_create_table_cmd,
db => $comptoir_db_name,
psql_user => $comptoir_db_user,
psql_user => $comptoir_db_username,
}
# Install app with Composer
-> exec { 'composer install':
command => '/usr/local/bin/composer --no-progress install',
cwd => $_comptoir_dir,
user => $comptoir_user,
user => $system_user,
environment => [ 'HOME=/home/comptoir' ],
timeout => 1200, # default value (300s) * 4
}
......@@ -73,7 +80,7 @@ class comptoir (
exec { 'Comptoir APP.PHP enable debug':
command => "${_my_sed} 's!//COMPTOIR-DEBUG!!' ${_file_app_php}",
cwd => $_comptoir_dir,
user => $comptoir_user,
user => $system_user,
environment => [ 'HOME=/home/comptoir' ],
onlyif => "/bin/grep '//COMPTOIR-DEBUG' ${_file_app_php}",
require => Exec['composer install'],
......@@ -81,7 +88,7 @@ class comptoir (
-> exec { 'Comptoir APP.PHP barman-DEV':
command => "${_my_sed} ${_sed_barman_dev} ${_file_app_php}",
cwd => $_comptoir_dir,
user => $comptoir_user,
user => $system_user,
environment => [ 'HOME=/home/comptoir' ],
unless => "/bin/grep 'barman-DEV' ${_file_app_php}",
}
......@@ -91,7 +98,7 @@ class comptoir (
exec { 'Comptoir APP.PHP salt':
command => "${_my_sed} 's/__SALT__/somerandomsalt/' ${_file_app_php}",
cwd => $_comptoir_dir,
user => $comptoir_user,
user => $system_user,
environment => [ 'HOME=/home/comptoir' ],
onlyif => "/bin/grep '__SALT__' ${_file_app_php}",
require => Exec['composer install'],
......@@ -99,7 +106,7 @@ class comptoir (
-> exec { 'Comptoir APP.PHP Session default':
command => "${_my_sed} \"s!'php',!env('SESSION_DEFAULTS', 'php'), !\" ${_file_app_php}",
cwd => $_comptoir_dir,
user => $comptoir_user,
user => $system_user,
unless => "/bin/grep 'SESSION_DEFAULTS' ${_file_app_php}",
}
......@@ -108,7 +115,7 @@ class comptoir (
ensure => present,
path => $_file_comptoir_php,
content => template('comptoir/comptoir.php.epp'),
owner => $comptoir_user,
owner => $system_user,
require => Exec['composer install'],
}
......@@ -116,14 +123,14 @@ class comptoir (
exec { 'chmod -R o-w Comptoir-srv/tmp':
command => "/bin/chmod -R o-w ${_comptoir_dir}/tmp",
cwd => $_comptoir_dir,
user => $comptoir_user,
user => $system_user,
onlyif => "/usr/bin/find ${_comptoir_dir}/tmp/ -maxdepth 0 -perm -o=w",
require => Exec['composer install'],
}
exec { 'chmod -R o-w Comptoir-srv/logs':
command => "/bin/chmod -R o-w ${_comptoir_dir}/logs",
cwd => $_comptoir_dir,
user => $comptoir_user,
user => $system_user,
onlyif => "/usr/bin/find ${_comptoir_dir}/logs/ -maxdepth 0 -perm -o=w",
require => Exec['composer install'],
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment