summaryrefslogtreecommitdiff
path: root/roles/subdap
diff options
context:
space:
mode:
authorChristian Franke <nobody@nowhere.ws>2015-08-25 19:23:43 +0200
committerChristian Franke <nobody@nowhere.ws>2015-08-25 19:23:43 +0200
commitaf66612e6014bea48458125cda72d73c51bc3c20 (patch)
tree49cee76d579149a9fd800225303ee31be79cf3eb /roles/subdap
Initial commit
Diffstat (limited to 'roles/subdap')
-rw-r--r--roles/subdap/defaults/main.yaml12
-rw-r--r--roles/subdap/handlers/main.yaml5
-rw-r--r--roles/subdap/meta/main.yaml3
-rw-r--r--roles/subdap/tasks/as_subdap.yaml23
-rw-r--r--roles/subdap/tasks/main.yaml34
-rw-r--r--roles/subdap/templates/accountservice.py.j24
-rw-r--r--roles/subdap/templates/subdap.service.j224
7 files changed, 105 insertions, 0 deletions
diff --git a/roles/subdap/defaults/main.yaml b/roles/subdap/defaults/main.yaml
new file mode 100644
index 0000000..828e81c
--- /dev/null
+++ b/roles/subdap/defaults/main.yaml
@@ -0,0 +1,12 @@
+$ANSIBLE_VAULT;1.1;AES256
+62323037313838613830313931326130393539323938383666373962343732336439653966313737
+6133313937316365626561396430626531653134613263660a333036313661653265633732323162
+33613362343163396232336365643133333961313638303038616130363166323834633933306234
+6633326634643636620a623961313665613366646535303238326138373464393937643036336531
+35316163353236393164393539616636393937663339306261393532616336376664343632656331
+30316335356662643630653465326234383438343531666635636333383230653634613138623230
+30383036313962633032636663363638663634363934623161303635646336633039343136613265
+62366363373463373066343961646438343438353231393866346539333631353731653634366364
+32333065336237313537323365653865326663613862326537376536666633616636376565613131
+32346266333365326366613762363764356464303262363332326433626539663631333261396537
+373435333366643561623432336339346462
diff --git a/roles/subdap/handlers/main.yaml b/roles/subdap/handlers/main.yaml
new file mode 100644
index 0000000..7e7eb38
--- /dev/null
+++ b/roles/subdap/handlers/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Restart subdap
+ service:
+ name: subdap
+ state: restarted
diff --git a/roles/subdap/meta/main.yaml b/roles/subdap/meta/main.yaml
new file mode 100644
index 0000000..fdda41b
--- /dev/null
+++ b/roles/subdap/meta/main.yaml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - role: common
diff --git a/roles/subdap/tasks/as_subdap.yaml b/roles/subdap/tasks/as_subdap.yaml
new file mode 100644
index 0000000..f0b9073
--- /dev/null
+++ b/roles/subdap/tasks/as_subdap.yaml
@@ -0,0 +1,23 @@
+---
+- name: Clone subdap code
+ git:
+ dest=/var/subdap/src
+ repo=git://git.sublab.org/subdap
+ accept_hostkey=yes
+
+- name: Setup virtualenv for subdap
+ pip:
+ name={{ item }}
+ virtualenv=/var/subdap/venv
+ virtualenv_site_packages=yes
+ with_items:
+ - cherrypy
+ - egenix-mx-base
+ - genshi
+ - gunicorn
+
+- name: Create accountservice.py
+ template:
+ dest=/var/subdap/src/accountservice.py
+ src=accountservice.py.j2
+ mode=0600
diff --git a/roles/subdap/tasks/main.yaml b/roles/subdap/tasks/main.yaml
new file mode 100644
index 0000000..6375e6e
--- /dev/null
+++ b/roles/subdap/tasks/main.yaml
@@ -0,0 +1,34 @@
+---
+- apt: name={{ item }} state=present
+ with_items:
+ - git
+ - python-ldap
+ - python-lxml
+ - python-m2crypto
+ - virtualenv
+
+- name: Create subdap group
+ group: name=subdap
+
+- name: Create subdap user
+ user: name=subdap group=subdap home=/var/subdap
+
+- include: as_subdap.yaml
+ become: yes
+ become_method: su
+ become_user: subdap
+ notify:
+ - Restart subdap
+
+- name: Create systemd service
+ template:
+ src=subdap.service.j2
+ dest=/etc/systemd/system/subdap.service
+ notify:
+ - Reload systemd daemons
+ - Restart subdap
+
+- name: Enable systemd service
+ service:
+ name: subdap
+ enabled: yes
diff --git a/roles/subdap/templates/accountservice.py.j2 b/roles/subdap/templates/accountservice.py.j2
new file mode 100644
index 0000000..2f6e8f1
--- /dev/null
+++ b/roles/subdap/templates/accountservice.py.j2
@@ -0,0 +1,4 @@
+import xmlrpclib
+
+url = '{{ subdap_accountservice_url }}'
+accountservice = xmlrpclib.ServerProxy(url)
diff --git a/roles/subdap/templates/subdap.service.j2 b/roles/subdap/templates/subdap.service.j2
new file mode 100644
index 0000000..068570d
--- /dev/null
+++ b/roles/subdap/templates/subdap.service.j2
@@ -0,0 +1,24 @@
+[Unit]
+Description=subdap ldap frontend application server
+After=network.target
+
+[Service]
+PIDFile=/var/subdap/gunicorn.pid
+User=subdap
+Group=subdap
+WorkingDirectory=/var/subdap/src
+Environment=VIRTUAL_ENV="/var/subdap/venv"
+Environment=PATH="$VIRTUAL_ENV/bin:$PATH"
+ExecStart=/var/subdap/venv/bin/gunicorn \
+ --pid /var/subdap/gunicorn.pid \
+ --log-syslog \
+ --max-requests 1000 \
+ -w 10 -t 120 \
+ -b 127.0.0.1:8001 \
+ index
+ExecReload=/bin/kill -HUP $MAINPID
+ExecStop=/bin/kill -TERM $MAINPID
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target