Role ansible pour setup de CodiMD

This commit is contained in:
Vulcain 2019-02-07 13:37:11 +01:00
parent 74c0d481a8
commit c8229fee9b
6 changed files with 113 additions and 0 deletions

6
codimd.yml Normal file
View file

@ -0,0 +1,6 @@
---
# Install CodiMD on CodiMD containers
- hosts: codimd.adm.auro.re
roles:
- debian-backports
- codimd

6
roles/codimd/README.md Normal file
View file

@ -0,0 +1,6 @@
# Rôle CodiMD
Ce rôle Ansible permet d'installer CodiMD.
Il doit être exécuté en tant que super-utilisateur
(option `-b` pour `--become`).

View file

@ -0,0 +1,19 @@
---
# For NodeJS package
- name: Configure NodeJS pin
when: ansible_distribution == 'Debian' and ansible_distribution_release == 'stretch'
template:
src: 'apt/nodejs'
dest: '/etc/apt/preferences.d/nodejs'
mode: 0644
# Install CodiMD dependencies
- name: Install required packages
apt:
name: "{{item}}"
state: present
update_cache: yes
with_items:
- git
- nodejs
- npm

View file

@ -0,0 +1,26 @@
---
# Security #1
- name: Create CodiMD system group
group:
name: codimd
system: yes
state: present
# Security #2
-name: Create CodiMD user
user:
name: codimd
group: codimd
home: '/var/local/codimd'
comment: CodiMD
system: yes
state: present
# Security #3
- name: Secure CodiMD home directory
file:
path: '/var/local/codimd'
state: directory
owner: codimd
group: codimd
mode: 0750

View file

@ -0,0 +1,48 @@
---
# Install APT dependencies
- include_tasks: 0_apt_dependencies.yml
# Create CodiMD user and group
- include_tasks: 1_user_group.yml
# Download CodiMD
- name: Clone CodiMD project
git:
repo: 'https://github.com/hackmdio/codimd.git'
dest: /var/local/codimd/codimd
version: 1.2.1
become: yes
become_user: codimd
# Installation script
# Setup dependencies and configs
- name: Install CodiMD depedencies
command: bin/setup
args:
chdir: /var/local/codimd/codimd
become: yes
become_user: codimd
# Build front-end bundle
- name: Build front-end for CodiMD
command: npm run build
become: yes
become_user: CodiMD
# Connection to database
- name: Connect CodiMD to database
template:
src: sequelizerc
dest: /var/local/codimd/codimd/.sequelizerc
owner: codimd
group: codimd
mode: 0600
# Update data base
- name: Migrate the Data Base to the latest schema
command: node_modules/.bin/sequelize db:migrate
args:
chdir /var/local/codimd/codimd
become: yes
become_user: codimd

View file

@ -0,0 +1,8 @@
var path = require('path');
module.exports = {
'config': path.resolve('config.json'),
'migrations-path': path.resolve('lib', 'migrations'),
'models-path': path.resolve('lib', 'models'),
'url': 'services-bdd.adm.auro.re'
}