diff --git a/inventory/group_vars/ci b/inventory/group_vars/ci index 36e573b726..5224b289a8 100644 --- a/inventory/group_vars/ci +++ b/inventory/group_vars/ci @@ -57,7 +57,7 @@ resultsdb_frontend_secret_key: "{{ ci_resultsdb_frontend_secret_key }}" ########################################################### # execdb details -############################################################ +########################################################### execdb_db_host_machine: ci-cc-rdu01.fedoraproject.org execdb_db_host: "{{ execdb_db_host_machine }}" execdb_db_port: 5432 @@ -68,6 +68,19 @@ execdb_db_password: "{{ ci_execdb_db_password }}" execdb_secret_key: "{{ ci_execdb_secret_key }}" +########################################################### +# ccsdb details +########################################################### +ccsdb_db_host_machine: ci-cc-rdu01.fedoraproject.org +ccsdb_db_host: "{{ ccsdb_db_host_machine }}" +ccsdb_db_port: 5432 +ccsdb_endpoint: 'ccsdb' +ccsdb_db_name: ccsdb +ccsdb_db_user: "{{ ci_ccsdb_db_user }}" +ccsdb_db_password: "{{ ci_ccsdb_db_password }}" +ccsdb_secret_key: "{{ ci_ccsdb_secret_key }}" + + ############################################################ # fedmsg details ############################################################ diff --git a/roles/ccsdb/tasks/main.yml b/roles/ccsdb/tasks/main.yml new file mode 100644 index 0000000000..f4022a0af6 --- /dev/null +++ b/roles/ccsdb/tasks/main.yml @@ -0,0 +1,82 @@ +--- +- name: install ccsdb and its dependencies + yum: name={{ item }} state=present + with_items: + - ccsdb + - mod_wsgi + - python-psycopg2 + - libsemanage-python + when: ansible_distribution_major_version|int < 22 + tags: + - ccsdb + +- name: install ccsdb and its dependencies + dnf: name={{ item }} state=present enablerepo={{ extra_enablerepos }} + with_items: + - ccsdb + - mod_wsgi + - python-psycopg2 + - libsemanage-python + when: ansible_distribution_major_version|int > 21 and ansible_cmdline.ostree is not defined + tags: + - ccsdb + +- name: ensure database is created + delegate_to: "{{ ccsdb_db_host_machine }}" + become_user: postgres + become: true + postgresql_db: db={{ ccsdb_db_name }} + tags: + - ccsdb + +- name: ensure ccsdb db user has access to database + delegate_to: "{{ ccsdb_db_host_machine }}" + become_user: postgres + become: true + postgresql_user: db={{ ccsdb_db_name }} + user={{ ccsdb_db_user }} + password={{ ccsdb_db_password }} + role_attr_flags=NOSUPERUSER + tags: + - ccsdb + +- name: ensure selinux lets httpd talk to postgres + seboolean: name=httpd_can_network_connect_db persistent=yes state=yes + tags: + - ccsdb + +- name: generate ccsdb config + template: src=ccsdb.cfg dest=/etc/ccsdb/ccsdb.cfg + owner=root group=root mode=0644 + notify: + - reload httpd + tags: + - ccsdb + +- name: generate ccsdb apache config + template: src=ccsdb.conf dest=/etc/httpd/conf.d/ccsdb.conf + owner=root group=root mode=0644 + notify: + - reload httpd + tags: + - ccsdb + +- name: create the /usr/share/ccsdb folder + file: state=directory + path=/usr/share/ccsdb + owner=root group=root mode=0755 + tags: + - ccsdb + +- name: install the wsgi file + template: src=ccsdb.wsgi dest=/usr/share/ccsdb/ccsdb.wsgi + owner=root group=root mode=0644 + notify: + - reload httpd + tags: + - ccsdb + +- name: initialize execdb database + shell: ccsdb-cli init_db + tags: + - ccsdb diff --git a/roles/ccsdb/templates/ccsdb.cfg b/roles/ccsdb/templates/ccsdb.cfg new file mode 100644 index 0000000000..4de44cf9e4 --- /dev/null +++ b/roles/ccsdb/templates/ccsdb.cfg @@ -0,0 +1,7 @@ +SECRET_KEY = '{{ ccsdb_secret_key }}' +SQLALCHEMY_DATABASE_URI = 'postgresql://{{ ccsdb_db_user }}:{{ ccsdb_db_password }}@{{ ccsdb_db_host }}:{{ ccsdb_db_port }}/{{ ccsdb_db_name }}' + +FILE_LOGGING = False +LOGFILR = '/var/log/ccsdb/ccsdb.log' +SYSLOG_LOGGING = False +STREAM_LOGGING = True diff --git a/roles/ccsdb/templates/ccsdb.wsgi b/roles/ccsdb/templates/ccsdb.wsgi new file mode 100644 index 0000000000..3df7ec863b --- /dev/null +++ b/roles/ccsdb/templates/ccsdb.wsgi @@ -0,0 +1,4 @@ +import os +os.environ['CCSDB_CONFIG'] = '/etc/ccsdb/ccsdb.cfg' + +from ccsdb.app import _app as application