diff --git a/aws_bitbucket_dc_node.yml b/aws_bitbucket_dc_node.yml index 678037b..d8b67ec 100644 --- a/aws_bitbucket_dc_node.yml +++ b/aws_bitbucket_dc_node.yml @@ -34,5 +34,6 @@ - role: restore_backups - role: bitbucket_config - role: product_startup + - role: bitbucket_dataset_restore diff --git a/group_vars/aws_node_local.yml b/group_vars/aws_node_local.yml index 2dea1b5..bed9cb2 100644 --- a/group_vars/aws_node_local.yml +++ b/group_vars/aws_node_local.yml @@ -138,6 +138,6 @@ atl_restore_required: "{{ atl_backup_manifest_url is defined and atl_backup_mani atl_bitbucket_license_key: "{{ lookup('env', 'ATL_BB_LICENSEKEY') }}" atl_bitbucket_admin_password: "{{ lookup('env', 'ATL_BB_ADMIN_PASSWORD') }}" + atl_bitbucket_dataset_url: "{{ lookup('env', 'ATL_DATASET_URL') }}" atl_bitbucket_baseurl: "{{ lookup('env', 'ATL_BB_BASEURL') }}" - diff --git a/roles/bitbucket_dataset_restore/tasks/main.yml b/roles/bitbucket_dataset_restore/tasks/main.yml new file mode 100644 index 0000000..0204079 --- /dev/null +++ b/roles/bitbucket_dataset_restore/tasks/main.yml @@ -0,0 +1,56 @@ +--- +- name: Force all notified handlers to run at this point, not waiting for normal sync points + meta: flush_handlers + +- name: wait for port 7990 to be up + wait_for: + port: 7990 + delay: 60 + +- name: wait for path to become available + wait_for: + path: "{{ atl_product_home_shared }}/data/migration/import" + delay: 60 + +- name: Copy Bitbucket dataset from s3 + get_url: + url: "{{ atl_bitbucket_dataset_url }}" + dest: "{{ atl_product_home_shared }}/data/migration/import" + +- name: Invoke Import API + uri: + url: "{{ atl_bitbucket_baseurl }}/rest/api/1.0/migration/imports" + user: admin + password: "{{ atl_bitbucket_admin_password }}" + method: POST + follow_redirects: yes + force_basic_auth: yes + creates: "{{ atl_product_home_shared }}/data/migration/import/lock.file" + body: "{ \"archivePath\": \"{{ atl_bitbucket_dataset_url | basename }}\" }" + body_format: json + return_content: yes + register: output + until: output.status == 200 + retries: 6 + delay: 15 + failed_when: output is defined and output.json is defined and output.json.state != 'INITIALISING' + +- name: get import status + uri: + url: "{{ atl_bitbucket_baseurl }}/rest/api/1.0/migration/imports/{{ output.json.id }}" + user: admin + password: "{{ atl_bitbucket_admin_password }}" + method: get + force_basic_auth: yes + body_format: json + return_content: yes + register: import_status + until: import_status is defined and import_status.json is defined and import_status.json.state == 'COMPLETED' + retries: 30 + delay: 10 + +- name: create lock file + file: + path: "{{ atl_product_home_shared }}/data/migration/import/lock.file" + state: touch + when: import_status.json.state == 'COMPLETED'