-
Notifications
You must be signed in to change notification settings - Fork 7
/
t2-medium-u18.yml
executable file
·62 lines (58 loc) · 1.62 KB
/
t2-medium-u18.yml
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
53
54
55
56
57
58
59
60
61
62
- name: Create EC2 Instance
hosts: localhost
tasks:
- ec2:
key_name: devops
instance_type: t2.medium
image: ami-05c1fa8df71875112
wait: yes
group: mysecgroup
count: "{{ count }}"
vpc_subnet_id: subnet-81211cfb
assign_public_ip: yes
region: us-east-2
register: out
- debug:
msg: "{{out}}"
- add_host:
hostname: "{{item.public_ip}}"
groupname: myservers
ansible_user: ubuntu
ansible_ssh_private_key_file: /aws/devops.pem
ansible_python_interpreter: /usr/bin/python3
with_items: "{{out.instances}}"
- wait_for:
host: "{{ item.public_ip }}"
port: 22
delay: 30
timeout: 320
state: started
with_items: "{{ out.instances }}"
- copy:
content: "{% for host in groups.myservers %}{{ hostvars[host].inventory_hostname }}\n{% endfor %}"
dest: /tmp/t2-medium-inv
delegate_to: localhost
- name: setup user
hosts: myservers
become: yes
tasks:
- name: install git & python
package:
name: "{{ item }}"
state: present
with_items:
- git
# - python
- name: clone git repo
shell: git clone https://github.com/lerndevops/tse.git
args:
chdir: /tmp
#- name: install kube
#shell: chmod -R 755 /tmp/labs ; /tmp/labs/kube/install/install-k8s-ubuntu.sh
- name: create user
shell: chmod -R 755 /tmp/tse/* ; /tmp/tse/setup-user.sh
register: outt
- debug:
var: outt
# - name: remove git
# command: apt remove -y git