v1.1 - Deploy backend and fronend independently #3

Merged
muppeth merged 3 commits from v1.1 into main 2022-10-21 22:58:16 +02:00
9 changed files with 109 additions and 107 deletions

View File

@ -1,11 +1,13 @@
---
lacre_pything_version: '3.9'
lacre_repo: 'https://git.disroot.org/Disroot/gpg-lacre.git'
lacre_version: 'php_update'
lacre_version: 'main'
lacre_app_dir: '/opt/gpg-lacre'
lacre_username: 'lacre'
lacre_group: 'lacre'
lacre_homedir: '/var/gpgmailgate/'
lacre_homedir: '/var/lib/gpg-lacre'
lacre_backend_deploy: 'true'
lacre_webgate_deploy: 'true'
#lacre_
lacre_apt:
- 'python3-m2crypto'
@ -24,21 +26,21 @@ lacre_dec_regex: 'None'
lacre_keyhome: '{{ lacre_homedir }}/.gnupg'
lacre_cert_path: '{{ lacre_homedir }}/smime'
lacre_register_email: 'register@example.org'
lacre_mail_templates: '{{ lacre_homedir }}/register_templates'
lacre_mail_templates: '{{ lacre_app_dir }}/register_templates'
lacre_webpanel_url: 'http://example.org'
lacre_notification_email: 'gpg-mailgate@example.org'
lacre_mail_templates: '{{ lacre_homedir }}/cron_templates'
lacre_mail_templates: '{{ lacre_app_dir }}/cron_templates'
lacre_logfile: '/etc/gpg-lacre-logging.conf'
lacre_relay: '127.0.0.1'
lacre_port: '10028'
lacre_enc_port: '25'
lacre_starttls: 'no'
lacre_db_enabled: 'yes'
lacre_db_backend: 'mysql'
lacre_db_name: 'gpgmw'
lacre_db_host: 'localhost'
lacre_db_username: 'user'
lacre_db_password: 'password'
lacre_webgate_db_enabled: 'yes'
lacre_webgate_db_backend: 'mysql'
lacre_webgate_db_name: 'gpgmw'
lacre_webgate_db_host: 'localhost'
lacre_webgatedb_username: 'user'
lacre_webgatedb_password: 'password'
#lacre logger
lacre_log_loggers_keys: 'root'
@ -57,18 +59,19 @@ lacre_log_postfix_datefmt: '%b %e %H:%M:%S'
lacre_log_postfix_style: '%'
lacre_log_postfix_validate: 'True'
#lacre webgate
lacre_smtp_enabled: 'false'
lacre_smtp_username: 'no-reply'
lacre_smtp_password: 'chanfeme'
lacre_smtp_host: 'example.lan'
lacre_smtp_port: '587'
lacre_smtp_starttls: 'true'
lacre_cron: 'true'
lacre_webgate_cron: 'true'
lacre_webgate_deploy: 'true'
lacre_webgate_apt:
- 'python3-markdown'
- 'python3-mysqldb'
lacre_webgate_webroot: '/var/www/'
lacre_webgate_repo: 'https://git.disroot.org/Lacre/lacre-webgate.git'
lacre_webgate_version: 'main'
lacre_webgate_dir: '/var/www/lacre-web'
lacre_webgate_user: 'www-data'
lacre_webgate_group: 'www-data'
lacre_webgate_email_web: 'admin@example.com'
@ -78,7 +81,7 @@ lacre_webgate_site_url: 'http://example.com/gpgmw'
lacre_webgate_site_title: 'PGP key management'
lacre_webgate_language: 'english'
lacre_webgate_debug: 'enable'
lacre_webgate_mail_smtp: 'false'
lacre_mail_smtp: 'false'
lacre_webgate_smtp_host: 'localhost'
lacre_webgate_smtp_port: '25'
lacre_webgate_smtp_username: 'gpgmw'

View File

@ -1,73 +0,0 @@
---
- name: '[Webgate] - Install dependencies'
apt:
name: "{{ lacre_webgate_apt }}"
- name: '[Webgate] - Copy files to webdir'
copy:
remote_src: true
src: "{{ lacre_app_dir }}/gpg-mailgate-web/public_html"
dest: "{{ lacre_webgate_webroot }}/gpg-mailgate-web"
owner: "{{ lacre_webgate_user }}"
group: "{{ lacre_webgate_group }}"
- name: '[Webgate] - Check if db schema is loaded'
shell:
cmd: mysql -h {{ lacre_db_host }} -u {{ lacre_db_username }} -p{{ lacre_db_password }} {{ lacre_db_name }} -se "SELECT EXISTS (SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA LIKE '{{ lacre_db_name }}' AND TABLE_TYPE LIKE 'BASE TABLE' AND TABLE_NAME = 'gpgmw_keys' );"
register: webgate_installed
ignore_errors: true
- name: '[Webgate] - Import sql schema'
mysql_db:
state: import
name: "{{ lacre_db_name }}"
login_host: "{{ lacre_db_host }}"
login_user: "{{ lacre_db_username }}"
login_password: "{{ lacre_db_password }}"
target: "{{ lacre_app_dir }}/gpg-mailgate-web/schema.sql"
when: webgate_installed.stdout != '1'
- name: 'Webgate] - Deploy config'
template:
src: 'config.php.j2'
dest: "{{ lacre_webgate_webroot }}/gpg-mailgate-web/public_html/config.php"
owner: "{{ lacre_webgate_user }}"
group: "{{ lacre_webgate_group }}"
- name: '[Webgate] - Create email template dir'
file:
path: "{{ lacre_homedir }}/cron-templates"
state: directory
owner: "{{ lacre_username }}"
group: "{{ lacre_group }}"
- name: '[Webgate] - Copy templates to template dir'
copy:
remote_src: true
src: "{{ lacre_app_dir }}/cron_templates"
dest: "{{ lacre_homedir }}/cron-templates"
owner: "{{ lacre_username }}"
group: "{{ lacre_group }}"
- name: '[Webgate] - Deploy cron.py'
copy:
remote_src: true
src: "{{ lacre_app_dir }}/gpg-mailgate-web/cron.py"
dest: '/usr/local/bin/gpgmw-cron.py'
owner: "{{ lacre_username }}"
group: "{{ lacre_group }}"
mode: a+x
- name: '[Webgate] - Set cron'
cron:
name: "Webgate cronjob"
state: present
minute: "*/3"
hour: "*"
day: "*"
month: "*"
weekday: "*"
user: "{{ lacre_username }}"
job: '/usr/local/bin/gpgmw-cron.py > /dev/null'
when: lacre_cron == 'true'

View File

@ -1,6 +1,6 @@
---
- name: '[GIT] - Clone lacre to /opt'
- name: '[GIT] - Clone lacre to app dir'
git:
repo: '{{ lacre_repo }}'
dest: '{{ lacre_app_dir }}'

View File

@ -40,3 +40,25 @@
src: '{{ lacre_app_dir }}/lacre'
dest: '/usr/local/lib/python{{ lacre_pything_version }}/dist-packages/lacre'
state: link
- name: '[INSTALL] - Set cron file permission'
file:
path: '{{ lacre_app_dir }}/webgate-cron.py'
state: 'file'
mode: 'a+x'
owner: '{{ lacre_username }}'
group: '{{ lacre_group }}'
when: lacre_webgate_cron == 'true'
- name: '[INSTALL] - Set cron'
cron:
name: "Lacre-webgate cronjob"
state: present
minute: "*/3"
hour: "*"
day: "*"
month: "*"
weekday: "*"
user: "{{ lacre_username }}"
job: '{{ lacre_app_dir }}/webgate-cron.py > /dev/null'
when: lacre_webgate_cron == 'true'

View File

@ -2,21 +2,33 @@
- name: 'Clone / Update repository'
include: git.yml
tags:
- 'backend'
when: lacre_backend_deploy == 'true'
- name: 'Create user'
include: user.yml
tags:
- 'backend'
when: lacre_backend_deploy == 'true'
- name: 'Install Lacre'
include: install.yml
tags:
- 'backend'
when: lacre_backend_deploy == 'true'
- name: 'Configure Lacre'
include: configure.yml
tags:
- 'config'
- 'configure'
- 'backend'
when: lacre_backend_deploy == 'true'
- name: 'Deploy frontend'
include: frontend.yml
- name: 'Deploy Lacre Webgate'
include: webgate.yml
tags:
- 'frontend'
- 'webgate'
when: lacre_webgate_deploy == 'true'

View File

@ -12,7 +12,7 @@
group: '{{ lacre_group }}'
state: present
- name: '[USER] - Change ownership to etherpad user'
- name: '[USER] - Change ownership of the app dir'
file:
path: '{{ lacre_app_dir }}'
owner: '{{ lacre_username }}'

38
tasks/webgate.yml Normal file
View File

@ -0,0 +1,38 @@
---
- name: '[Lacre-webgate] - Install dependencies'
apt:
name: "{{ lacre_webgate_apt }}"
- name: '[Lacre-webgate] - clone repository'
git:
repo: '{{ lacre_webgate_repo }}'
dest: '{{ lacre_webgate_dir }}'
force: 'yes'
version: '{{ lacre_webgate_version }}'
become: 'yes'
become_user: '{{ lacre_webgate_user }}'
- name: '[Lacre-webgate] - Check if db schema is loaded'
shell:
cmd: mysql -h {{ lacre_webgate_db_host }} -u {{ lacre_webgate_db_username }} -p{{ lacre_webgate_db_password }} {{ lacre_webgate_db_name }} -se "SELECT EXISTS (SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA LIKE '{{ lacre_webgate_db_name }}' AND TABLE_TYPE LIKE 'BASE TABLE' AND TABLE_NAME = 'gpgmw_keys' );"
register: lacre_webgate_installed
ignore_errors: true
- name: '[Lacre-webgate] - Import sql schema'
mysql_db:
state: import
name: "{{ lacre_webgate_db_name }}"
login_host: "{{ lacre_webgate_db_host }}"
login_user: "{{ lacre_webgate_db_username }}"
login_password: "{{ lacre_webgate_db_password }}"
target: "{{ lacre_webgate_dir }}/schema.sql"
when: lacre_webgate_installed.stdout != '3'
- name: '[Lacre-webgate] - Deploy config'
template:
src: 'lacre-web/config.php.j2'
dest: "{{ lacre_webgate_dir }}/public_html/config.php"
owner: "{{ lacre_webgate_user }}"
group: "{{ lacre_webgate_group }}"

View File

@ -94,12 +94,12 @@ port = {{ lacre_smtp_port }}
starttls = {{ lacre_smtp_starttls }}
[database]
enabled = {{ lacre_db_enabled }}
{% if lacre_db_backend == 'sqlite' %}
url = sqlite://{{ lacre_db_name }}
enabled = {{ lacre_webgate_db_enabled }}
{% if lacre_webgate_db_backend == 'sqlite' %}
url = sqlite://{{ lacre_webgate_db_name }}
{% endif %}
{% if lacre_db_backend == 'mysql' %}
url = mysql://{{ lacre_db_username }}:{{ lacre_db_password }}@{{ lacre_db_host }}/{{ lacre_db_name }}
{% if lacre_webgate_db_backend == 'mysql' %}
url = mysql://{{ lacre_webgate_db_username }}:{{ lacre_webgate_db_password }}@{{ lacre_webgate_db_host }}/{{ lacre_webgate_db_name }}
{% endif %}
[enc_keymap]

View File

@ -45,37 +45,37 @@ $config['site_title'] = '{{ lacre_webgate_site_title }}';
$config['language'] = '{{ lacre_webgate_language }}';
//whether debug mode should be enabled
$config['debug'] = {{ lacre_webgate_debug }};
$config['debug'] = '{{ lacre_webgate_debug }}';
//
// MAIL SETTINGS
//
//whether to send mail through SMTP (instead of PHP mail function)
$config['mail_smtp'] = {{ lacre_webgate_mail_smtp }};
$config['mail_smtp'] = {{ lacre_mail_smtp }};
//SMTP settings, if mail_smtp is enabled
//this requires Net_SMTP from http://pear.php.net/package/Net_SMTP/ to be installed
$config['mail_smtp_host'] = '{{ lacre_webgate_smtp_host }}';
$config['mail_smtp_port'] = {{ lacre_webgate_smtp_port }};
$config['mail_smtp_username'] = '{{ lacre_webgate_smtp_username }}';
$config['mail_smtp_password'] = '{{ lacre_webgate_smtp_password }}';
$config['mail_smtp_host'] = '{{ lacre_smtp_host }}';
$config['mail_smtp_port'] = {{ lacre_smtp_port }};
$config['mail_smtp_username'] = '{{ lacre_smtp_username }}';
$config['mail_smtp_password'] = '{{ lacre_smtp_password }}';
//
// DATABASE SETTINGS
//
//database name (MySQL only); or see include/dbconnect.php
$config['db_name'] = '{{ lacre_db_name }}';
$config['db_name'] = '{{ lacre_webgate_db_name }}';
//database host
$config['db_host'] = '{{ lacre_db_host }}';
$config['db_host'] = '{{ lacre_webgate_db_host }}';
//database username
$config['db_username'] = '{{ lacre_db_username }}';
$config['db_username'] = '{{ lacre_webgate_db_username }}';
//database password
$config['db_password'] = '{{ lacre_db_password }}';
$config['db_password'] = '{{ lacre_webgate_db_password }}';
//
// PGP VERIFICATION SETTINGS