|
46 | 46 | state: absent |
47 | 47 | when: ansible_os_family == 'Debian' |
48 | 48 |
|
49 | | - - name: Ensure the python command exists |
50 | | - ansible.builtin.shell: |
51 | | - cmd: which python||exit 0 |
52 | | - register: python_path |
53 | | - tags: py |
54 | | - - name: Register python3 path |
55 | | - ansible.builtin.command: which python3 |
56 | | - register: python3_path |
57 | | - when: python_path.stdout == "" |
58 | | - tags: py |
59 | | - - name: Link python to python3 if missing |
60 | | - ansible.builtin.file: |
61 | | - src: "{{ python3_path.stdout }}" |
62 | | - dest: "{{ python3_path.stdout[:-1] }}" |
63 | | - state: link |
64 | | - force: yes |
65 | | - when: python_path.stdout == "" |
66 | | - tags: py |
67 | | - |
68 | | - - git: |
69 | | - repo: 'https://github.com/usegalaxy-eu/libraries-training-repo' |
70 | | - dest: /libraries/ |
71 | | - when: "'usegalaxy' in inventory_hostname" |
72 | | -# - name: Create data storage for UMSA |
73 | | -# file: |
74 | | -# owner: "{{ galaxy_user_name }}" |
75 | | -# group: "{{ galaxy_user_group_name }}" |
76 | | -# path: "{{ galaxy_data_dir }}" |
77 | | -# state: directory |
78 | | -# mode: "0755" |
79 | | -# when: "'umsa' in inventory_hostname" |
80 | | - - name: Create the RBD storage directory |
81 | | - file: |
82 | | - owner: "{{ galaxy_user_name }}" |
83 | | - group: "{{ galaxy_user_group_name }}" |
84 | | - path: /rbd/data |
85 | | - state: directory |
86 | | - mode: '0755' |
87 | | - when: "'usegalaxy' in inventory_hostname" |
88 | | - |
89 | | - - name: Ensure galaxy temp dir mount |
90 | | - mount: |
91 | | - path: "{{ galaxy_temp_dir }}" |
92 | | - src: "/dev/rbd0" |
93 | | - fstype: "ext4" |
94 | | - opts: "defaults,nodev,nosuid,noexec,noatime,_netdev" |
95 | | - passno: "2" |
96 | | - state: mounted |
97 | | - - name: Create the galaxy temp directory under root |
98 | | - file: |
99 | | - owner: root |
100 | | - group: root |
101 | | - path: "{{ galaxy_temp_dir }}" |
102 | | - state: directory |
103 | | - mode: '1777' |
104 | | - - name: Create the nginx upload job files store |
105 | | - file: |
106 | | - owner: www-data |
107 | | - group: "{{ galaxy_user_group_name }}" |
108 | | - path: "{{ galaxy_temp_dir }}/_upload_job_files" |
109 | | - state: directory |
110 | | - mode: '0775' |
111 | | - - name: Create the client body temp path |
112 | | - file: |
113 | | - owner: www-data |
114 | | - group: "{{ galaxy_user_group_name }}" |
115 | | - path: "{{ galaxy_temp_dir }}/nginx_upload_store" |
116 | | - state: directory |
117 | | - mode: '0775' |
118 | 49 | ## Part responsible for setting up NBD mount (specific for galaxy-re) |
119 | 50 | - name: Check if /dev/nbd0 exists |
120 | 51 | stat: |
|
153 | 84 | state: mounted |
154 | 85 | when: "'galaxy-re' in inventory_hostname or 'galaxy-re' in ansible_hostname" |
155 | 86 |
|
156 | | -# recover from WAL based on https://training.galaxyproject.org/training-material/topics/admin/tutorials/backup-cleanup/tutorial.html#restoration |
157 | | - ## Part responsible for recovering Galaxy DB from backup if exists (it should be in post_tasks of dbservers but NDB access needs to be set up first) |
158 | | - - name: Register psql data directory |
159 | | - ansible.builtin.shell: |
160 | | - cmd: psql -Atc 'show data_directory;' |
161 | | - register: psql_data_dir |
162 | | - become: true |
163 | | - become_user: postgres |
164 | | - tags: gal_db |
165 | | - - name: Check if Galaxy DB exists |
166 | | - ansible.builtin.shell: |
167 | | - cmd: "psql -XAtc '\\l' |cut -f 1 -d '|' |grep -qw {{ galaxy_db_name }}" |
168 | | - register: galaxy_db_in_psql |
169 | | - ignore_errors: true |
170 | | - become: true |
171 | | - become_user: postgres |
172 | | - tags: gal_db |
173 | | - - name: Restore Galaxy DB backup - stop postgresql |
174 | | - ansible.builtin.systemd: |
175 | | - name: postgresql |
176 | | - state: stopped |
177 | | - when: galaxy_db_in_psql.rc == 1 |
178 | | - tags: gal_db |
179 | | - - name: Restore Galaxy DB backup - backup current postgresql |
180 | | - ansible.builtin.shell: |
181 | | - cmd: "mv {{ psql_data_dir.stdout }} {{ psql_data_dir.stdout+'.backup_'+ansible_date_time.iso8601 }}" |
182 | | - ignore_errors: true |
183 | | - when: galaxy_db_in_psql.rc == 1 and psql_data_dir.stdout != '' |
184 | | - become: true |
185 | | - become_user: postgres |
186 | | - tags: gal_db |
187 | | - |
188 | | - - name: Restore Galaxy DB backup - pick proper backup version |
189 | | - ansible.builtin.shell: |
190 | | - cmd: "if [ '{{ galaxy_db_restore_version }}' = 'latest' ]; then ls -dt {{ postgresql_backup_dir }}/20*Z | head -1; else ls -d {{ postgresql_backup_dir }}/{{ galaxy_db_restore_version }}; fi " |
191 | | - register: galaxy_db_restore_dir |
192 | | - when: galaxy_db_in_psql.rc == 1 |
193 | | - become: true |
194 | | - become_user: postgres |
195 | | - tags: gal_db |
196 | | - - name: Restore Galaxy DB backup - copy proper backup version |
197 | | - ansible.builtin.shell: |
198 | | - cmd: "rsync -a {{ galaxy_db_restore_dir.stdout }}/ {{ psql_data_dir.stdout }}/ && chmod -R 0750 {{ psql_data_dir.stdout }} " |
199 | | - when: galaxy_db_in_psql.rc == 1 and galaxy_db_restore_dir.stdout != '' and psql_data_dir.stdout != '' |
200 | | - become: true |
201 | | - become_user: postgres |
202 | | - tags: gal_db |
203 | | -# - name: Restore Galaxy DB backup - pick the latest backup version |
204 | | -# ansible.builtin.shell: |
205 | | -# cmd: "ls -dt {{ postgresql_backup_dir }}/20*Z | head -1 " |
206 | | -# register: galaxy_db_restore_dir_latest |
207 | | -# ignore_errors: true |
208 | | -# when: galaxy_db_in_psql.rc == 1 and galaxy_db_restore_version == 'latest' |
209 | | -# become: true |
210 | | -# become_user: postgres |
211 | | -# tags: gal_db |
212 | | -# - name: Restore Galaxy DB backup - pick the user-defined backup version |
213 | | -# ansible.builtin.shell: |
214 | | -# cmd: "ls -d {{ postgresql_backup_dir }}/{{ galaxy_db_restore_version }} " |
215 | | -# register: galaxy_db_restore_dir |
216 | | -# ignore_errors: true |
217 | | -# when: galaxy_db_in_psql.rc == 1 and galaxy_db_restore_version != 'latest' |
218 | | -# become: true |
219 | | -# become_user: postgres |
220 | | -# tags: gal_db |
221 | | -# - name: Restore Galaxy DB backup - copy latest backup version |
222 | | -# ansible.builtin.shell: |
223 | | -# cmd: "rsync -a {{ galaxy_db_restore_dir_latest.stdout }}/ {{ psql_data_dir.stdout }}/ && chmod -R 0750 {{ psql_data_dir.stdout }} " |
224 | | -# when: galaxy_db_in_psql.rc == 1 and galaxy_db_restore_dir_latest.stdout != '' and psql_data_dir.stdout != '' |
225 | | -# become: true |
226 | | -# become_user: postgres |
227 | | -# tags: gal_db |
228 | | -# - name: Restore Galaxy DB backup - copy user-defined backup version |
229 | | -# ansible.builtin.shell: |
230 | | -# cmd: "rsync -a {{ galaxy_db_restore_dir.stdout }}/ {{ psql_data_dir.stdout }}/ && chmod -R 0750 {{ psql_data_dir.stdout }} " |
231 | | -# when: galaxy_db_in_psql.rc == 1 and galaxy_db_restore_dir.stdout != '' and psql_data_dir.stdout != '' |
232 | | -# become: true |
233 | | -# become_user: postgres |
234 | | -# tags: gal_db |
235 | | - - name: Restore Galaxy DB backup - fill postgresql.auto.conf |
236 | | - ansible.builtin.lineinfile: |
237 | | - path: "{{ psql_data_dir.stdout }}/postgresql.auto.conf" |
238 | | - insertafter: EOF |
239 | | - line: "restore_command = 'cp \"{{ postgresql_backup_dir }}/wal_archive/%f\" \"%p\"'" |
240 | | - state: present |
241 | | - create: true |
242 | | - when: galaxy_db_in_psql.rc == 1 and psql_data_dir.stdout != '' |
243 | | - become: true |
244 | | - become_user: postgres |
245 | | - tags: gal_db |
246 | | - - name: Restore Galaxy DB backup - touch the signal file |
247 | | - ansible.builtin.shell: |
248 | | - cmd: "touch {{ psql_data_dir.stdout }}/recovery.signal " |
249 | | - when: galaxy_db_in_psql.rc == 1 and psql_data_dir.stdout != '' |
250 | | - become: true |
251 | | - become_user: postgres |
252 | | - tags: gal_db |
253 | | - - name: Restore Galaxy DB backup - start postgresql |
254 | | - ansible.builtin.systemd: |
255 | | - name: postgresql |
256 | | - state: started |
257 | | - tags: gal_db |
258 | | - |
259 | 87 | roles: |
260 | 88 | - galaxyproject.tusd |
261 | 89 | - galaxyproject.galaxy |
262 | 90 | - usegalaxy_eu.tpv_auto_lint |
263 | | - - role: galaxyproject.miniconda |
264 | | - become: true |
265 | | - become_user: "{{ galaxy_user_name }}" |
| 91 | +# - role: galaxyproject.miniconda |
| 92 | +# become: true |
| 93 | +# become_user: "{{ galaxy_user_name }}" |
266 | 94 | - geerlingguy.redis |
267 | 95 | - galaxyproject.nginx |
268 | 96 | - usegalaxy_eu.flower |
|
289 | 117 | minute: "2" |
290 | 118 | hour: "*" |
291 | 119 | #DEMON: zvazit ci nepouzit find /rbd/data/datasets/*/*/*/dataset_*_files -type f ! -perm /g+rw -exec chmod g+rw '{}' ';' |
292 | | - job: "/usr/bin/find {{ galaxy_config.galaxy.file_path }}/*/*/*/dataset_*_files -type d -mmin -180 -maxdepth 0 -exec chmod -R g+rw '{}' ';'" |
| 120 | + job: "/usr/bin/find {{ galaxy_config.galaxy.file_path }}/*/*/*/dataset_*_files -maxdepth 0 -type d -mmin -240 -exec chmod -R g+rw '{}' ';'" |
293 | 121 | become: yes |
294 | 122 | become_user: "{{ galaxy_user_name }}" |
295 | 123 | - name: Creates entry in crontab "tmpreaper call in tus upload dir" |
296 | 124 | ansible.builtin.cron: |
297 | 125 | name: "tmpreaper in tus upload dir" |
298 | 126 | minute: "5" |
299 | 127 | hour: "*" |
300 | | - job: "/usr/sbin/tmpreaper --verbose=0 --showdeleted --all --mtime --mtime-dir --runtime=600 4h {{ galaxy_tus_upload_store }} >> {{ galaxy_data_dir }}/cleaning_tus_upload_dir.log" |
| 128 | + job: "/usr/sbin/tmpreaper --verbose=0 --showdeleted --all --mtime --mtime-dir --runtime=600 24h {{ galaxy_tus_upload_store }} >> {{ galaxy_data_dir }}/cleaning_tus_upload_dir.log" |
301 | 129 | become: yes |
302 | 130 | become_user: "{{ galaxy_user_name }}" |
303 | 131 | - name: Creates entry in crontab "tmpreaper call in galaxy tmp dir" |
304 | 132 | ansible.builtin.cron: |
305 | 133 | name: "tmpreaper in galaxy temp dir" |
306 | 134 | minute: "7" |
307 | 135 | hour: "*" |
308 | | - job: "/usr/sbin/tmpreaper --verbose=0 --showdeleted --all --mtime --mtime-dir --runtime=600 4h {{ galaxy_temp_dir }}/tmp >> {{ galaxy_data_dir }}/cleaning_galaxy_temp_dir.log" |
| 136 | + job: "/usr/sbin/tmpreaper --verbose=0 --showdeleted --all --mtime --mtime-dir --runtime=600 24h {{ galaxy_temp_dir }}/tmp >> {{ galaxy_data_dir }}/cleaning_galaxy_temp_dir.log" |
309 | 137 | become: yes |
310 | 138 | become_user: "{{ galaxy_user_name }}" |
| 139 | +# - name: Creates entry in crontab "tmpreaper call in galaxy jobs dir" |
| 140 | +# ansible.builtin.cron: |
| 141 | +# name: "tmpreaper in galaxy jobs dir" |
| 142 | +# minute: "9" |
| 143 | +# hour: "*" |
| 144 | +# job: "/usr/sbin/tmpreaper --verbose=0 --showdeleted --all --mtime --mtime-dir --runtime=600 40d {{ galaxy_temp_dir }}/jobs >> {{ galaxy_data_dir }}/cleaning_galaxy_jobs_dir.log" |
| 145 | +# become: yes |
| 146 | +# become_user: "{{ galaxy_user_name }}" |
311 | 147 | - name: Setup gxadmin cleanup task |
312 | 148 | ansible.builtin.cron: |
313 | 149 | name: "Cleanup Old User Data" |
314 | 150 | user: "{{ galaxy_user_name }}" # Run as the Galaxy user |
315 | 151 | minute: "0" |
316 | 152 | hour: "0" |
317 | | - job: "GALAXY_LOG_DIR=/tmp/gxadmin/ GALAXY_ROOT={{ galaxy_root }}/server /usr/local/bin/gxadmin galaxy cleanup 60" |
318 | | - - name: Setup user - group association rutine |
319 | | - ansible.builtin.cron: |
320 | | - name: "Add E-infra users to E-infra group" |
321 | | - user: postgres # Run as the postgres user |
322 | | - minute: "0" |
323 | | - hour: "*" |
324 | | - job: "python3 {{ playbook_dir }}/add_group_users.py {{ inventory_hostname }} {{ api_key }}" |
325 | | - when: "'usegalaxy' in inventory_hostname" |
| 153 | + job: "GALAXY_LOG_DIR=/tmp/gxadmin/ GALAXY_ROOT={{ galaxy_root }}/server /usr/local/bin/gxadmin galaxy cleanup 60 >> {{ galaxy_data_dir }}/cleaning_gxadmin_cleanup.log" |
326 | 154 | # - name: RE Galaxy instance patch in lib/galaxy/webapps/galaxy/api/job_files.py |
327 | 155 | # replace: |
328 | 156 | # path: "{{ galaxy_root }}/server/lib/galaxy/webapps/galaxy/api/job_files.py" |
|
0 commit comments