summaryrefslogtreecommitdiffstats
path: root/roles/ccsdb
diff options
context:
space:
mode:
authorPierre-Yves Chibon <pingou@pingoured.fr>2017-05-30 17:18:53 +0200
committerPierre-Yves Chibon <pingou@pingoured.fr>2017-05-30 17:20:19 +0200
commit18e12646961c3e5cd693da17eb71297e5f427aa9 (patch)
tree1f6b236c5c89612b353a325f6803015a8c42c234 /roles/ccsdb
parent1cb3a9ae199ff1834e9e3470e234821fda342ad2 (diff)
downloadansible-18e12646961c3e5cd693da17eb71297e5f427aa9.tar.gz
ansible-18e12646961c3e5cd693da17eb71297e5f427aa9.tar.xz
ansible-18e12646961c3e5cd693da17eb71297e5f427aa9.zip
Add the configuration and role for ccsdb
Diffstat (limited to 'roles/ccsdb')
-rw-r--r--roles/ccsdb/tasks/main.yml82
-rw-r--r--roles/ccsdb/templates/ccsdb.cfg7
-rw-r--r--roles/ccsdb/templates/ccsdb.wsgi4
3 files changed, 93 insertions, 0 deletions
diff --git a/roles/ccsdb/tasks/main.yml b/roles/ccsdb/tasks/main.yml
new file mode 100644
index 000000000..f4022a0af
--- /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 000000000..4de44cf9e
--- /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 000000000..3df7ec863
--- /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