-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathami_worker.yml
128 lines (124 loc) · 3.42 KB
/
ami_worker.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
125
126
127
128
- name: Create Instance
hosts: localhost
gather_facts: false
tags:
- create
tasks:
- name: Include variables
include_vars: all.yml
- name: Create instance
ec2:
region: "{{ vpc_region }}"
vpc_subnet_id: "{{ vpc_kubernetes_subnets[0].id }}"
key_name: "{{ ec2_keypair }}"
instance_type: t2.micro
image: "{{ source_ami }}"
count_tag:
role: ami_build_worker
exact_count: 1
instance_tags:
os: coreos
role: ami_build_worker
wait: true
- name: Refresh Inventory
meta: refresh_inventory
- name: Bootstrap Instance
include: bootstrap_coreos.yml
vars:
hosts: tag_role_ami_build_worker
tags:
- bootstrap
- name: Provision Instance
hosts: tag_role_ami_build_worker
gather_facts: true
become: true
tags:
- provision
tasks:
- name: Include variables
include_vars: all.yml
- name: /opt/bin is present
file:
dest: /opt/bin
state: directory
- name: cfssl binaries are present
get_url:
url: "{{ item.url }}"
dest: /opt/bin/{{ item.name }}
mode: 0755
with_items:
- name: cfssl
url: "https://pkg.cfssl.org/{{cfssl_version}}/cfssl_linux-amd64"
- name: cfssljson
url: "https://pkg.cfssl.org/{{cfssl_version}}/cfssljson_linux-amd64"
- name: /etc/certfetcher directory is present
file:
dest: /etc/certfetcher
state: directory
- name: certfetcher CSRs are present
template:
src: certfetcher/{{ item }}
dest: /etc/certfetcher/{{ item }}
with_items:
- worker-csr.json
- name: certfetcher service is present
template:
src: certfetcher/certfetcher.service
dest: /etc/systemd/system/
# Cloud init
- name: Custom cloud config directory is present
file:
dest: /var/lib/coreos-install
state: directory
- name: Custom cloud config file is present
template:
src: cloud_config/worker
dest: /var/lib/coreos-install/user_data
register: cloud_config_file
- name: Kubernetes directories are present
file:
dest: "{{ item }}"
state: directory
with_items:
- /etc/kubernetes
- /etc/kubernetes/manifests
- /etc/kubernetes/cni
- /etc/kubernetes/cni/net.d
- name: worker kubeconfig is present
template:
src: "{{ item }}"
dest: /etc/kubernetes/
with_items:
- worker-kubeconfig.yml
- name: kubelet service is present
template:
src: kubelet.service
dest: /etc/systemd/system/kubelet.service
- name: Kubernetes worker components are present
template:
src: manifests/{{ item }}
dest: /etc/kubernetes/manifests/{{ item }}
with_items:
- kube-proxy.yml
- name: Create AMI
hosts: localhost
gather_facts: false
tags:
- ami
vars:
output: {}
tasks:
- name: Include variables
include_vars: all.yml
- name: Create AMI
ec2_ami:
region: "{{ vpc_region }}"
instance_id: "{{ hostvars[groups['tag_role_ami_build_worker'][0]]['ec2_id'] }}"
wait: yes
name: "{{ worker_ami_name }}"
register: ami_out
- name: AMI id is set in output
set_fact:
output: "{{ output | combine({'worker_ami_id': ami_out.image_id }) }}"
- name: Variables are printed
debug: var=output