Commit d8fe5d58 authored by Matthieu FAURE's avatar Matthieu FAURE
Browse files

REFACTOR code review

parent aea068b8
......@@ -41,7 +41,7 @@ $_ds_project_directory = "$_ds_home/demarches-simplifiees.fr"
$db_user_name = 'ds'
$db_name = 'ds'
$_ds_db_role = 'ds'
$db_user_password = 'kiki34' # /!\ TODO => Mettre un mot de passe sécurisé pour passer en prod
$db_user_password = 'kiki34' # /!\ Do not forget to change this passwd in production :)
$db_host = 'localhost'
$db_port = 3434
$db_test_name = 'tps_test'
......@@ -66,10 +66,10 @@ $preRequistes = [
'curl',
'autoconf',
'bison',
'libcurl4-openssl-dev',
'libpq-dev',
'chromium-browser',
'chromium-chromedriver',
'libcurl4-openssl-dev',
'libpq-dev',
]
package { $preRequistes:
......@@ -77,29 +77,11 @@ package { $preRequistes:
require => Class['apt::update'],
}
# TODO Package ne supporte par le provider npm, il faut donc passer par un exec pour ce package
# package { 'npm-install-peers':
# ensure => 'installed',
# provider => 'npm',
# install_options => ['/-g'],
# }
# CODE #############################################################################
# cloning repos of demarches-simplifiees to environnement of production.
# This part must be commented to set up a dev environnement.
#vcsrepo { "$_ds_project_directory":
# ensure => present,
# provider => git,
# source => $source_code_of_ds,
# user => $_system_username,
# require => User[$_system_username],
#}
# DEV environnement. Create a soft link on /shared_dev directory which is a share folder of your local project.
# Create a soft link on /shared_dev directory which is a share folder of your local project.
# Comment this part if you want to clone a repository installation.
file { $_ds_project_directory:
ensure => link,
target => "$local_source_code_of_ds",
ensure => link,
target => "$local_source_code_of_ds",
}
# Desactivation of IPv6
......@@ -111,55 +93,63 @@ sysctl { 'net.ipv6.conf.all.autoconf':
# #############################################################################
# PREREQUISITES Create and customize values of DB in .env
# Copy the file `config/env.example`, rename it to `.env` and put it at the root of the project as 'ds' user
# TODO Automatiser la modification du fichier avec un template est possible dans le cas d'un module puppet. Faire un module DS puppet.
-> file { "$_ds_project_directory/.env":
ensure => present,
source => "$_ds_project_directory/config/env.example",
# NOTE: once this code is transformed in a clear Puppet Module, all the file_lines should be treated with
# content => epp()
file { "$_ds_project_directory/.env":
ensure => present,
source => "$_ds_project_directory/config/env.example",
# content => epp('vagrant-demarches-simplifiees/env.epp'),
owner => $_system_username,
owner => $_system_username,
require => File[$_ds_project_directory],
}
# As long as this is not a pupet module, we don't use a template but 'file_line'.
# Puppuet module should use a template to set proper values.
# Set values for Database and Github Oauth token in config file '.env'
-> file_line { 'DB_DATABASE':
ensure => present,
path => "$_ds_project_directory/.env",
line => 'DB_DATABASE="ds"',
match => '^DB_DATABASE="tps_development"',
}
-> file_line { 'DB_USERNAME':
ensure => present,
path => "$_ds_project_directory/.env",
line => 'DB_USERNAME="ds"',
match => '^DB_USERNAME="tps_development"',
}
-> file_line { 'DB_PASSWORD':
ensure => present,
path => "$_ds_project_directory/.env",
line => 'DB_PASSWORD="kiki34"',
match => '^DB_PASSWORD="tps_development"',
}
-> file_line { 'GITHUB_CLIENT_ID':
ensure => present,
path => "$_ds_project_directory/.env",
line => 'GITHUB_CLIENT_ID="efb23e8a602aac61157c"',
match => '^GITHUB_CLIENT_ID=""',
}
-> file_line { 'GITHUB_CLIENT_SECRET':
ensure => present,
path => "$_ds_project_directory/.env",
line => 'GITHUB_CLIENT_SECRET="ec8f3370372bc4fb381f3f379d5320f1231c2189"',
match => '^GITHUB_CLIENT_SECRET=""',
}
#Modification of bin/setup file.
#As we already create the DB we don't need to recreate it.
file_line { 'DB_DATABASE':
ensure => present,
path => "$_ds_project_directory/.env",
line => 'DB_DATABASE="ds"',
match => '^DB_DATABASE="tps_development"',
require => File["$_ds_project_directory/.env"],
}
file_line { 'DB_USERNAME':
ensure => present,
path => "$_ds_project_directory/.env",
line => 'DB_USERNAME="ds"',
match => '^DB_USERNAME="tps_development"',
require => File["$_ds_project_directory/.env"],
}
file_line { 'DB_PASSWORD':
ensure => present,
path => "$_ds_project_directory/.env",
line => 'DB_PASSWORD="kiki34"',
match => '^DB_PASSWORD="tps_development"',
require => File["$_ds_project_directory/.env"],
}
file_line { 'GITHUB_CLIENT_ID':
ensure => present,
path => "$_ds_project_directory/.env",
line => 'GITHUB_CLIENT_ID="efb23e8a602aac61157c"',
match => '^GITHUB_CLIENT_ID=""',
require => File["$_ds_project_directory/.env"],
}
file_line { 'GITHUB_CLIENT_SECRET':
ensure => present,
path => "$_ds_project_directory/.env",
line => 'GITHUB_CLIENT_SECRET="ec8f3370372bc4fb381f3f379d5320f1231c2189"',
match => '^GITHUB_CLIENT_SECRET=""',
require => File["$_ds_project_directory/.env"],
}
# Modification of bin/setup file.
# As we already created the DB we don't need to recreate it.
file_line { 'db:setup':
ensure => present,
path => "$_ds_project_directory/bin/setup",
line => "system! 'bin/rails db:schema:load db:seed",
match => "^system! 'bin/rails db:setup'",
ensure => present,
path => "$_ds_project_directory/bin/setup",
line => "system! 'bin/rails db:schema:load db:seed",
match => "^system! 'bin/rails db:setup'",
require => File[$_ds_project_directory],
}
# #############################################################################
......@@ -172,36 +162,22 @@ class { 'rbenv':
rbenv::plugin { 'rbenv/ruby-build': }
-> rbenv::build { '2.6.5': global => true }
# Lorsque je précise le path à l'exec de bundle install, j'ai une erreur de droit sur /usr/bin/env
# Ensure permissions on /usr/bin/env
-> file { '/usr/bin/env':
ensure => file,
owner => "$_system_username",
}
# Fonctionne mais ne déroule pas toutes les gems, erreur sur curb, alors que tout se déroule correctement à la main :
# /Stage[main]/Main/Exec[/home/ds/rbenv/shims/bundle install]/returns: change from 'notrun' to ['0'] failed: '/home/ds/rbenv/shims/bundle install' returned 5 instead of one of [0]
# TODO A voir avec Fabien pour la syntaxe / bonne pratique (command et path)
# ->exec { "$_ds_home/rbenv/shims/bundle install":
# user => $_system_username,
# # path => "$_path_bundle",
# cwd => "$_ds_project_directory",
# timeout => '600',
# require => [
# Class['rbenv'],
# User[$_system_username],
# ]
# }
# #############################################################################
# PREREQUISITES Postgres
# This installs a PostgreSQL server
# This ensures a PostgreSQL server is installed
class { 'postgresql::server': }
# Define for granting membership to a role
# Grant membership to a role
postgresql::server::role { $_ds_db_role:
password_hash => postgresql_password($db_user_name, $db_user_password),
}
# Define for conveniently creating a role, database and assigning the correct permissions
# Create a role, database and assign the correct permissions
-> postgresql::server::db { $db_name:
user => $db_user_name,
password => postgresql_password($db_user_name, $db_user_password),
......@@ -244,10 +220,8 @@ file { 'PGPASS file':
}
# #############################################################################
# The desired version must be specified.
# PREREQUISITES nodejs
# Install nodejs
# The desired version must be specified.
class { 'nodejs':
repo_url_suffix => '12.x',
}
......@@ -255,9 +229,8 @@ class { 'nodejs':
# #############################################################################
# PREREQUISITES Yarn
# Install Yarn
# /!\ Il n'y a pas d'option pour spécifier la version installé. Par defaut il install la derniere.
# /!\ By default, last version is installed
class { 'yarn': }
# Ce module yarn se fait un peu vieux => 12.12.19 updated 3 months ago
# #############################################################################
# PREREQUISITES tmux
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment