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