Skip to content

Commit 315ebd4

Browse files
committed
Use dbshell in location configuration
This is needed if mysql is not in the same vm
1 parent 970c770 commit 315ebd4

File tree

1 file changed

+38
-14
lines changed

1 file changed

+38
-14
lines changed

tasks/configure.yml

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -251,22 +251,35 @@
251251
when: archivematica_src_configure_fprule is defined
252252

253253
- name: "Configure locations"
254+
environment: "{{ archivematica_src_ss_environment }}"
254255
block:
255256
# Get id of the first registered pipeline (id=1)
256257
- name: "Configure AM: get default pipeline UUID from SS database"
257-
become: "yes"
258-
command: mysql {{ archivematica_src_ss_db_name }} -Ns -e "select uuid from locations_pipeline where id='1';"
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"
259264
register: pipeline_uuid
260265

261266
# Gets the uuid of the first registered space (id=1)
262267
- name: "Configure AM: get default Space UUID from SS database"
263-
become: "yes"
264-
command: mysql {{ archivematica_src_ss_db_name }} -Ns -e "select uuid from locations_space where id='1';"
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"
265274
register: space_uuid
266275

267276
- name: "Configure AM: get all TS descriptions from SS database"
268-
become: "yes"
269-
command: mysql {{ archivematica_src_ss_db_name }} -Ns -e "select description from locations_location;"
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"
270283
register: location_descriptions
271284

272285
- name: "Configure SS: add custom locations"
@@ -293,8 +306,12 @@
293306
#
294307

295308
- name: "Configure AM: get S3 Space UUID from SS database"
296-
become: "yes"
297-
command: mysql {{ archivematica_src_ss_db_name }} -Ns -e "select uuid from locations_space where access_protocol='S3';"
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"
298315
register: s3_space_exists
299316

300317
- name: "Configure SS: add spaces"
@@ -321,8 +338,12 @@
321338
- am_ss_s3_spaces is defined
322339

323340
- name: "Configure AM: get existing S3 Space UUID from SS database"
324-
become: "yes"
325-
command: mysql {{ archivematica_src_ss_db_name }} -Ns -e "select uuid from locations_space where access_protocol='S3';"
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"
326347
register: s3_space_uuid
327348

328349
- name: "Configure SS: add S3 locations"
@@ -356,14 +377,17 @@
356377
if [ x"$PURPOSE" == x"RP" ]
357378
then
358379
echo $LOCATION replicates $REPLICAOF
359-
LOCATION_ID=$(echo "select id from locations_location where description=\"$LOCATION\";" | mysql -s -N SS)
360-
REPLICAOF_ID=$(echo "select id from locations_location where description=\"$REPLICAOF\";" | mysql -s -N SS)
361-
CONFIG_ID=$(echo "select id from locations_location_replicators where from_location_id=$REPLICAOF_ID and to_location_id=$LOCATION_ID;" | mysql -s -N SS)
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)
362383
if [ x$CONFIG_ID == x ]
363384
then
364-
echo "insert into locations_location_replicators (from_location_id, to_location_id) values($REPLICAOF_ID,$LOCATION_ID);" | mysql -s -N SS
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
365386
fi
366387
fi
388+
args:
389+
chdir: "{{ archivematica_src_ss_app }}"
390+
executable: "/bin/bash"
367391
environment:
368392
PURPOSE: "{{ item.location_purpose }}"
369393
LOCATION: "{{ item.location_description }}"

0 commit comments

Comments
 (0)