Commit 8d468a0c authored by Matthieu FAURE's avatar Matthieu FAURE

Fix #9

parent 1e1b483f
Pipeline #5948 passed with stages
in 3 minutes and 10 seconds
......@@ -629,8 +629,8 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Puppet-Amies
Copyright (C) 2019 AMIES
Puppet-DirectMairie
Copyright (C) 2019 Adullact
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
......
# Amies
# DirectMairie
## Table of Contents
1. [Description](#description)
2. [Setup - The basics of getting started with amies](#setup)
* [What amies affects](#what-amies-affects)
2. [Setup - The basics of getting started with directmairie](#setup)
* [What directmairie affects](#what-directmairie-affects)
* [Setup requirements](#setup-requirements)
* [Beginning with amies](#beginning-with-amies)
* [Beginning with directmairie](#beginning-with-directmairie)
3. [Usage - Configuration options and additional functionality](#usage)
4. [Limitations - OS compatibility, etc.](#limitations)
5. [Development - Guide for contributing to the module](#development)
## Description
This module installs dans configure the application AMIES.
This module installs and configures the application DirectMairie.
## Setup
### What amies affects
### What directmairie affects
This module does following things dedicated to AMIES:
This module does following things dedicated to DirectMairie:
* creation of a system user;
* installation of needed system packages
* Postgres: creation of role, user and database
* creation of files for AMIES
* creation of files for DirectMairie
### Setup Requirements
* Being able to send emails (postfix, sendmail or any mail relay)
* Postgres 9.4+ installed
### Beginning with amies
### Beginning with directmairie
The very basic steps needed for a user to get the module up and running. This can include setup steps, if necessary, or it can be an example of the most basic use of the module.
......
---
amies::dummyVar: 'DUMMY so no warning risen for an allegedly malformed YAML :) '
\ No newline at end of file
directmairie::dummyVar: 'DUMMY so no warning risen for an allegedly malformed YAML :) '
---
amies::package_list:
directmairie::package_list:
- 'git'
- 'openjdk-8-jdk'
# @summary Install and configure AMIES
# @summary Install and configure DirectMairie
#
# Install and configure AMIES, the open source citizen participation tool for cities streets
# Install and configure DirectMairie, the open source citizen participation tool for cities streets
#
# @example
# class { 'amies':
# class { 'directmairie':
# smtp_host => 'smtp.example.org',
# smtp_port => 587,
# smtp_user_name => 'KateBush@example.org',
# smtp_user_passwd => 'RunningUpThatHill!',
# app_dir => '/home/amies/AMIES',
# picture_dir => '/home/amies/AMIES-pictures',
# app_dir => '/home/directmairie/DirectMairie',
# picture_dir => '/home/directmairie/DirectMairie-pictures',
# security_key => '0123654789abcdefghijklm',
# ci_job_name => 'myJob',
# db_user_password => 'S3cr#TPassw0rdz',
......@@ -22,35 +22,35 @@
# @param app_dir Directory in which application will be copied
# @param picture_dir Directory holding user-uploaded pictures (may be fat)
# @param security_key Secret key for the application (used as salt)
# @param ci_job_name Gitlab CI job name from which to download AMIES jar file
# @param db_user_password Password for Amies database
# @param ci_job_name Gitlab CI job name from which to download DirectMairie jar file
# @param db_user_password Password for DirectMairie database
# @param package_list List of packages to be installed beforehand (stored in Hiera)
class amies (
class directmairie (
String $smtp_host,
Integer $smtp_port,
String $smtp_user_name,
String $smtp_user_passwd,
# Directory for AMIES application, eg /home/amies/AMIES
# Directory for DirectMairie application, eg /home/directmairie/DirectMairie
String $app_dir,
# Directory for users uploaded pictures
String $picture_dir,
# Secret key (used as salt)
String $security_key,
# CI Job name from which downloading amies jar file (build artefact)
# CI Job name from which downloading directmairie jar file (build artefact)
String $ci_job_name,
# Password for Amies database
# Password for DirectMairie database
String $db_user_password,
Array $package_list, # Value of $package_list are specified in Hiera
# Git refspec to download Amies (can be branch, a tag, or a commit)
# Git refspec to download DirectMairie (can be branch, a tag, or a commit)
String $refspec = 'master',
String $db_host = 'localhost',
Integer $db_port = 5432,
String $db_name = 'amies',
String $db_for_tests_name = 'amies_test',
String $db_user_name = 'amies',
String $system_username = 'amies',
String $db_name = 'directmairie',
String $db_for_tests_name = 'directmairie_test',
String $db_user_name = 'directmairie',
String $system_username = 'directmairie',
# Activate debug / dev mode
Boolean $debug = false,
) {
......@@ -59,32 +59,32 @@ class amies (
# Variables
$_gitlab_srv = 'gitlab.adullact.net'
$_gitlab_group = 'amies'
$_gitlab_project_name = 'amies-server'
$_gitlab_group = 'directmairie'
$_gitlab_project_name = 'directmairie'
# URL of AMIES source code repository
$_amies_gitlab_full_url = "${_gitlab_srv}/${_gitlab_group}/${_gitlab_project_name}"
# URL of AMIES jar file (grabbed from a CI job)
# URL of DirectMairie source code repository
$_directmairie_gitlab_full_url = "${_gitlab_srv}/${_gitlab_group}/${_gitlab_project_name}"
# URL of DirectMairie jar file (grabbed from a CI job)
# see https://docs.gitlab.com/ee/user/project/pipelines/job_artifacts.html#downloading-the-latest-artifacts
$_amies_jar_url = join(
$_directmairie_jar_url = join(
[
"https://${_amies_gitlab_full_url}",
"/-/jobs/artifacts/${refspec}/raw/backend/build/libs/amies.jar",
"https://${_directmairie_gitlab_full_url}",
"/-/jobs/artifacts/${refspec}/raw/backend/build/libs/amies.jar", # TODO rename once renamed in upstream
"?job=${ci_job_name}",
]
)
# Filename of AMIES jar file (build artefact)
$_jar_name = 'amies.jar'
# Filename of DirectMairie jar file (build artefact)
$_jar_name = 'directmairie.jar'
# Postgres role for Amies
$_amies_db_role = 'amies'
# Postgres role for DirectMairie
$_directmairie_db_role = 'directmairie'
# JDBC URL string
$_amies_jdbc_url = "jdbc:postgresql://${db_host}:${db_port}/${db_name}"
$_directmairie_jdbc_url = "jdbc:postgresql://${db_host}:${db_port}/${db_name}"
# #############################################################################
# PREREQUISITES packages
package { $amies::package_list:
package { $directmairie::package_list:
ensure => present,
}
......@@ -92,7 +92,7 @@ class amies (
# PREREQUISITES Postgres
# Role creation
postgresql::server::role { $_amies_db_role:
postgresql::server::role { $_directmairie_db_role:
password_hash => postgresql_password($db_user_name, $db_user_password),
}
......@@ -106,11 +106,11 @@ class amies (
-> postgresql::server::database_grant { $db_name:
privilege => 'ALL',
db => $db_name,
role => $_amies_db_role,
role => $_directmairie_db_role,
}
# Create DB needed for running tests
if $amies::debug {
if $directmairie::debug {
postgresql::server::db { $db_for_tests_name:
user => $db_user_name,
password => postgresql_password($db_user_name, $db_user_password),
......@@ -118,16 +118,16 @@ class amies (
postgresql::server::database_grant { $db_for_tests_name:
privilege => 'ALL',
db => $db_for_tests_name,
role => $_amies_db_role,
require => Postgresql::Server::Role[$_amies_db_role],
role => $_directmairie_db_role,
require => Postgresql::Server::Role[$_directmairie_db_role],
}
}
# #############################################################################
# Prepare AMIES
# Prepare DirectMairie
# Create directory for users uploaded pictures
file { 'AMIES picture dir':
file { 'DirectMairie picture dir':
ensure => directory,
path => $picture_dir,
mode => '0700',
......@@ -135,32 +135,32 @@ class amies (
}
# Create systemd unit-file
file { 'AMIES systemd unit':
file { 'DirectMairie systemd unit':
ensure => file,
path => '/etc/systemd/system/amies.service',
path => '/etc/systemd/system/directmairie.service',
mode => '0644',
content => epp('amies/amies.service.epp'),
require => Archive['download-amies-jar'],
content => epp('directmairie/directmairie.service.epp'),
require => Archive['download-directmairie-jar'],
}
# Get AMIES jar file
archive { 'download-amies-jar':
# Get DirectMairie jar file
archive { 'download-directmairie-jar':
ensure => 'present',
path => "${amies::app_dir}/${amies::_jar_name}",
source => $_amies_jar_url,
path => "${directmairie::app_dir}/${directmairie::_jar_name}",
source => $_directmairie_jar_url,
}
# #############################################################################
# Launch AMIES
# Launch DirectMairie
service { 'launch AMIES':
service { 'launch DirectMairie':
ensure => 'running',
name => 'amies',
name => 'directmairie',
enable => true,
require => [
Package[$amies::package_list],
File['AMIES systemd unit'],
Package[$directmairie::package_list],
File['DirectMairie systemd unit'],
Postgresql::Server::Database_grant[$db_name],
]
}
......
{
"name": "adullact-amies",
"name": "adullact-directmairie",
"version": "1.0.0",
"author": "adullact",
"summary": "",
......
require 'spec_helper'
describe 'amies' do
describe 'directmairie' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) do
......@@ -15,8 +15,8 @@ describe 'amies' do
smtp_port: 587,
smtp_user_name: 'katebush@example.org',
smtp_user_passwd: 'RunningUpThatHill!',
app_dir: '/home/amies/AMIES',
picture_dir: '/home/amies/AMIES-pictures',
app_dir: '/home/directmairie/DirectMairie',
picture_dir: '/home/directmairie/DirectMairie-pictures',
security_key: '0123654789abcdefghijklm',
ci_job_name: 'myJob',
db_user_password: 'S3cr#TPassw0rdz',
......
[Unit]
Description=AMIES
After=syslog.target
[Service]
User=amies
ExecStart=/usr/bin/java -jar "<%= $amies::app_dir %>/<%= $amies::_jar_name %>" \
--amies.security.secret-key="<%= $amies::security_key %>" \
--amies.pictures.root-directory="<%= $amies::picture_dir %>" \
--spring.mail.host=<%= $amies::smtp_host %> \
--spring.mail.port=<%= $amies::smtp_port %> \
--spring.mail.username="<%= $amies::smtp_user_name %>" \
--spring.mail.password="<%= $amies::smtp_user_passwd %>" \
--spring.mail.properties.mail.smtp.auth=true \
--spring.mail.properties.mail.smtp.starttls.enable=true \
--spring.datasource.url="<%= $amies::_amies_jdbc_url %>" \
--spring.datasource.username="<%= $amies::db_user_name %>" \
--spring.datasource.password="<%= $amies::db_user_password %>"
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
\ No newline at end of file
[Unit]
Description=DirectMairie
After=syslog.target
[Service]
User=<%= $directmairie::system_username %>
ExecStart=/usr/bin/java -jar "<%= $directmairie::app_dir %>/<%= $directmairie::_jar_name %>" \
--amies.security.secret-key="<%= $directmairie::security_key %>" \
--amies.pictures.root-directory="<%= $directmairie::picture_dir %>" \
--spring.mail.host=<%= $directmairie::smtp_host %> \
--spring.mail.port=<%= $directmairie::smtp_port %> \
--spring.mail.username="<%= $directmairie::smtp_user_name %>" \
--spring.mail.password="<%= $directmairie::smtp_user_passwd %>" \
--spring.mail.properties.mail.smtp.auth=true \
--spring.mail.properties.mail.smtp.starttls.enable=true \
--spring.datasource.url="<%= $directmairie::_directmairie_jdbc_url %>" \
--spring.datasource.username="<%= $directmairie::db_user_name %>" \
--spring.datasource.password="<%= $directmairie::db_user_password %>"
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
Markdown is supported
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