Skip to content

Commit bc2ac36

Browse files
committed
aws
1 parent ba7c8ab commit bc2ac36

File tree

7 files changed

+236
-72
lines changed

7 files changed

+236
-72
lines changed

cloud/aws/jnode.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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:

cloud/aws/kube.yml

Lines changed: 0 additions & 68 deletions
This file was deleted.

cloud/aws/master.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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:

cloud/aws/node1.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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:

cloud/aws/node2.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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:

cloud/aws/t2-micro-u18.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
hosts: localhost
33
tasks:
44
- ec2:
5-
key_name: devops
5+
key_name: du-devops
66
instance_type: t2.micro
77
image: ami-05c1fa8df71875112
88
wait: yes
@@ -19,7 +19,7 @@
1919
hostname: "{{item.public_ip}}"
2020
groupname: myservers
2121
ansible_user: ubuntu
22-
ansible_ssh_private_key_file: /aws/devops.pem
22+
ansible_ssh_private_key_file: /Users/nareshwar/aws/du-devops.pem
2323
ansible_python_interpreter: /usr/bin/python3
2424
with_items: "{{out.instances}}"
2525

cloud/aws/t2-small-u18.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
hosts: localhost
33
tasks:
44
- ec2:
5-
key_name: devops
5+
key_name: du-devops
66
instance_type: t2.small
77
image: ami-05c1fa8df71875112
88
wait: yes
@@ -19,7 +19,7 @@
1919
hostname: "{{item.public_ip}}"
2020
groupname: myservers
2121
ansible_user: ubuntu
22-
ansible_ssh_private_key_file: /aws/devops.pem
22+
ansible_ssh_private_key_file: /Users/nareshwar/aws/du-devops.pem
2323
ansible_python_interpreter: /usr/bin/python3
2424
with_items: "{{out.instances}}"
2525

0 commit comments

Comments
 (0)