File tree Expand file tree Collapse file tree 7 files changed +236
-72
lines changed Expand file tree Collapse file tree 7 files changed +236
-72
lines changed Original file line number Diff line number Diff line change
1
+ - hosts : localhost
2
+ gather_facts : no
3
+ tasks :
4
+ - name : Create EC2 Instances
5
+ ec2 :
6
+ key_name : du-devops
7
+ instance_type : t2.micro
8
+ image : ami-05c1fa8df71875112
9
+ wait : yes
10
+ group : mysecgroup
11
+ count : " {{ count }}"
12
+ vpc_subnet_id : subnet-81211cfb
13
+ assign_public_ip : yes
14
+ region : us-east-2
15
+ register : out
16
+ - name : Name ec2 instances
17
+ ec2_tag :
18
+ resource : " {{item.id}}"
19
+ tags :
20
+ Name : " ju{{item.ami_launch_index}}"
21
+ loop : " {{out.instances}}"
22
+ - name : create in memory Inventory
23
+ add_host :
24
+ hostname : " {{item.public_ip}}"
25
+ groupname : myservers
26
+ ansible_user : ubuntu
27
+ ansible_ssh_private_key_file : /Users/nareshwar/aws/du-devops.pem
28
+ ansible_python_interpreter : /usr/bin/python3
29
+ loop : " {{out.instances}}"
30
+ - name : wait 60 Sec for ssh
31
+ shell : sleep 60
32
+ - name : Create file with Public IPs
33
+ copy :
34
+ content : " {% for host in groups.myservers %}{{ hostvars[host].inventory_hostname }}\n {% endfor %}"
35
+ dest : /tmp/uinventory
36
+ delegate_to : localhost
37
+
38
+ - name : setup user on newly created instances
39
+ hosts : myservers
40
+ gather_facts : no
41
+ become : yes
42
+ tasks :
43
+ - name : install git & python
44
+ package :
45
+ name : " {{ item }}"
46
+ state : present
47
+ loop : ['git']
48
+ - name : clone git repo
49
+ shell : git clone https://github.com/lerndevops/labs.git
50
+ args :
51
+ chdir : /tmp
52
+ - name : create user
53
+ shell : chmod -R 755 /tmp/labs/* ; /tmp/labs/cloud/setup-user.sh
54
+ register : outt
55
+ - name : setup hostname
56
+ shell : echo jnode > /etc/hostname
57
+ - name : reboot instances
58
+ reboot :
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ - hosts : localhost
2
+ gather_facts : no
3
+ tasks :
4
+ - name : Create EC2 Instances
5
+ ec2 :
6
+ key_name : du-devops
7
+ instance_type : t2.small
8
+ image : ami-05c1fa8df71875112
9
+ wait : yes
10
+ group : mysecgroup
11
+ count : " {{ count }}"
12
+ vpc_subnet_id : subnet-81211cfb
13
+ assign_public_ip : yes
14
+ region : us-east-2
15
+ register : out
16
+ - name : Name ec2 instances
17
+ ec2_tag :
18
+ resource : " {{item.id}}"
19
+ tags :
20
+ Name : " mu{{item.ami_launch_index}}"
21
+ loop : " {{out.instances}}"
22
+ - name : create in memory Inventory
23
+ add_host :
24
+ hostname : " {{item.public_ip}}"
25
+ groupname : myservers
26
+ ansible_user : ubuntu
27
+ ansible_ssh_private_key_file : /Users/nareshwar/aws/du-devops.pem
28
+ ansible_python_interpreter : /usr/bin/python3
29
+ loop : " {{out.instances}}"
30
+ - name : wait 60 Sec for ssh
31
+ shell : sleep 60
32
+ - name : Create file with Public IPs
33
+ copy :
34
+ content : " {% for host in groups.myservers %}{{ hostvars[host].inventory_hostname }}\n {% endfor %}"
35
+ dest : /tmp/uinventory
36
+ delegate_to : localhost
37
+
38
+ - name : setup user on newly created instances
39
+ hosts : myservers
40
+ gather_facts : no
41
+ become : yes
42
+ tasks :
43
+ - name : install git & python
44
+ package :
45
+ name : " {{ item }}"
46
+ state : present
47
+ loop : ['git']
48
+ - name : clone git repo
49
+ shell : git clone https://github.com/lerndevops/labs.git
50
+ args :
51
+ chdir : /tmp
52
+ - name : create user
53
+ shell : chmod -R 755 /tmp/labs/* ; /tmp/labs/cloud/setup-user.sh
54
+ register : outt
55
+ - name : setup hostname
56
+ shell : echo master > /etc/hostname
57
+ - name : reboot instances
58
+ reboot :
Original file line number Diff line number Diff line change
1
+ - hosts : localhost
2
+ gather_facts : no
3
+ tasks :
4
+ - name : Create EC2 Instances
5
+ ec2 :
6
+ key_name : du-devops
7
+ instance_type : t2.small
8
+ image : ami-05c1fa8df71875112
9
+ wait : yes
10
+ group : mysecgroup
11
+ count : " {{ count }}"
12
+ vpc_subnet_id : subnet-81211cfb
13
+ assign_public_ip : yes
14
+ region : us-east-2
15
+ register : out
16
+ - name : Name ec2 instances
17
+ ec2_tag :
18
+ resource : " {{item.id}}"
19
+ tags :
20
+ Name : " n1u{{item.ami_launch_index}}"
21
+ loop : " {{out.instances}}"
22
+ - name : create in memory Inventory
23
+ add_host :
24
+ hostname : " {{item.public_ip}}"
25
+ groupname : myservers
26
+ ansible_user : ubuntu
27
+ ansible_ssh_private_key_file : /Users/nareshwar/aws/du-devops.pem
28
+ ansible_python_interpreter : /usr/bin/python3
29
+ loop : " {{out.instances}}"
30
+ - name : wait 60 Sec for ssh
31
+ shell : sleep 60
32
+ - name : Create file with Public IPs
33
+ copy :
34
+ content : " {% for host in groups.myservers %}{{ hostvars[host].inventory_hostname }}\n {% endfor %}"
35
+ dest : /tmp/uinventory
36
+ delegate_to : localhost
37
+
38
+ - name : setup user on newly created instances
39
+ hosts : myservers
40
+ gather_facts : no
41
+ become : yes
42
+ tasks :
43
+ - name : install git & python
44
+ package :
45
+ name : " {{ item }}"
46
+ state : present
47
+ loop : ['git']
48
+ - name : clone git repo
49
+ shell : git clone https://github.com/lerndevops/labs.git
50
+ args :
51
+ chdir : /tmp
52
+ - name : create user
53
+ shell : chmod -R 755 /tmp/labs/* ; /tmp/labs/cloud/setup-user.sh
54
+ register : outt
55
+ - name : setup hostname
56
+ shell : echo node1 > /etc/hostname
57
+ - name : reboot instances
58
+ reboot :
Original file line number Diff line number Diff line change
1
+ - hosts : localhost
2
+ gather_facts : no
3
+ tasks :
4
+ - name : Create EC2 Instances
5
+ ec2 :
6
+ key_name : du-devops
7
+ instance_type : t2.small
8
+ image : ami-05c1fa8df71875112
9
+ wait : yes
10
+ group : mysecgroup
11
+ count : " {{ count }}"
12
+ vpc_subnet_id : subnet-81211cfb
13
+ assign_public_ip : yes
14
+ region : us-east-2
15
+ register : out
16
+ - name : Name ec2 instances
17
+ ec2_tag :
18
+ resource : " {{item.id}}"
19
+ tags :
20
+ Name : " n2u{{item.ami_launch_index}}"
21
+ loop : " {{out.instances}}"
22
+ - name : create in memory Inventory
23
+ add_host :
24
+ hostname : " {{item.public_ip}}"
25
+ groupname : myservers
26
+ ansible_user : ubuntu
27
+ ansible_ssh_private_key_file : /Users/nareshwar/aws/du-devops.pem
28
+ ansible_python_interpreter : /usr/bin/python3
29
+ loop : " {{out.instances}}"
30
+ - name : wait 60 Sec for ssh
31
+ shell : sleep 60
32
+ - name : Create file with Public IPs
33
+ copy :
34
+ content : " {% for host in groups.myservers %}{{ hostvars[host].inventory_hostname }}\n {% endfor %}"
35
+ dest : /tmp/uinventory
36
+ delegate_to : localhost
37
+
38
+ - name : setup user on newly created instances
39
+ hosts : myservers
40
+ gather_facts : no
41
+ become : yes
42
+ tasks :
43
+ - name : install git & python
44
+ package :
45
+ name : " {{ item }}"
46
+ state : present
47
+ loop : ['git']
48
+ - name : clone git repo
49
+ shell : git clone https://github.com/lerndevops/labs.git
50
+ args :
51
+ chdir : /tmp
52
+ - name : create user
53
+ shell : chmod -R 755 /tmp/labs/* ; /tmp/labs/cloud/setup-user.sh
54
+ register : outt
55
+ - name : setup hostname
56
+ shell : echo node2 > /etc/hostname
57
+ - name : reboot instances
58
+ reboot :
Original file line number Diff line number Diff line change 2
2
hosts : localhost
3
3
tasks :
4
4
- ec2 :
5
- key_name : devops
5
+ key_name : du- devops
6
6
instance_type : t2.micro
7
7
image : ami-05c1fa8df71875112
8
8
wait : yes
19
19
hostname : " {{item.public_ip}}"
20
20
groupname : myservers
21
21
ansible_user : ubuntu
22
- ansible_ssh_private_key_file : /aws/devops.pem
22
+ ansible_ssh_private_key_file : /Users/nareshwar/ aws/du- devops.pem
23
23
ansible_python_interpreter : /usr/bin/python3
24
24
with_items : " {{out.instances}}"
25
25
Original file line number Diff line number Diff line change 2
2
hosts : localhost
3
3
tasks :
4
4
- ec2 :
5
- key_name : devops
5
+ key_name : du- devops
6
6
instance_type : t2.small
7
7
image : ami-05c1fa8df71875112
8
8
wait : yes
19
19
hostname : " {{item.public_ip}}"
20
20
groupname : myservers
21
21
ansible_user : ubuntu
22
- ansible_ssh_private_key_file : /aws/devops.pem
22
+ ansible_ssh_private_key_file : /Users/nareshwar/ aws/du- devops.pem
23
23
ansible_python_interpreter : /usr/bin/python3
24
24
with_items : " {{out.instances}}"
25
25
You can’t perform that action at this time.
0 commit comments