|
@@ -0,0 +1,131 @@
|
|
1
|
+- name: Install gpodder dependencies
|
|
2
|
+ apt:
|
|
3
|
+ name: "{{ packages }}"
|
|
4
|
+ state: present
|
|
5
|
+ vars:
|
|
6
|
+ packages:
|
|
7
|
+ - libpq-dev
|
|
8
|
+ - libjpeg-dev
|
|
9
|
+ - zlib1g-dev
|
|
10
|
+ - libwebp-dev
|
|
11
|
+ - build-essential
|
|
12
|
+ - python3-dev
|
|
13
|
+ - virtualenv
|
|
14
|
+ - libffi-dev
|
|
15
|
+ tags:
|
|
16
|
+ - dependencies
|
|
17
|
+
|
|
18
|
+- name: Add gpodder user
|
|
19
|
+ user:
|
|
20
|
+ name: gpodder
|
|
21
|
+ home: /home/gpodder
|
|
22
|
+ create_home: yes
|
|
23
|
+ shell: /bin/bash
|
|
24
|
+ password_lock: yes
|
|
25
|
+ state: present
|
|
26
|
+ system: yes
|
|
27
|
+
|
|
28
|
+- name: Add gpodder postgres user
|
|
29
|
+ postgresql_user:
|
|
30
|
+ login_host=localhost
|
|
31
|
+ login_user={{ db_admin_username }}
|
|
32
|
+ login_password="{{ db_admin_password }}"
|
|
33
|
+ name={{ gpodder_db_username }}
|
|
34
|
+ password="{{ gpodder_db_password }}"
|
|
35
|
+ encrypted=yes
|
|
36
|
+ state=present
|
|
37
|
+
|
|
38
|
+- name: Create gpodder database
|
|
39
|
+ postgresql_db:
|
|
40
|
+ login_host=localhost
|
|
41
|
+ login_user={{ db_admin_username }}
|
|
42
|
+ login_password="{{ db_admin_password }}"
|
|
43
|
+ name={{ gpodder_db_database }}
|
|
44
|
+ state=present
|
|
45
|
+ owner={{ gpodder_db_username }}
|
|
46
|
+
|
|
47
|
+- name: Download gpodder {{ gpodder_version }} release
|
|
48
|
+ get_url:
|
|
49
|
+ url="{{ gpodder_release }}"
|
|
50
|
+ dest=/home/gpodder/gpodder-{{ gpodder_version }}.zip
|
|
51
|
+
|
|
52
|
+- name: Stop old gpodder instance
|
|
53
|
+ service: name=gpodder state=stopped
|
|
54
|
+ ignore_errors: True
|
|
55
|
+
|
|
56
|
+- name: Remove old gpodder directory
|
|
57
|
+ shell: rm -rf /home/gpodder/gpodder
|
|
58
|
+
|
|
59
|
+- name: Create gpodder directory
|
|
60
|
+ file: state=directory path=/home/gpodder/gpodder
|
|
61
|
+
|
|
62
|
+- name: Extract gpodder sources
|
|
63
|
+ unarchive:
|
|
64
|
+ src: /home/gpodder/gpodder-{{ gpodder_version }}.zip
|
|
65
|
+ dest: /home/gpodder/gpodder
|
|
66
|
+ remote_src: yes
|
|
67
|
+
|
|
68
|
+- name: Move sources in correct place
|
|
69
|
+ shell: mv mygpo-{{ gpodder_version }}/* . chdir=/home/gpodder/gpodder
|
|
70
|
+
|
|
71
|
+- name: Remove empty directory
|
|
72
|
+ shell: rm -rf /home/gpodder/gpodder/mygpo-{{ gpodder_version }}
|
|
73
|
+
|
|
74
|
+- name: Create virtualenv
|
|
75
|
+ shell: virtualenv venv chdir=/home/gpodder/gpodder
|
|
76
|
+
|
|
77
|
+- name: Install generic dependencies in virtualenv
|
|
78
|
+ shell: bash -c 'source venv/bin/activate && pip install -r requirements.txt' chdir=/home/gpodder/gpodder
|
|
79
|
+
|
|
80
|
+- name: Install dependencies for production in virtualenv
|
|
81
|
+ shell: bash -c 'source venv/bin/activate && pip install -r requirements-setup.txt' chdir=/home/gpodder/gpodder
|
|
82
|
+
|
|
83
|
+- name: Create gpodder media directory
|
|
84
|
+ file:
|
|
85
|
+ state: directory
|
|
86
|
+ path: "/data/gpodder"
|
|
87
|
+ owner: gpodder
|
|
88
|
+ group: gpodder
|
|
89
|
+ mode: 0750
|
|
90
|
+
|
|
91
|
+# TODO put env somewhere so we can use it for systemd unit, migration and cron
|
|
92
|
+
|
|
93
|
+- name: Run database migration script
|
|
94
|
+ shell: bash -c 'source venv/bin/activate && DATABASE_URL=postgres://{{ gpodder_db_username }}:{{ gpodder_db_password }}@localhost:5432/{{ gpodder_db_database }}?sslmode=disable SECRET_KEY={{ gpodder_secret }} python manage.py migrate' chdir=/home/gpodder/gpodder
|
|
95
|
+
|
|
96
|
+- name: Add systemd service to start gpodder automatically
|
|
97
|
+ template:
|
|
98
|
+ src=etc_systemd_system_gpodder.j2
|
|
99
|
+ dest=/etc/systemd/system/gpodder.service
|
|
100
|
+ owner=root
|
|
101
|
+ group=root
|
|
102
|
+
|
|
103
|
+- name: Register new gpodder service
|
|
104
|
+ systemd: name=gpodder daemon_reload=yes enabled=yes
|
|
105
|
+
|
|
106
|
+- name: Start new gpodder instance
|
|
107
|
+ service: name=gpodder state=started
|
|
108
|
+
|
|
109
|
+# TODO cron jobs
|
|
110
|
+# envdir envs/dev python manage.py update-toplist
|
|
111
|
+# envdir envs/dev python manage.py update-episode-toplist
|
|
112
|
+
|
|
113
|
+# envdir envs/dev python manage.py feed-downloader
|
|
114
|
+# envdir envs/dev python manage.py feed-downloader <feed-url> [...]
|
|
115
|
+# envdir envs/dev python manage.py feed-downloader --max <max-updates>
|
|
116
|
+# envdir envs/dev python manage.py feed-downloader --random --max <max-updates>
|
|
117
|
+# envdir envs/dev python manage.py feed-downloader --toplist --max <max-updates>
|
|
118
|
+# envdir envs/dev python manage.py feed-downloader --update-new --max <max-updates>
|
|
119
|
+
|
|
120
|
+- name: Create the Apache gpodder sites config files
|
|
121
|
+ template:
|
|
122
|
+ src=etc_apache2_sites-available_gpodder.j2
|
|
123
|
+ dest=/etc/apache2/sites-available/gpodder_{{ item.name }}.conf
|
|
124
|
+ owner=root
|
|
125
|
+ group=root
|
|
126
|
+ with_items: "{{ virtual_domains }}"
|
|
127
|
+
|
|
128
|
+- name: Enable Apache sites (creates new sites-enabled symlinks)
|
|
129
|
+ command: a2ensite gpodder_{{ item }}.conf creates=/etc/apache2/sites-enabled/gpodder_{{ item }}.conf
|
|
130
|
+ notify: restart apache
|
|
131
|
+ with_items: "{{ virtual_domains | json_query('[*].name') }}"
|