Add backward compatibility

This commit is contained in:
a@a.ru 2019-05-15 14:15:48 +03:00
parent 188aecae44
commit 64f4c9f3c1
8 changed files with 31 additions and 27 deletions

View File

@ -5,7 +5,8 @@
- { role: s3, when: "backend|bool == true" }
- { role: dynamodb, when: "backend|bool == true" }
- { role: attach_existing_rds }
- { role: debug, when: "backend|bool == true and upload_debug_info_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" }
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."

View File

@ -5,4 +5,5 @@
- { role: s3, when: "backend|bool == true" }
- { role: dynamodb, when: "backend|bool == true" }
- { role: main_infra }
- { role: debug, when: "backend|bool == true and upload_debug_info_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" }

View File

@ -12,5 +12,6 @@
- name: Save debug files
hosts: localhost
roles:
- { role: s3, when: "backend|bool == true and upload_debug_info_to_s3|bool == true" }
- { role: debug, when: "backend|bool == true and upload_debug_info_to_s3|bool == true" }
- { 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" }

View File

@ -11,7 +11,8 @@ aws_region: "us-east-1"
## If set to true backend will be uploaded and stored at S3 bucket, so you can easily manage your deployment from any machine. It is highly recommended to do not change this variable
backend: true
## If this is set to true along with backend variable, this config file and the log output will be saved to s3 bucket. Please, make sure to name it as all.yml. Otherwise, no upload will be performed
## If this is set to true along with backend variable, this config file/the log output will be saved to s3 bucket. Please, make sure to name the config file "all.yml". Otherwise, no upload will be performed
upload_config_to_s3: true
upload_debug_info_to_s3: true
## The bucket and dynamodb_table variables will be used only when backend variable is set to true

View File

@ -1,25 +1,3 @@
- name: Check log file exists
stat:
path: "{{ playbook_dir }}/log.txt"
register: stat_result
- name: Upload logs to s3
aws_s3:
bucket: "{{ prefix }}-{{ bucket }}"
object: log.txt
src: "{{ playbook_dir }}/log.txt"
mode: put
profile: "{{ profile }}"
aws_access_key: "{{ access_key }}"
aws_secret_key: "{{ secret_key }}"
region: "{{ region }}"
vars:
access_key: "{{ aws_access_key|default(omit) }}"
secret_key: "{{ aws_secret_key|default(omit) }}"
profile: "{{ aws_profile|default(omit) }}"
region: "{{ aws_region|default(omit) }}"
when: stat_result.stat.exists == true
- name: Check if config file exists
stat:
path: "{{ playbook_dir }}/group_vars/all.yml"

View File

@ -0,0 +1 @@
aws_profile: "default"

View File

@ -0,0 +1,21 @@
- name: Check log file exists
stat:
path: "{{ playbook_dir }}/log.txt"
register: stat_result
- name: Upload logs to s3
aws_s3:
bucket: "{{ prefix }}-{{ bucket }}"
object: log.txt
src: "{{ playbook_dir }}/log.txt"
mode: put
profile: "{{ profile }}"
aws_access_key: "{{ access_key }}"
aws_secret_key: "{{ secret_key }}"
region: "{{ region }}"
vars:
access_key: "{{ aws_access_key|default(omit) }}"
secret_key: "{{ aws_secret_key|default(omit) }}"
profile: "{{ aws_profile|default(omit) }}"
region: "{{ aws_region|default(omit) }}"
when: stat_result.stat.exists == true