Hubs: add the hubs role to the playbook

This commit is contained in:
Aurélien Bompard 2018-02-19 10:36:01 +00:00
parent 3bd998fffe
commit 68d73e1307
5 changed files with 93 additions and 8 deletions

View file

@ -9,7 +9,7 @@
vars_files:
- /srv/web/infra/ansible/vars/global.yml
- "/srv/private/ansible/vars.yml"
- /srv/private/ansible/vars.yml
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
pre_tasks:
@ -25,7 +25,6 @@
- sudo
- { role: openvpn/client,
when: env != "staging" }
- mod_wsgi
tasks:
- import_tasks: "{{ tasks_path }}/2fa_client.yml"
@ -33,3 +32,86 @@
handlers:
- import_tasks: "{{ handlers_path }}/restart_services.yml"
#
# Database setup
#
- name: prepare setting up the database
hosts: db01.stg.phx2.fedoraproject.org
gather_facts: no
user: root
tasks:
- name: install psycopg2 for the postgresql ansible modules
package: name=python-psycopg2 state=present
tags:
- packages
- name: setup the database
hosts: db01.stg.phx2.fedoraproject.org
gather_facts: no
become: yes
become_user: postgres
vars_files:
- /srv/web/infra/ansible/vars/global.yml
- /srv/private/ansible/vars.yml
- "/srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml"
tasks:
#- name: hubs DB admin user
# postgresql_user: name=hubsadmin password={{ hubs_admin_db_pass }}
#- name: databases creation
# postgresql_db: name=hubs owner=hubsadmin encoding=UTF-8
- name: hubs DB user
postgresql_user: name=hubsapp password={{ hubs_db_pass }}
- name: databases creation
postgresql_db: name=hubs owner=hubsapp encoding=UTF-8
#
# Real Hubs-specific work
#
- name: setup Hubs
hosts: hubs-stg
user: root
gather_facts: True
vars_files:
- /srv/web/infra/ansible/vars/global.yml
- /srv/private/ansible/vars.yml
- "/srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml"
roles:
- fedmsg/base
- role: hubs
main_user: hubs
hubs_url_hostname: hubs.stg.fedoraproject.org
hubs_secret_key: "{{ hubs_session_secret }}"
hubs_db_type: postgresql
hubs_db_host: db01.stg.fedoraproject.org
hubs_db_user: hubsapp
hubs_db_password: "{{ hubs_db_pass }}"
hubs_dev_mode: false
hubs_conf_dir: /etc/fedora-hubs
hubs_var_dir: /var/lib/fedora-hubs
hubs_ssl_cert: /etc/letsencrypt/live/hubs.stg.fedoraproject.org/fullchain.pem
hubs_ssl_key: /etc/letsencrypt/live/hubs.stg.fedoraproject.org/privkey.pem
hubs_fas_username: "{{ fedoraDummyUser }}"
hubs_fas_password: "{{ fedoraDummyUserPassword }}"
hubs_oidc_url: id.stg.fedoraproject.org
tasks:
- name: add more hubs workers
service: name={{item}} enabled=yes state=started
with_items:
- fedora-hubs-triage@3
- fedora-hubs-triage@4
- fedora-hubs-worker@3
- fedora-hubs-worker@4
handlers:
- import_tasks: "{{ handlers_path }}/restart_services.yml"

View file

@ -6,7 +6,10 @@ hubs_code_dir: "{{ hubs_base_dir }}/fedora-hubs"
hubs_conf_dir: "{{ hubs_base_dir }}/config"
hubs_var_dir: "{{ hubs_base_dir }}/var"
hubs_db_type: sqlite
hubs_db_user: hubs
hubs_db_password: changeme
hubs_db_host: localhost
hubs_db_name: hubs
hubs_url_hostname: "{{ ansible_fqdn }}"
hubs_url: http{% if not hubs_dev_mode %}s{% endif %}://{{ hubs_url_hostname }}{% if hubs_dev_mode %}:5000{% endif %}
hubs_ssl_cert: /etc/pki/tls/certs/{{ hubs_url_hostname }}.crt

View file

@ -31,14 +31,14 @@
become_user: "{{ main_user }}"
args:
creates: node_modules
chdir: "{{ hubs_code_dir }}/hubs/static/client"
chdir: "{{ hubs_code_dir }}/js"
- name: Build JavaScript assets
command: npm run build
become: true
become_user: "{{ main_user }}"
args:
chdir: "{{ hubs_code_dir }}/hubs/static/client"
chdir: "{{ hubs_code_dir }}/js"
creates: "{{ hubs_code_dir }}/hubs/static/js/build/common.js"

View file

@ -2,7 +2,7 @@ config = {
# Database
{% if hubs_db_type == "postgresql" %}
'hubs.sqlalchemy.uri': 'postgresql://hubs:{{ hubs_db_password }}@localhost/hubs',
'hubs.sqlalchemy.uri': 'postgresql://{{ hubs_db_user }}:{{ hubs_db_password }}@{{ hubs_db_host }}/{{ hubs_db_name }}',
{% else %}
'hubs.sqlalchemy.uri': 'sqlite:///{{ hubs_var_dir }}/hubs.db',
{% endif %}

View file

@ -1,7 +1,7 @@
web: /usr/bin/flask-3 run --host 0.0.0.0 --port 5000
triage: fedora-hubs-triage
worker: fedora-hubs-worker
triage: fedora-hubs run triage
worker: fedora-hubs run worker
sse: /usr/bin/twistd-3 -l - --pidfile= -n hubs-sse
fedmsg_hub: /usr/bin/fedmsg-hub-3
fedmsg_relay: /usr/bin/fedmsg-relay-3
js_build: cd {{ hubs_code_dir }}/hubs/static/client && npm run dev
js_build: cd {{ hubs_code_dir }}/js && npm run dev