This repository has been archived by the owner on Aug 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
resume_gcp.yml
124 lines (109 loc) · 3.56 KB
/
resume_gcp.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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
- hosts: tag_role_jumphost:&tag_user_{{ user }}
gather_facts: false
tasks:
- name: Get ipaddr of jumphost
set_fact:
remote_ip: "{{ inventory_hostname | ipaddr}}"
- name: Get ipaddr of jumphost
set_fact:
remote_ip: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
when: not remote_ip
- name: Store external ip address of jumphost
add_host:
name: "{{ remote_ip }}"
groups: "moadsd_ng_jumphost_instance_public"
- hosts: tag_role_jumphost:tag_role_k8smaster:&tag_user_{{ user }}
gather_facts: false
vars:
tasks:
- name: Include vars
include: site_vars.yml
- name: Start instance
include_role:
name: environment-gcp
vars:
operation: start_instance
instance_name: "{{ hostvars[inventory_hostname]['name'] }}"
- name: Wating for Jumphost and Kubernetes Master to Come up
pause:
minutes: 1
- hosts: tag_role_jumphost:tag_role_k8smaster:tag_role_k8sworker:tag_role_linuxep:tag_role_windowsep:tag_role_openshift:tag_role_dsm:tag_rols_dsmdb:&tag_user_{{ user }}
gather_facts: false
vars:
tasks:
- name: Include vars
include: site_vars.yml
- name: Start instance
include_role:
name: environment-gcp
vars:
operation: start_instance
instance_name: "{{ hostvars[inventory_hostname]['name'] }}"
- hosts: localhost
gather_facts: false
tasks:
- name: Include vars
include: site_vars.yml
- name: Create Jumphost SSH Command
delegate_to: 127.0.0.1
copy:
dest: "./ssh_jumphost"
content: |
ssh ubuntu@{{ jumphost_ip }}
force: yes
owner: ansible
mode: '0700'
- name: Create Master SSH Command
delegate_to: 127.0.0.1
copy:
dest: "./ssh_master"
content: |
ssh -o ProxyCommand="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -W %h:%p {{ jumphost_ip }}" ubuntu@{{ k8smaster_ip }} $1
force: yes
owner: ansible
mode: '0700'
- name: Create Copy Master Command
delegate_to: 127.0.0.1
copy:
dest: "./copy_master"
content: |
scp -o ProxyCommand="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -W %h:%p {{ jumphost_ip }}" $1 ubuntu@{{ k8smaster_ip }}:~/$1
force: yes
owner: ansible
mode: '0700'
- name: Create Fetch Master Command
delegate_to: 127.0.0.1
copy:
dest: "./fetch_master"
content: |
scp -o ProxyCommand="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -W %h:%p {{ jumphost_ip }}" ubuntu@{{ k8smaster_ip }}:~/$1 $1
force: yes
owner: ansible
mode: '0700'
- name: Create Master Watch Pods Command
delegate_to: 127.0.0.1
copy:
dest: "./ssh_master_pods"
content: |
watch './ssh_master "kubectl get pods --all-namespaces"'
force: yes
owner: ansible
mode: '0700'
- name: Create Master Watch Services Command
delegate_to: 127.0.0.1
copy:
dest: "./ssh_master_services"
content: |
watch './ssh_master "kubectl get services --all-namespaces"'
force: yes
owner: ansible
mode: '0700'
- name: Create Master Watch Deployments Command
delegate_to: 127.0.0.1
copy:
dest: "./ssh_master_deployments"
content: |
watch './ssh_master "kubectl get deployments --all-namespaces"'
force: yes
owner: ansible
mode: '0700'