diff --git a/README.md b/README.md index 9758dd0..1ec9889 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,8 @@ The single point of configuration in this script is a `group_vars/all.yml` file. - `aws_access_key` and `aws_secret_key` is a credentials pair that provides access to AWS for the deployer; - `backend` variable defines whether deployer should keep state files remote or locally. Set `backend` variable to `true` if you want to save state file to the remote S3 bucket; -- `upload_debug_info_to_s3` - set to `true` if you want to upload debug info such as config `all.yml` file and full log output to the S3 bucket automatically after the deployment. Will not work if `backend` is set to false; +- `upload_config_to_s3` - set to `true` if you want to upload config `all.yml` file to the S3 bucket automatically after the deployment. Will not work if `backend` is set to false; +- `upload_debug_info_to_s3` - set to `true` if you want to upload full log output to the S3 bucket automatically after the deployment. Will not work if `backend` is set to false. *IMPORTANT*: Locally logs are stored at `log.txt` which is not cleaned automatically. Please, do not forget to clean it manually or using the `clean.yml` playbook; - `bucket` represents a globally unique name of the bucket where your configs and state will be stored. It will be created automatically during the deployment; - `prefix` - is a unique tag to use for provisioned resources (5 alphanumeric chars or less); - `chains` - maps chains to the URLs of HTTP RPC endpoints, an ordinary blockchain node can be used; diff --git a/attach_existing_rds.yml b/attach_existing_rds.yml index 8605f37..2675396 100644 --- a/attach_existing_rds.yml +++ b/attach_existing_rds.yml @@ -1,13 +1,25 @@ - name: Attach existing RDS instance hosts: localhost - roles: - - { role: check } - - { role: s3, when: "backend|bool == true" } - - { role: dynamodb, when: "backend|bool == true" } - - { role: attach_existing_rds } - - { role: s3_config, when: "backend|bool == true and upload_config_to_s3|bool == true" } - - { role: s3_debug, when: "backend|bool == true and upload_debug_info_to_s3|bool == true" } + tasks: + - block: + - include_role: + name: check + - include_role: + name: "{{ item }}" + with_items: + - s3 + - dynamodb + when: backend|bool == true + - include_role: + name: attach_existing_rds + always: + - include_role: + name: s3_config + when: backend|bool == true and upload_config_to_s3|bool == true + - include_role: + name: s3_debug + when: backend|bool == true and upload_debug_info_to_s3|bool == true vars_prompt: - name: "confirmation" - prompt: "Are you sure you want to attach the existing RDS? If backend variable is set to True, this action includes creating the S3 and DynamoDB table for storing Terraform state files." + prompt: "Are you sure you want to attach the existing RDS? If backend variable is set to True, this action also includes creating the S3 and DynamoDB table for storing Terraform state files." default: False diff --git a/deploy_infra.yml b/deploy_infra.yml index 1820e92..5d64e04 100644 --- a/deploy_infra.yml +++ b/deploy_infra.yml @@ -1,9 +1,21 @@ - name: Prepare infrastructure hosts: localhost - roles: - - { role: check } - - { role: s3, when: "backend|bool == true" } - - { role: dynamodb, when: "backend|bool == true" } - - { role: main_infra } - - { role: s3_config, when: "backend|bool == true and upload_config_to_s3|bool == true" } - - { role: s3_debug, when: "backend|bool == true and upload_debug_info_to_s3|bool == true" } + tasks: + - block: + - include_role: + name: check + - include_role: + name: "{{ item }}" + with_items: + - s3 + - dynamodb + when: backend|bool == true + - include_role: + name: main_infra + always: + - include_role: + name: s3_config + when: backend|bool == true and upload_config_to_s3|bool == true + - include_role: + name: s3_debug + when: backend|bool == true and upload_debug_info_to_s3|bool == true diff --git a/deploy_software.yml b/deploy_software.yml index 747a840..21c38ce 100644 --- a/deploy_software.yml +++ b/deploy_software.yml @@ -1,17 +1,21 @@ - name: Deploy BlockScout hosts: localhost tasks: - - name: Use role in loop - include_role: - name: main_software - loop: "{{ chain_custom_environment.keys() }}" - loop_control: - loop_var: chain - index_var: index - -- name: Save debug files - hosts: localhost - roles: - - { role: s3, when: "backend|bool == true and (upload_debug_info_to_s3|bool == true or upload_config_to_s3|bool ==true)" } - - { role: s3_config, when: "backend|bool == true and upload_config_to_s3|bool == true" } - - { role: s3_debug, when: "backend|bool == true and upload_debug_info_to_s3|bool == true" } + - block: + - name: Use role in loop + include_role: + name: main_software + loop: "{{ chain_custom_environment.keys() }}" + loop_control: + loop_var: chain + index_var: index + always: + - include_role: + name: s3 + when: backend|bool == true and (upload_debug_info_to_s3|bool == true or upload_config_to_s3|bool ==true) + - include_role: + name: s3_config + when: backend|bool == true and upload_config_to_s3|bool == true + - include_role: + name: s3_debug + when: backend|bool == true and upload_debug_info_to_s3|bool == true diff --git a/roles/check/tasks/main.yml b/roles/check/tasks/main.yml index 30205d2..2792753 100644 --- a/roles/check/tasks/main.yml +++ b/roles/check/tasks/main.yml @@ -1,8 +1,3 @@ -- name: Clean log file - file: - state: absent - path: "log.txt" - - name: Check prefix fail: msg: "The prefix '{{ prefix }}' is invalid. It must consist only of the lowercase characters a-z and digits 0-9, and must be between 3 and 5 characters long."