From af66612e6014bea48458125cda72d73c51bc3c20 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Tue, 25 Aug 2015 19:23:43 +0200 Subject: Initial commit --- roles/subdap/defaults/main.yaml | 12 ++++++++++ roles/subdap/handlers/main.yaml | 5 +++++ roles/subdap/meta/main.yaml | 3 +++ roles/subdap/tasks/as_subdap.yaml | 23 +++++++++++++++++++ roles/subdap/tasks/main.yaml | 34 +++++++++++++++++++++++++++++ roles/subdap/templates/accountservice.py.j2 | 4 ++++ roles/subdap/templates/subdap.service.j2 | 24 ++++++++++++++++++++ 7 files changed, 105 insertions(+) create mode 100644 roles/subdap/defaults/main.yaml create mode 100644 roles/subdap/handlers/main.yaml create mode 100644 roles/subdap/meta/main.yaml create mode 100644 roles/subdap/tasks/as_subdap.yaml create mode 100644 roles/subdap/tasks/main.yaml create mode 100644 roles/subdap/templates/accountservice.py.j2 create mode 100644 roles/subdap/templates/subdap.service.j2 (limited to 'roles/subdap') 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 -- cgit v1.2.1