From 6ec00975df2aca1edb1acb86dc89c96ca02fb205 Mon Sep 17 00:00:00 2001 From: Sven-Hendrik Haase <svenstaro@gmail.com> Date: Fri, 17 Jun 2016 04:39:19 +0200 Subject: [PATCH] Add archweb service to orion --- group_vars/all/archweb.yml | 9 ++++ group_vars/all/postgres.yml | 16 ++++--- playbooks/orion.yml | 1 + .../archweb/files/archweb-mirrorcheck.service | 14 ++++++ roles/archweb/files/archweb-mirrorcheck.timer | 10 ++++ roles/archweb/files/archweb-reporead.service | 13 ++++++ roles/archweb/handlers/main.yml | 4 ++ roles/archweb/tasks/main.yml | 46 +++++++++++++++++++ roles/archweb/templates/local_settings.py.j2 | 28 +++++++++++ 9 files changed, 134 insertions(+), 7 deletions(-) create mode 100644 group_vars/all/archweb.yml create mode 100644 roles/archweb/files/archweb-mirrorcheck.service create mode 100644 roles/archweb/files/archweb-mirrorcheck.timer create mode 100644 roles/archweb/files/archweb-reporead.service create mode 100644 roles/archweb/handlers/main.yml create mode 100644 roles/archweb/tasks/main.yml create mode 100644 roles/archweb/templates/local_settings.py.j2 diff --git a/group_vars/all/archweb.yml b/group_vars/all/archweb.yml new file mode 100644 index 000000000..72d63ecf1 --- /dev/null +++ b/group_vars/all/archweb.yml @@ -0,0 +1,9 @@ +$ANSIBLE_VAULT;1.1;AES256 +32336337623936643161653739636138303332326366363963393436396465633137616266653463 +3663343535306333323332366338623463363030663534630a326336333065633333333230663130 +32656537326537313336343136316338346464386237626230663236343865336562363562363739 +6163396332343032340a653739353436656139396336623539643431366462363164646361336436 +36316238336535323864383537613964373666656465636562613530356566303139383230643761 +65663030323464623230626330633538303436363664383839623334333837666435323466666638 +64353061613234373966636266613763366364386334323333663933616534333937396539376562 +38623139323463336363 diff --git a/group_vars/all/postgres.yml b/group_vars/all/postgres.yml index cbe49315f..5ffb5f79d 100644 --- a/group_vars/all/postgres.yml +++ b/group_vars/all/postgres.yml @@ -1,8 +1,10 @@ $ANSIBLE_VAULT;1.1;AES256 -36666131373264613664663533333232343233306332663433303930333063643539656232353735 -3637393832313138323238646166336531363837313731630a393035643830626464316239326131 -66356665636131346639383733616631316664313331396538376663353832323133333134623833 -3038336638346361660a626637336430303036343631666365316339643732356362643133663363 -37316531383534343361393338616332323232376332323339366338663063643238666539646330 -63343466363930326238356334656636663363363166373561393131303435353461366237623233 -356262383565623262343836623666663232 +66316639393734333962323264376164626437356233663165303536373661643566383463663230 +3733646361633362356465363839326133623739343664360a353832303138343537366661653333 +33363631343830613937323336383766343035353166336663316335616335316466343835306463 +3862306265383864310a313439353937376436386565343334303364376134333633313735323864 +33633665616331313932326563376565363133376438633665343932636461316530666434656236 +62313332383437383964346332653035383834343132626631396639643262353031656538643134 +66383132313837316563656630666663333166346130646334343639643462643131656533363635 +63316162303862346134633961323538623934363836313731646336623339333138376436623933 +3962 diff --git a/playbooks/orion.yml b/playbooks/orion.yml index 4a939c085..e1cac193f 100644 --- a/playbooks/orion.yml +++ b/playbooks/orion.yml @@ -15,3 +15,4 @@ - { role: nginx, tags: ["nginx"] } - { role: dbscripts, repos_domain: "repos.archlinux.org" } - sudo + - { role: archweb, archweb_home: "/srv/http/archweb" } diff --git a/roles/archweb/files/archweb-mirrorcheck.service b/roles/archweb/files/archweb-mirrorcheck.service new file mode 100644 index 000000000..d5825f977 --- /dev/null +++ b/roles/archweb/files/archweb-mirrorcheck.service @@ -0,0 +1,14 @@ +[Unit] +Description=archewb mirrorcheck +After=network.target + +[Service] +Type=oneshot +User=archweb +WorkingDirectory=/srv/http/archweb +ExecStart=/srv/http/archweb/env/bin/python manage.py mirrorcheck --location 3 +ExecStart=/srv/http/archweb/env/bin/python manage.py mirrorcheck --location 4 +Nice=5 + +[Install] +WantedBy=multi-user.target diff --git a/roles/archweb/files/archweb-mirrorcheck.timer b/roles/archweb/files/archweb-mirrorcheck.timer new file mode 100644 index 000000000..b3ef3ed9a --- /dev/null +++ b/roles/archweb/files/archweb-mirrorcheck.timer @@ -0,0 +1,10 @@ +[Unit] +Description=archweb mirrorcheck + +[Timer] +OnUnitActiveSec=1h +OnBootSec=10min +RandomizedDelaySec=5min + +[Install] +WantedBy=timers.target diff --git a/roles/archweb/files/archweb-reporead.service b/roles/archweb/files/archweb-reporead.service new file mode 100644 index 000000000..d48058a71 --- /dev/null +++ b/roles/archweb/files/archweb-reporead.service @@ -0,0 +1,13 @@ +[Unit] +Description=archweb reporead +After=network.target + +[Service] +User=archweb +WorkingDirectory=/srv/http/archweb +ExecStart=/srv/http/archweb/env/bin/python manage.py reporead_inotify +Restart=on-failure +Nice=5 + +[Install] +WantedBy=multi-user.target diff --git a/roles/archweb/handlers/main.yml b/roles/archweb/handlers/main.yml new file mode 100644 index 000000000..f9ee66365 --- /dev/null +++ b/roles/archweb/handlers/main.yml @@ -0,0 +1,4 @@ +--- + +- name: daemon reload + command: systemctl daemon-reload diff --git a/roles/archweb/tasks/main.yml b/roles/archweb/tasks/main.yml new file mode 100644 index 000000000..752940663 --- /dev/null +++ b/roles/archweb/tasks/main.yml @@ -0,0 +1,46 @@ +--- + +- name: install git + pacman: name=git,python2,python2-virtualenv state=present + +- name: make archweb uesr + user: name=archweb shell=/bin/false home="{{ archweb_home }}" createhome=no + +- name: fix home permissions + file: state=directory owner=archweb group=archweb path="{{ archweb_home }}" + +- name: clone archweb repo + git: repo=git://git.archlinux.org/archweb.git dest="{{ archweb_home }}" + become: true + become_user: archweb + +- name: make virtualenv + command: virtualenv2 "{{ archweb_home }}"/env + become: true + become_user: archweb + +- name: install stuff into virtualenv + pip: requirements="{{ archweb_home }}/requirements_prod.txt" virtualenv="{{ archweb_home }}/env" + become: true + become_user: archweb + +- name: fix home permissions + file: state=directory owner=archweb group=archweb path="{{ archweb_home }}" + +- name: copy archweb-reporead.service + copy: src="{{ item }}" dest="/etc/systemd/system/{{ item }}" owner=root group=root mode=0644 + with_items: + - archweb-reporead.service + - archweb-mirrorcheck.service + - archweb-mirrorcheck.timer + notify: + - daemon reload + +- name: configure archweb + template: src=local_settings.py.j2 dest=/srv/http/archweb/local_settings.py owner=archweb group=archweb mode=660 + +- name: start and enable archweb services + service: name="{{ item }}" enabled=yes state=started + with_items: + - archweb-reporead.service + - archweb-mirrorcheck.timer diff --git a/roles/archweb/templates/local_settings.py.j2 b/roles/archweb/templates/local_settings.py.j2 new file mode 100644 index 000000000..397061635 --- /dev/null +++ b/roles/archweb/templates/local_settings.py.j2 @@ -0,0 +1,28 @@ +# Django settings for archlinux project. + + +## Database settings +DATABASES = { + 'default': { + 'ENGINE' : 'django.db.backends.postgresql_psycopg2', + 'NAME' : 'archweb', + 'USER' : 'archweb_update', + 'PASSWORD': '{{ postgres_users.archweb_update }}', + 'HOST' : 'gudrun.archlinux.org', + 'OPTIONS' : { + 'autocommit': True, + 'application_name': 'archweb', + 'sslmode': 'require', + } + } +} + +## Make this unique, and don't share it with anybody. +SECRET_KEY = '{{ archweb_secret_key }}' + +## Cache settings +CACHE_BACKEND = 'memcached://gudrun.archlinux.org:11211' +CACHE_MIDDLEWARE_SECONDS = 300 +CACHE_MIDDLEWARE_KEY_PREFIX = 'arch' + +# vim: set ts=4 sw=4 et: -- GitLab