Skip to content

Commit aef2863

Browse files
Miguel Angelmamedin
authored andcommitted
configure: Read SS key when SS user was configured
1 parent a95f435 commit aef2863

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

tasks/configure.yml

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,19 @@
1818

1919
# ss-configure
2020

21-
# Create api-key if not defined
22-
- set_fact: archivematica_src_configure_ss_api_key={{ 999999999999999999999 | random | to_uuid | hash('md5') }}
23-
when: "archivematica_src_configure_ss_api_key is undefined and archivematica_src_configure_ss|bool"
21+
- name: "Check for SS user"
22+
become: "yes"
23+
shell: echo 'select username from auth_user where username="{{ archivematica_src_configure_ss_user }}";' | {{ archivematica_src_ss_virtualenv }}/bin/python manage.py dbshell | tail -n1
24+
args:
25+
chdir: "{{ archivematica_src_ss_app }}"
26+
executable: /bin/bash
27+
environment: "{{ archivematica_src_ss_environment }}"
28+
register: ss_user
29+
when: archivematica_src_configure_ss|bool
30+
31+
- debug:
32+
msg: "The SS user {{ archivematica_src_configure_ss_user }} is already configured: The SS superuser will not be created."
33+
when: archivematica_src_configure_ss|bool and ss_user.stdout != ""
2434

2535
- name: "Get SS API Key"
2636
shell: >
@@ -34,24 +44,20 @@
3444
become: yes
3545
remote_user: "{{ archivematica_src_configure_ss_ssh_user | default('artefactual') }}"
3646
register: archivematica_src_configure_ss_api_key_temp
37-
when: "archivematica_src_configure_dashboard|bool and archivematica_src_configure_ss_api_key is undefined"
47+
when:
48+
- "archivematica_src_configure_dashboard|bool or archivematica_src_configure_ss|bool"
49+
- "archivematica_src_configure_ss_api_key is undefined"
3850

3951
- set_fact: archivematica_src_configure_ss_api_key="{{ archivematica_src_configure_ss_api_key_temp.stdout }}"
40-
when: "archivematica_src_configure_dashboard|bool and archivematica_src_configure_ss_api_key_temp.stdout is defined"
52+
when:
53+
- "archivematica_src_configure_dashboard|bool"
54+
- "archivematica_src_configure_ss_api_key_temp.stdout is defined"
4155

42-
- name: "Check for SS user"
43-
become: "yes"
44-
shell: echo 'select username from auth_user where username="{{ archivematica_src_configure_ss_user }}";' | {{ archivematica_src_ss_virtualenv }}/bin/python manage.py dbshell | tail -n1
45-
args:
46-
chdir: "{{ archivematica_src_ss_app }}"
47-
executable: /bin/bash
48-
environment: "{{ archivematica_src_ss_environment }}"
49-
register: ss_user
50-
when: archivematica_src_configure_ss|bool
51-
52-
- debug:
53-
msg: "The SS user {{ archivematica_src_configure_ss_user }} is already configured: The SS superuser will not be created."
54-
when: archivematica_src_configure_ss|bool and ss_user.stdout != ""
56+
# Create api-key if not defined and SS user was not already configured
57+
- set_fact: archivematica_src_configure_ss_api_key={{ 999999999999999999999 | random | to_uuid | hash('md5') }}
58+
when:
59+
- "archivematica_src_configure_ss_api_key is undefined"
60+
- "archivematica_src_configure_ss|bool"
5561

5662
- name: "Create SS superuser"
5763
django_manage:

0 commit comments

Comments
 (0)