postgresql
This commit is contained in:
parent
d4ec5ff29f
commit
84277b9fcb
|
@ -4,9 +4,17 @@ osp_git_commit: '0.7.9'
|
||||||
osp_worker_start_port: 5000
|
osp_worker_start_port: 5000
|
||||||
osp_worker_count: "{{ ansible_processor_nproc }}"
|
osp_worker_count: "{{ ansible_processor_nproc }}"
|
||||||
|
|
||||||
|
osp_http_user: "http"
|
||||||
|
osp_http_group: "http"
|
||||||
osp_http_path: "/srv/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_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_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_password_salt: "{{ lookup('password', 'credentials/'+inventory_hostname+'/osp_password_salt length=8 chars=digits') }}"
|
||||||
osp_allow_registration: yes
|
osp_allow_registration: yes
|
||||||
|
|
|
@ -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 }}"
|
|
@ -95,8 +95,8 @@
|
||||||
- name: Create www directory
|
- name: Create www directory
|
||||||
file:
|
file:
|
||||||
path: "{{osp_http_path }}/{{item}}"
|
path: "{{osp_http_path }}/{{item}}"
|
||||||
owner: http
|
owner: "{{ osp_http_user }}"
|
||||||
group: http
|
group: "{{ osp_http_group }}"
|
||||||
state: directory
|
state: directory
|
||||||
loop:
|
loop:
|
||||||
- .
|
- .
|
||||||
|
@ -113,6 +113,9 @@
|
||||||
state: started
|
state: started
|
||||||
enabled: yes
|
enabled: yes
|
||||||
|
|
||||||
|
- name: Database
|
||||||
|
include_tasks: db_postgresql.yml
|
||||||
|
when: osp_db_type == "postgresql"
|
||||||
|
|
||||||
- name: Clone OSP repository
|
- name: Clone OSP repository
|
||||||
git:
|
git:
|
||||||
|
@ -128,15 +131,15 @@
|
||||||
- name: Create cache directory
|
- name: Create cache directory
|
||||||
file:
|
file:
|
||||||
path: /var/cache/osp
|
path: /var/cache/osp
|
||||||
owner: http
|
owner: "{{ osp_http_user }}"
|
||||||
group: http
|
group: "{{ osp_http_group }}"
|
||||||
state: directory
|
state: directory
|
||||||
|
|
||||||
- name: Create logging directory
|
- name: Create logging directory
|
||||||
file:
|
file:
|
||||||
path: /var/log/osp
|
path: /var/log/osp
|
||||||
owner: http
|
owner: "{{ osp_http_user }}"
|
||||||
group: http
|
group: "{{ osp_http_group }}"
|
||||||
state: directory
|
state: directory
|
||||||
|
|
||||||
- name: Configure osp
|
- name: Configure osp
|
||||||
|
@ -152,23 +155,21 @@
|
||||||
dest: "/opt/osp/conf/config.py"
|
dest: "/opt/osp/conf/config.py"
|
||||||
state: link
|
state: link
|
||||||
|
|
||||||
- name: Permissions for database
|
|
||||||
file:
|
|
||||||
path: "/opt/osp/{{ item }}"
|
|
||||||
owner: http
|
|
||||||
group: http
|
|
||||||
recurse: yes
|
|
||||||
loop:
|
|
||||||
- db
|
|
||||||
- migrations
|
|
||||||
|
|
||||||
- name: Init Database
|
- name: Init Database
|
||||||
become: yes
|
|
||||||
become_user: http
|
|
||||||
command: python3 manage.py db init
|
command: python3 manage.py db init
|
||||||
args:
|
args:
|
||||||
chdir: /opt/osp/
|
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
|
- name: Install services files and workers
|
||||||
notify: restart osp
|
notify: restart osp
|
||||||
|
|
Loading…
Reference in New Issue