| | |
| | | stack_name: "{{ project_tag }}" |
| | | register: stack_facts |
| | | |
| | | - name: Grab and set stack creation_time |
| | | set_fact: |
| | | stack_creation_time: >- |
| | | {{ stack_facts.ansible_facts.cloudformation[project_tag].stack_description.creation_time }} |
| | | stack_status: >- |
| | | {{ stack_facts.ansible_facts.cloudformation[project_tag].stack_description.stack_status }} |
| | | - when: project_tag in stack_facts.ansible_facts.cloudformation |
| | | block: |
| | | - name: Grab and set stack creation_time |
| | | set_fact: |
| | | stack_creation_time: >- |
| | | {{ stack_facts.ansible_facts.cloudformation[project_tag].stack_description.creation_time }} |
| | | stack_status: >- |
| | | {{ stack_facts.ansible_facts.cloudformation[project_tag].stack_description.stack_status }} |
| | | |
| | | - name: Backup even log for user |
| | | shell: >- |
| | | aws cloudtrail lookup-events |
| | | --lookup-attributes AttributeKey=Username,AttributeValue={{ email | default( owner )}} |
| | | --start-time {{ stack_creation_time }} |
| | | > {{ output_dir }}/{{ env_type }}_{{ guid }}_cloudtrail_event_log.json |
| | | when: email is defined or owner is defined |
| | | - name: Backup even log for user |
| | | shell: >- |
| | | aws cloudtrail lookup-events |
| | | --lookup-attributes AttributeKey=Username,AttributeValue={{ email | default( owner )}} |
| | | --start-time {{ stack_creation_time }} |
| | | > {{ output_dir }}/{{ env_type }}_{{ guid }}_cloudtrail_event_log.json |
| | | when: email is defined or owner is defined |
| | | |
| | | - name: Build inventory |
| | | hosts: localhost |
| | |
| | | msg: "No clientVM present" |
| | | when: >- |
| | | ( 'bastions' not in groups or groups.bastions | length == 0 ) |
| | | and stack_status is defined |
| | | and stack_status == 'CREATE_COMPLETE' |
| | | |
| | | - when: stack_status == 'CREATE_COMPLETE' |
| | | - when: |
| | | - stack_status is defined |
| | | - stack_status == 'CREATE_COMPLETE' |
| | | block: |
| | | - name: Start clientVM instance |
| | | command: "aws ec2 start-instances --instance-ids '{{clientvm_id}}'" |