-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02-deploy_openshift.yaml
110 lines (100 loc) · 3.23 KB
/
02-deploy_openshift.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
- name: Cria instancia AWS com Openshift All-In-One
hosts: localhost
connection: local
gather_facts: false
vars:
machine_type_node: t2.2xlarge
region: sa-east-1
preemptible: true
tamanho_disco_pequeno: 40
tamanho_disco_grande: 50
tamanho_disco_adicional: 50
master_private_ip: ""
infranode_private_ip: ""
node1_private_ip: ""
image: ami-cb5803a7
tasks:
- name: Carregando variaveis de config.yml
include_vars: config.yml
- name: Cria Instancia AllInOne
ec2:
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
key_name: "{{ aws_key_name }}"
group: "default"
instance_type: "{{ machine_type_node }}"
image: "{{ image }}"
wait: true
region: "{{ region }}"
vpc_subnet_id: "{{ aws_subnet_id }}"
# id: "{{ id_instancia_aws }}"
#
instance_tags:
Name: OpenshiftTechTour2019
assign_public_ip: yes
volumes:
- device_name: /dev/sda1
volume_type: gp2
volume_size: 40
- device_name: /dev/sdb
volume_type: gp2
volume_size: 100
register: ec2
- name: Cria regras de firewall
ec2_group:
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
name: regrasopenshift
description: "Regras para Openshift"
vpc_id: "{{ aws_vpc_network }}"
region: "{{ region }}"
rules:
- proto: tcp
ports:
- 22
- 80
- 443
- 8443
cidr_ip: 0.0.0.0/0
- name: Salva dados no grupo de inventario... usuario
add_host:
hostname: "{{ item.public_ip }}"
groupname: aws_instances_ips
with_items: "{{ ec2.instances }}"
- name: Grava IP da instancia na variavel ip_publico
set_fact:
ip_publico: "{{ item.public_dns_name }}"
with_items: "{{ ec2.instances }}"
- name: Espera por SSH habilitado...
wait_for:
delay: 1
host: "{{ item.public_ip }}"
port: 22
state: started
timeout: 60
with_items: "{{ ec2.instances }}"
- name: "Seta variaveis para proximos passos, incluindo o endereco {{ ip_publico }}"
set_fact:
chave_ssh: "{{ chave_ssh }}"
usuario_ssh_aws: "{{ usuario_ssh_aws }}"
private_ip: "{{ item.private_ip }}"
public_ip: "{{ item.public_ip }}"
public_dns: "{{ item.public_dns_name }}"
machine_type_node: "{{ machine_type_node }}"
with_items: "{{ ec2.instances }}"
- name: "Configura Hosts seguindo roles... {{ hostvars['localhost']['chave_ssh'] }} "
vars:
ansible_ssh_private_key_file: "{{ hostvars['localhost']['chave_ssh'] }}"
public_ip: "{{ hostvars['localhost']['public_ip'] }}"
public_dns: "{{ hostvars['localhost']['public_dns'] }}"
private_ip: "{{ hostvars['localhost']['private_ip'] }}"
provider: "{{ hostvars['localhost']['provider'] }}"
machine_type_node: "{{ hostvars['localhost']['machine_type_node'] }}"
remote_user: "{{ hostvars['localhost']['usuario_ssh_aws'] }}"
hosts: aws_instances_ips
become: yes
gather_facts: false
become_method: sudo
remote_user: "{{ hostvars['localhost']['usuario_ssh_aws'] }}"
roles:
- postinstall-hostpreparation