From 20a9c089794d03c7dd360eb7645801d9fa744475 Mon Sep 17 00:00:00 2001 From: Varun Arbatti Date: Tue, 31 Dec 2019 00:37:50 +0000 Subject: [PATCH] Merged in DCD-797-restore_independent-of_db_init_role (pull request #61) DCD-797: Make restore work without requiring database_init role to be run * DCD-797: Make restore work without requiring database_init role to be run * DCD-797: Fixes error with yaml lint * DCD-797: Adds check before running restore database tasks * DCD-797: Restore a database when either db_creted.changed is true or when `atl_force_db_restore` variable is set to true * DCD-797: set default filter to return a default value when the argument is a python false-y value. Update readme to reflect name of extra var env variable Approved-by: Ben Partridge Approved-by: Steve Smith --- README.md | 4 ++-- roles/restore_backups/tasks/main.yml | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 29605c6..e33ea18 100644 --- a/README.md +++ b/README.md @@ -47,11 +47,11 @@ directly, the command for this would look like the following: -i inv/aws_node_local aws_jira_dc_node.yml You can also do this on a CloudFormation template where the stack details are in `/etc/atl`. -On such templates, the variable `ATL_ANSIBLE_EXTRA_PARAMS` is added to the +On such templates, the variable `ATL_DEPLOYMENT_REPOSITORY_CUSTOM_PARAMS` is added to the `ansible-playbook` parameters in `bin/ansible-with-alt-env`. In this case you need to set it to: + ATL_DEPLOYMENT_REPOSITORY_CUSTOM_PARAMS="-e atl_product_download_url=http://s3.amazon.com/atlassian/jira-9.0.0-PRE-TEST.tar.gz -e atl_use_system_jdk=true -e atl_download_format=tarball" - ATL_ANSIBLE_EXTRA_PARAMS="-e atl_product_download_url=http://s3.amazon.com/atlassian/jira-9.0.0-PRE-TEST.tar.gz -e atl_use_system_jdk=true -e atl_download_format=tarball" To set the same parameters in the AWS Quick Starts for [Jira Data Center](https://aws.amazon.com/quickstart/architecture/jira/), diff --git a/roles/restore_backups/tasks/main.yml b/roles/restore_backups/tasks/main.yml index f4e7833..f8162e0 100644 --- a/roles/restore_backups/tasks/main.yml +++ b/roles/restore_backups/tasks/main.yml @@ -85,6 +85,8 @@ include_tasks: "{{ ansible_distribution|lower }}.yml" + # Restores the application database. If a var with name `atl_force_db_restore` is set to true, the database will be restored even when the database has not been created in the same playbook run. + # This is done to accommodate running the restore role independent of the database_init role. - name: Restore application database postgresql_db: login_host: "{{ atl_db_host }}" @@ -106,8 +108,8 @@ failed_when: - result.rc != 0 - '"COMMENT ON EXTENSION" not in result.msg' - when: db_created.changed and atl_backup_db_dest is defined - + # default('false', true) filter makes the default filter return the specified default value for python False-y values (like an empty string) + when: atl_backup_db_dest is defined and (db_created.changed or (atl_force_db_restore | default('false', true) | bool)) - name: Restore shared home include_tasks: "home_restore.yml"