fixed checks and modified roles
This commit is contained in:
parent
c54925fc9e
commit
0552d775fe
|
@ -15,3 +15,5 @@
|
|||
# Stack-specific information
|
||||
/PREFIX
|
||||
|
||||
group_vars/*.yml
|
||||
*.retry
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
- 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."
|
||||
when: prefix|length > 2 and prefix|length < 6 and prefix is match("^[a-z0-9]+$")
|
||||
when: prefix|length < 3 or prefix|length > 5 or prefix is not match("^[a-z0-9]+$")
|
||||
|
||||
- name: Check if terraform is installed
|
||||
command: which terraform
|
||||
register: terraform_status
|
||||
changed_when: false
|
||||
|
||||
- name: Terraform check result
|
||||
fail:
|
||||
|
@ -15,15 +16,19 @@
|
|||
- name: Check if python is installed
|
||||
command: which python
|
||||
register: python_status
|
||||
changed_when: false
|
||||
|
||||
- name: Python check result
|
||||
fail:
|
||||
msg: "Python either is not installed or is too old. Please install python version 2.6 or higher"
|
||||
when: python_stats.stdout == "" or ansible_python_version.split(".")[0] * 100 + ansible_python_version.split(".")[1] * 10 + ansible_python_version.split(".")[2] < 260
|
||||
when: python_status.stdout == "" or python_int_version|int < 260
|
||||
vars:
|
||||
python_int_version: "{{ ansible_python_version.split('.')[0]|int * 100 + ansible_python_version.split('.')[1]|int * 10 + ansible_python_version.split('.')[2]|int }}"
|
||||
|
||||
- name: Check if all required modules is installed
|
||||
command: "python -c 'import {{ item }}'"
|
||||
command: "{{ ansible_python_interpreter }} -c 'import {{ item }}'"
|
||||
with_items:
|
||||
- boto
|
||||
- boto3
|
||||
- botocore
|
||||
changed_when: false
|
||||
|
|
Binary file not shown.
|
@ -1,5 +1,6 @@
|
|||
- dynamodb_table:
|
||||
name: "{{ prefix }}-{{ table }}"
|
||||
- name: Create DynamoDB table
|
||||
dynamodb_table:
|
||||
name: "{{ table }}"
|
||||
region: us-east-1
|
||||
hash_key_name: LockID
|
||||
hash_key_type: STRING
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
- name: Create S3 bucket
|
||||
aws_s3:
|
||||
bucket: "{{ bucket }}"
|
||||
mode: create
|
||||
|
||||
- name: Apply tags and versioning to create S3 bucket
|
||||
s3_bucket:
|
||||
name: "{{ prefix }}-{{ bucket }}"
|
||||
name: "{{ bucket }}"
|
||||
versioning: yes
|
||||
tags:
|
||||
origin: terraform
|
||||
|
@ -8,7 +13,7 @@
|
|||
|
||||
- name: Add lifecycle management policy to created S3 bucket
|
||||
s3_lifecycle:
|
||||
name: "{{ prefix }}-{{ bucket }}"
|
||||
name: "{{ bucket }}"
|
||||
rule_id: "expire"
|
||||
noncurrent_version_expiration_days: 90
|
||||
status: enabled
|
||||
|
@ -21,8 +26,8 @@
|
|||
when: upload_config_to_s3|bool == True
|
||||
|
||||
- name: Upload config to S3 bucket
|
||||
s3:
|
||||
bucket: "{{ prefix }}-{{ bucket }}"
|
||||
aws_s3:
|
||||
bucket: "{{ bucket }}"
|
||||
object: localhost.yml
|
||||
src: "{{ playbook_dir }}/group_vars/all.yml"
|
||||
mode: put
|
||||
|
|
Loading…
Reference in New Issue