-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdeploy.yml
More file actions
95 lines (77 loc) · 3.17 KB
/
deploy.yml
File metadata and controls
95 lines (77 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
---
- hosts: all
become: true
become_user: root
become_method: sudo
serial: 1
vars:
sleep_time: "{{ ((restart_delay|default(60))/2)|int|abs }}"
pre_tasks:
- name: socat installed
apt: pkg=socat state=present
- name: Newrelic Python config
template: src=templates/newrelic.ini.j2 dest=/srv/python27-apps/pleiades4/newrelic.ini owner=plone_daemon group=plone_group mode=0644
when: newrelic_license_key is defined
- set_fact:
instance_task:
name: pleiades-instance{{ item }}
command: /srv/python27-apps/pleiades4/bin/instance{{ item }} console
directory: /srv/python27-apps/pleiades4
user: plone_daemon
redirect_stderr: true
stopwaitsecs: 30
autostart: true
autorestart: true
with_sequence: start=1 end={{ plone_client_count }}
register: instance_task_results
- set_fact:
supervisor_tasks: "{{instance_task_results.results | map(attribute='ansible_facts.instance_task') | list + supervisor_tasks}}"
- set_fact:
balancer_client:
name: plone_{{ item }}
port: 840{{ item }}
number: "{{ item }}"
preload_command: "{% for i in cache_preload_urls %}curl http://localhost:840{{ item }}{{ i }} -s -o - > /dev/null; {%endfor%}"
with_sequence: start=1 end={{ plone_client_count }}
register: balancer_client_results
- set_fact:
balancer_clients: "{{balancer_client_results.results | map(attribute='ansible_facts.balancer_client') | list}}"
roles:
- {role: 'buildout',
base_dir: '/srv/python27-apps',
buildout_python: '/srv/python27-apps/bin/python2.7',
instance_name: 'pleiades4',
buildout_repo: 'https://github.com/isawnyu/pleiades3-buildout.git',
buildout_version: "{{ pleiades_buildout_branch }}",
buildout_file: "{{ pleiades_buildout_file }}",
tags: ['plone4', 'buildout'],
}
tasks:
- name: Run buildout pleiades4
command: bin/buildout -c {{ pleiades_buildout_file }}
args:
chdir: /srv/python27-apps/pleiades4
when: not buildout_run is defined
become: yes
become_user: plone_buildout
- name: Pleiades frontpage update
git:
repo=https://github.com/isawnyu/pleiades-frontpage.git
update=yes
dest=/var/www/pleiades.stoa.org/pleiades-frontpage
version={{pleiades_static_branch}}
force=yes
accept_hostkey=yes
become_user: "www-data"
tags:
- frontpage
post_tasks:
- name: Restart admin instance
command: supervisorctl restart pleiades-instance1
- name: Rolling restart of load balanced instances
shell: echo "disable server default/{{ item.name }}" | socat /var/run/haproxy.sock stdio && supervisorctl stop pleiades-instance{{ item.number }} && sleep {{ sleep_time }} && supervisorctl start pleiades-instance{{ item.number }} && sleep {{ sleep_time }} && {{ item.preload_command }} echo "enable server default/{{ item.name }}" | socat /var/run/haproxy.sock stdio
with_items: "{{ balancer_clients }}"
handlers:
- name: Restart buildout pleiades4
meta: noop
ignore_errors: yes