forked from awanmbandi/ansible-tower-automation-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdynamic-version.yaml
52 lines (49 loc) · 1.93 KB
/
dynamic-version.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
- hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Set environment variables
shell: |
export AWS_DEFAULT_REGION=us-east-1
- name: Create EC2
ec2_instance:
region: "{{ deployment_region }}"
key_name: "{{ lookup('aws_ssm', '/JJTech/{{ team }}/keyname', region=AWS_DEFAULT_REGION) }}"
security_group: "{{ lookup('aws_ssm', '/JJTech/{{ team }}/{{ security_group }}', region=AWS_DEFAULT_REGION) }}"
image_id: "{{ lookup('aws_ssm', '/JJTech/{{ team }}/{{ image_id }}', region=AWS_DEFAULT_REGION) }}"
instance_type: "{{ instance_type }}"
vpc_subnet_id: "{{ lookup('aws_ssm', '/JJTech/{{ team }}/{{ vpc_subnet_id }}', region=AWS_DEFAULT_REGION) }}"
instance_role: "{{ lookup('aws_ssm', '/JJTech/{{ team }}/{{ instance_role }}', region=AWS_DEFAULT_REGION) }}"
wait: true
state: "{{ resource_state }}"
volumes:
- device_name: /dev/xvda
ebs:
volume_type: gp2
volume_size: "{{ root_volume_size }}"
delete_on_termination: true
encrypted: true
name: "{{ instance_name }}"
tags:
created_by: "{{ created_by }}"
Owner: "{{ Owner }}"
App_Name: "{{ App_Name }}"
Cost_Center: "{{ Cost_Center }}"
Business_Unit: "{{ Business_Unit }}"
user_data: |
#!/bin/bash
yum update -y
yum install httpd -y
service httpd start
chkconfig httpd on
yum install wget
wget https://github.com/awanmbandi/aws-real-world-projects/blob/web-appplications-src-code/medlife-health-care.zip
yum install unzip -y
unzip medlife-health-care.zip
rm -f /var/www/html/index.html
cp -rf medlife-health-care/* /var/www/html/
# - debug:
# msg: ec2_instance
# - debug:
# msg: "{{ ec2.results[0].instance_ids }}"