Make debug info uploader work even if error occured during deployment

This commit is contained in:
a@a.ru 2019-05-15 15:23:27 +03:00
parent 64f4c9f3c1
commit 4cf45a9797
5 changed files with 59 additions and 35 deletions

View File

@ -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; - `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; - `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; - `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); - `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; - `chains` - maps chains to the URLs of HTTP RPC endpoints, an ordinary blockchain node can be used;

View File

@ -1,13 +1,25 @@
- name: Attach existing RDS instance - name: Attach existing RDS instance
hosts: localhost hosts: localhost
roles: tasks:
- { role: check } - block:
- { role: s3, when: "backend|bool == true" } - include_role:
- { role: dynamodb, when: "backend|bool == true" } name: check
- { role: attach_existing_rds } - include_role:
- { role: s3_config, when: "backend|bool == true and upload_config_to_s3|bool == true" } name: "{{ item }}"
- { role: s3_debug, when: "backend|bool == true and upload_debug_info_to_s3|bool == true" } 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: vars_prompt:
- name: "confirmation" - 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 default: False

View File

@ -1,9 +1,21 @@
- name: Prepare infrastructure - name: Prepare infrastructure
hosts: localhost hosts: localhost
roles: tasks:
- { role: check } - block:
- { role: s3, when: "backend|bool == true" } - include_role:
- { role: dynamodb, when: "backend|bool == true" } name: check
- { role: main_infra } - include_role:
- { role: s3_config, when: "backend|bool == true and upload_config_to_s3|bool == true" } name: "{{ item }}"
- { role: s3_debug, when: "backend|bool == true and upload_debug_info_to_s3|bool == true" } 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

View File

@ -1,17 +1,21 @@
- name: Deploy BlockScout - name: Deploy BlockScout
hosts: localhost hosts: localhost
tasks: tasks:
- name: Use role in loop - block:
include_role: - name: Use role in loop
name: main_software include_role:
loop: "{{ chain_custom_environment.keys() }}" name: main_software
loop_control: loop: "{{ chain_custom_environment.keys() }}"
loop_var: chain loop_control:
index_var: index loop_var: chain
index_var: index
- name: Save debug files always:
hosts: localhost - include_role:
roles: name: s3
- { role: s3, when: "backend|bool == true and (upload_debug_info_to_s3|bool == true or upload_config_to_s3|bool ==true)" } 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" } - include_role:
- { role: s3_debug, when: "backend|bool == true and upload_debug_info_to_s3|bool == true" } 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

View File

@ -1,8 +1,3 @@
- name: Clean log file
file:
state: absent
path: "log.txt"
- name: Check prefix - name: Check prefix
fail: 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." 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."