|
250 | 250 | loop: "{{ lookup('dict',archivematica_src_configure_fprule|default({}),wantlist=True) }}" |
251 | 251 | when: archivematica_src_configure_fprule is defined |
252 | 252 |
|
253 | | -- name: "Configure locations" |
254 | | - environment: "{{ archivematica_src_ss_environment }}" |
255 | | - block: |
256 | | - # Get id of the first registered pipeline (id=1) |
257 | | - - name: "Configure AM: get default pipeline UUID from SS database" |
258 | | - shell: > |
259 | | - echo "select uuid from locations_pipeline where id='1';" |
260 | | - | {{ archivematica_src_ss_virtualenv }}/bin/python manage.py dbshell | tail -n1 |
261 | | - args: |
262 | | - chdir: "{{ archivematica_src_ss_app }}" |
263 | | - executable: "/bin/bash" |
264 | | - register: pipeline_uuid |
265 | | - |
266 | | - # Gets the uuid of the first registered space (id=1) |
267 | | - - name: "Configure AM: get default Space UUID from SS database" |
268 | | - shell: > |
269 | | - echo "select uuid from locations_space where id='1';" |
270 | | - | {{ archivematica_src_ss_virtualenv }}/bin/python manage.py dbshell | tail -n1 |
271 | | - args: |
272 | | - chdir: "{{ archivematica_src_ss_app }}" |
273 | | - executable: "/bin/bash" |
274 | | - register: space_uuid |
275 | | - |
276 | | - - name: "Configure AM: get all TS descriptions from SS database" |
277 | | - shell: > |
278 | | - echo "select description from locations_location;" |
279 | | - | {{ archivematica_src_ss_virtualenv }}/bin/python manage.py dbshell | grep -v "^description$" |
280 | | - args: |
281 | | - chdir: "{{ archivematica_src_ss_app }}" |
282 | | - executable: "/bin/bash" |
283 | | - register: location_descriptions |
284 | | - |
285 | | - - name: "Configure SS: add custom locations" |
286 | | - uri: |
287 | | - url: "{{ archivematica_src_configure_ss_url }}/api/v2/location/" |
288 | | - headers: |
289 | | - Content-Type: "application/json" |
290 | | - Authorization: "ApiKey {{ archivematica_src_configure_ss_user }}:{{ archivematica_src_configure_ss_api_key }}" |
291 | | - body: |
292 | | - pipeline: ["/api/v2/pipeline/{{ pipeline_uuid.stdout }}/"] |
293 | | - purpose: "{{ item.location_purpose }}" |
294 | | - relative_path: "{{ item.location_path | regex_replace('^\\/', '') }}" |
295 | | - description: "{{ item.location_description }}" |
296 | | - space: "/api/v2/space/{{ space_uuid.stdout }}/" |
297 | | - default: "{{ item.location_default }}" |
298 | | - body_format: json |
299 | | - status_code: 201 |
300 | | - method: POST |
301 | | - when: not location_descriptions.stdout | join('') | regex_search( '(^|\n)'+item.location_description+'(\n|$)' ) |
302 | | - with_items: "{{ am_ss_default_locations }}" |
303 | | - |
304 | | -# |
305 | | -# S3 Space/locations configuration |
306 | | -# |
307 | | - |
308 | | - - name: "Configure AM: get S3 Space UUID from SS database" |
309 | | - shell: > |
310 | | - echo "select uuid from locations_space where access_protocol='S3';" |
311 | | - | {{ archivematica_src_ss_virtualenv }}/bin/python manage.py dbshell | tail -n1 |
312 | | - args: |
313 | | - chdir: "{{ archivematica_src_ss_app }}" |
314 | | - executable: "/bin/bash" |
315 | | - register: s3_space_exists |
316 | | - |
317 | | - - name: "Configure SS: add spaces" |
318 | | - uri: |
319 | | - url: "{{ archivematica_src_configure_ss_url }}/api/v2/space/" |
320 | | - headers: |
321 | | - Content-Type: "application/json" |
322 | | - Authorization: "ApiKey {{ archivematica_src_configure_ss_user }}:{{ archivematica_src_configure_ss_api_key }}" |
323 | | - body: |
324 | | - access_protocol: "{{ item.access_protocol }}" |
325 | | - path: "{{ item.path }}" |
326 | | - staging_path: "{{ item.staging_path }}" |
327 | | - endpoint_url: "{{ item.endpoint_url }}" |
328 | | - access_key_id: "{{ item.access_key_id }}" |
329 | | - secret_access_key: "{{ item.secret_access_key }}" |
330 | | - region: "{{ item.region }}" |
331 | | - bucket: "{{ item.bucket }}" |
332 | | - body_format: json |
333 | | - status_code: 201 |
334 | | - method: POST |
335 | | - with_items: "{{ am_ss_s3_spaces }}" |
336 | | - when: |
337 | | - - s3_space_exists.stdout == "" |
338 | | - - am_ss_s3_spaces is defined |
339 | | - |
340 | | - - name: "Configure AM: get existing S3 Space UUID from SS database" |
341 | | - shell: > |
342 | | - echo "select uuid from locations_space where access_protocol='S3';" |
343 | | - | {{ archivematica_src_ss_virtualenv }}/bin/python manage.py dbshell | tail -n1 |
344 | | - args: |
345 | | - chdir: "{{ archivematica_src_ss_app }}" |
346 | | - executable: "/bin/bash" |
347 | | - register: s3_space_uuid |
348 | | - |
349 | | - - name: "Configure SS: add S3 locations" |
350 | | - uri: |
351 | | - url: "{{ archivematica_src_configure_ss_url }}/api/v2/location/" |
352 | | - headers: |
353 | | - Content-Type: "application/json" |
354 | | - Authorization: "ApiKey {{ archivematica_src_configure_ss_user }}:{{ archivematica_src_configure_ss_api_key }}" |
355 | | - body: |
356 | | - pipeline: ["/api/v2/pipeline/{{ pipeline_uuid.stdout }}/"] |
357 | | - purpose: "{{ item.location_purpose }}" |
358 | | - relative_path: "{{ item.location_path | regex_replace('^\\/', '') }}" |
359 | | - staging_path: "{{ item.staging_path }}" |
360 | | - description: "{{ item.location_description }}" |
361 | | - space: "/api/v2/space/{{ s3_space_uuid.stdout }}/" |
362 | | - default: "{{ item.location_default }}" |
363 | | - body_format: json |
364 | | - status_code: 201 |
365 | | - method: POST |
366 | | - with_items: "{{ am_ss_s3_locations | default([]) }}" |
367 | | - when: |
368 | | - - am_ss_s3_locations is defined and am_ss_s3_locations != "" |
369 | | - - not location_descriptions.stdout | join('') | regex_search( '(^|\n)'+item.location_description+'(\n|$)' ) |
370 | | - |
371 | | -# |
372 | | -# Configure replication |
373 | | -# |
374 | | - |
375 | | - - name: "Configure replicas" |
376 | | - shell: | |
377 | | - if [ x"$PURPOSE" == x"RP" ] |
378 | | - then |
379 | | - echo $LOCATION replicates $REPLICAOF |
380 | | - LOCATION_ID=$(echo "select id from locations_location where description=\"$LOCATION\";" | {{ archivematica_src_ss_virtualenv }}/bin/python manage.py dbshell | tail -n1 ) |
381 | | - REPLICAOF_ID=$(echo "select id from locations_location where description=\"$REPLICAOF\";" | {{ archivematica_src_ss_virtualenv }}/bin/python manage.py dbshell | tail -n1) |
382 | | - CONFIG_ID=$(echo "select id from locations_location_replicators where from_location_id=$REPLICAOF_ID and to_location_id=$LOCATION_ID;" | {{ archivematica_src_ss_virtualenv }}/bin/python manage.py dbshell | tail -n1) |
383 | | - if [ x$CONFIG_ID == x ] |
384 | | - then |
385 | | - echo "insert into locations_location_replicators (from_location_id, to_location_id) values($REPLICAOF_ID,$LOCATION_ID);" | {{ archivematica_src_ss_virtualenv }}/bin/python manage.py dbshell |
386 | | - fi |
387 | | - fi |
388 | | - args: |
389 | | - chdir: "{{ archivematica_src_ss_app }}" |
390 | | - executable: "/bin/bash" |
391 | | - environment: |
392 | | - PURPOSE: "{{ item.location_purpose }}" |
393 | | - LOCATION: "{{ item.location_description }}" |
394 | | - REPLICAOF: "{{ item.location_replicaof|default('') }}" |
395 | | - with_items: |
396 | | - - "{{ am_ss_default_locations|default({}) }}" |
397 | | - - "{{ am_ss_s3_locations|default({}) }}" |
398 | | - when: am_ss_default_locations is defined or am_ss_s3_locations is defined |
399 | | - tags: |
400 | | - - "configure-am" |
401 | | - - "configure-locations" |
0 commit comments