postgresql

This commit is contained in:
Geno 2020-11-13 22:02:44 +01:00
parent d4ec5ff29f
commit 84277b9fcb
3 changed files with 47 additions and 20 deletions

View File

@ -4,9 +4,17 @@ osp_git_commit: '0.7.9'
osp_worker_start_port: 5000
osp_worker_count: "{{ ansible_processor_nproc }}"
osp_http_user: "http"
osp_http_group: "http"
osp_http_path: "/srv/http"
osp_db_host: localhost
osp_db_name: osp
osp_db_user: osp
osp_db_location: 'sqlite:///db/database.db'
osp_db_type: "sqlite"
#osp_db_type: "cockroachdb"
osp_db_location_postgresql: "postgresql://{{ osp_db_user }}@{{ osp_db_host }}/{{ osp_db_name }}"
osp_secret_key: "{{ lookup('password', 'credentials/'+inventory_hostname+'/osp_secret_key length=8 chars=digits') }}"
osp_password_salt: "{{ lookup('password', 'credentials/'+inventory_hostname+'/osp_password_salt length=8 chars=digits') }}"
osp_allow_registration: yes

18
tasks/db_postgresql.yml Normal file
View File

@ -0,0 +1,18 @@
- name: DB - create user
postgresql_user:
login_host: "{{ osp_db_host }}"
name: "{{ osp_db_user }}"
- name: DB - create database
postgresql_db:
login_host: "{{ osp_db_host }}"
name: "{{ osp_db_name }}"
owner: "{{ osp_db_user }}"
encoding: UTF-8
lc_collate: en_US.UTF-8
lc_ctype: en_US.UTF-8
- name: Set DB location
when: osp_db_location != "///db/database.db"
set_fact:
osp_db_location: "{{ osp_db_location_postgresql }}"

View File

@ -95,8 +95,8 @@
- name: Create www directory
file:
path: "{{osp_http_path }}/{{item}}"
owner: http
group: http
owner: "{{ osp_http_user }}"
group: "{{ osp_http_group }}"
state: directory
loop:
- .
@ -113,6 +113,9 @@
state: started
enabled: yes
- name: Database
include_tasks: db_postgresql.yml
when: osp_db_type == "postgresql"
- name: Clone OSP repository
git:
@ -128,15 +131,15 @@
- name: Create cache directory
file:
path: /var/cache/osp
owner: http
group: http
owner: "{{ osp_http_user }}"
group: "{{ osp_http_group }}"
state: directory
- name: Create logging directory
file:
path: /var/log/osp
owner: http
group: http
owner: "{{ osp_http_user }}"
group: "{{ osp_http_group }}"
state: directory
- name: Configure osp
@ -152,23 +155,21 @@
dest: "/opt/osp/conf/config.py"
state: link
- name: Permissions for database
file:
path: "/opt/osp/{{ item }}"
owner: http
group: http
recurse: yes
loop:
- db
- migrations
- name: Init Database
become: yes
become_user: http
command: python3 manage.py db init
args:
chdir: /opt/osp/
creates: /opt/osp/db/database.db
creates: /opt/osp/migrations
environment:
VIRTUAL_ENV: /opt/osp-venv
PATH: /opt/osp-venv/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
- name: Permissions for database
file:
path: "/opt/osp/db"
owner: "{{ osp_http_user }}"
group: "{{ osp_http_group }}"
recurse: yes
- name: Install services files and workers
notify: restart osp