Skip to content

Commit 63b77fb

Browse files
authored
Merge pull request #5361 from kwoodson/fix_bootstrap_files
Provisioning updates.
2 parents 5ff1e1b + 47d2e20 commit 63b77fb

File tree

24 files changed

+429
-93
lines changed

24 files changed

+429
-93
lines changed

playbooks/aws/openshift-cluster/accept.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@
4242
until: "'instances' in instancesout and instancesout.instances|length > 0"
4343

4444
- debug:
45-
msg: "{{ instancesout.instances|map(attribute='private_dns_name') | list | regex_replace('.ec2.internal') }}"
45+
msg: "{{ instancesout.instances|map(attribute='private_dns_name') | list }}"
4646

4747
- name: approve nodes
4848
oc_adm_csr:
4949
#approve_all: True
50-
nodes: "{{ instancesout.instances|map(attribute='private_dns_name') | list | regex_replace('.ec2.internal') }}"
51-
timeout: 0
50+
nodes: "{{ instancesout.instances|map(attribute='private_dns_name') | list }}"
51+
timeout: 60
5252
register: nodeout
5353
delegate_to: "{{ mastersout.instances[0].public_ip_address }}"

playbooks/aws/openshift-cluster/build_ami.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- name: set the user to perform installation
2828
set_fact:
2929
ansible_ssh_user: "{{ openshift_aws_build_ami_ssh_user | default('root') }}"
30+
openshift_node_bootstrap: True
3031

3132
# This is the part that installs all of the software and configs for the instance
3233
# to become a node.

playbooks/common/openshift-cluster/evaluate_groups.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
when:
5252
- g_etcd_hosts | default([]) | length not in [3,1]
5353
- not openshift_master_unsupported_embedded_etcd | default(False)
54-
- not openshift_node_bootstrap | default(False)
54+
- not (openshift_node_bootstrap | default(False))
5555

5656
- name: Evaluate oo_all_hosts
5757
add_host:

playbooks/common/openshift-node/image_prep.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
- name: normalize groups
33
include: ../../byo/openshift-cluster/initialize_groups.yml
44

5-
- name: run the std_include
5+
- name: evaluate the groups
66
include: ../openshift-cluster/evaluate_groups.yml
77

8-
- name: run the std_include
8+
- name: initialize the facts
99
include: ../openshift-cluster/initialize_facts.yml
1010

11-
- name: run the std_include
11+
- name: initialize the repositories
1212
include: ../openshift-cluster/initialize_openshift_repos.yml
1313

1414
- name: run node config setup

roles/lib_openshift/library/oc_adm_csr.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,11 +1478,23 @@ def action_needed(csr, action):
14781478

14791479
return False
14801480

1481+
def get_csr_request(self, request):
1482+
'''base64 decode the request object and call openssl to determine the
1483+
subject and specifically the CN: from the request
1484+
1485+
Output:
1486+
(0, '...
1487+
Subject: O=system:nodes, CN=system:node:ip-172-31-54-54.ec2.internal
1488+
...')
1489+
'''
1490+
import base64
1491+
return self._run(['openssl', 'req', '-noout', '-text'], base64.b64decode(request))[1]
1492+
14811493
def match_node(self, csr):
14821494
'''match an inc csr to a node in self.nodes'''
14831495
for node in self.nodes:
1484-
# we have a match
1485-
if node['name'] in csr['metadata']['name']:
1496+
# we need to match based upon the csr's request certificate's CN
1497+
if node['name'] in self.get_csr_request(csr['spec']['request']):
14861498
node['csrs'][csr['metadata']['name']] = csr
14871499

14881500
# check that the username is the node and type is 'Approved'

roles/lib_openshift/src/class/oc_adm_csr.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,23 @@ def action_needed(csr, action):
6666

6767
return False
6868

69+
def get_csr_request(self, request):
70+
'''base64 decode the request object and call openssl to determine the
71+
subject and specifically the CN: from the request
72+
73+
Output:
74+
(0, '...
75+
Subject: O=system:nodes, CN=system:node:ip-172-31-54-54.ec2.internal
76+
...')
77+
'''
78+
import base64
79+
return self._run(['openssl', 'req', '-noout', '-text'], base64.b64decode(request))[1]
80+
6981
def match_node(self, csr):
7082
'''match an inc csr to a node in self.nodes'''
7183
for node in self.nodes:
72-
# we have a match
73-
if node['name'] in csr['metadata']['name']:
84+
# we need to match based upon the csr's request certificate's CN
85+
if node['name'] in self.get_csr_request(csr['spec']['request']):
7486
node['csrs'][csr['metadata']['name']] = csr
7587

7688
# check that the username is the node and type is 'Approved'

roles/openshift_aws/defaults/main.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ openshift_aws_create_iam_cert: True
44
openshift_aws_create_security_groups: True
55
openshift_aws_create_launch_config: True
66
openshift_aws_create_scale_group: True
7-
openshift_aws_kubernetes_cluster_status: owned # or shared
87
openshift_aws_node_group_type: master
98

109
openshift_aws_wait_for_ssh: True
@@ -13,6 +12,7 @@ openshift_aws_clusterid: default
1312
openshift_aws_region: us-east-1
1413
openshift_aws_vpc_name: "{{ openshift_aws_clusterid }}"
1514
openshift_aws_build_ami_group: "{{ openshift_aws_clusterid }}"
15+
openshift_aws_kubernetes_cluster_status: "{{ openshift_aws_clusterid }}"
1616

1717
openshift_aws_iam_cert_name: "{{ openshift_aws_clusterid }}-master-external"
1818
openshift_aws_iam_cert_path: ''
@@ -89,6 +89,10 @@ openshift_aws_node_group_config_node_volumes:
8989
delete_on_termination: True
9090

9191
openshift_aws_node_group_config_tags: "{{ openshift_aws_clusterid | build_instance_tags(openshift_aws_kubernetes_cluster_status) }}"
92+
openshift_aws_node_group_termination_policy: Default
93+
openshift_aws_node_group_replace_instances: []
94+
openshift_aws_node_group_replace_all_instances: False
95+
openshift_aws_node_group_config_extra_labels: {}
9296

9397
openshift_aws_node_group_config:
9498
tags: "{{ openshift_aws_node_group_config_tags }}"
@@ -105,7 +109,11 @@ openshift_aws_node_group_config:
105109
tags:
106110
host-type: master
107111
sub-host-type: default
112+
labels:
113+
type: master
108114
wait_for_instances: True
115+
termination_policy: "{{ openshift_aws_node_group_termination_policy }}"
116+
replace_all_instances: "{{ openshift_aws_node_group_replace_all_instances }}"
109117
compute:
110118
instance_type: m4.xlarge
111119
ami: "{{ openshift_aws_ami }}"
@@ -119,6 +127,10 @@ openshift_aws_node_group_config:
119127
tags:
120128
host-type: node
121129
sub-host-type: compute
130+
labels:
131+
type: compute
132+
termination_policy: "{{ openshift_aws_node_group_termination_policy }}"
133+
replace_all_instances: "{{ openshift_aws_node_group_replace_all_instances }}"
122134
infra:
123135
instance_type: m4.xlarge
124136
ami: "{{ openshift_aws_ami }}"
@@ -132,6 +144,10 @@ openshift_aws_node_group_config:
132144
tags:
133145
host-type: node
134146
sub-host-type: infra
147+
labels:
148+
type: infra
149+
termination_policy: "{{ openshift_aws_node_group_termination_policy }}"
150+
replace_all_instances: "{{ openshift_aws_node_group_replace_all_instances }}"
135151

136152
openshift_aws_elb_security_groups:
137153
- "{{ openshift_aws_clusterid }}"
@@ -211,3 +227,7 @@ openshift_aws_vpc:
211227
az: "us-east-1e"
212228
- cidr: 172.31.16.0/20
213229
az: "us-east-1a"
230+
231+
openshift_aws_node_run_bootstrap_startup: True
232+
openshift_aws_node_user_data: ''
233+
openshift_aws_node_config_namespace: openshift-node

roles/openshift_aws/tasks/launch_config.yml

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
when:
55
- openshift_aws_ami is undefined
66

7+
- fail:
8+
msg: "Ensure that openshift_deployment_type is defined."
9+
when:
10+
- openshift_deployment_type is undefined
11+
712
- name: query vpc
813
ec2_vpc_net_facts:
914
region: "{{ openshift_aws_region }}"
@@ -27,23 +32,7 @@
2732
image_id: "{{ openshift_aws_ami }}"
2833
instance_type: "{{ openshift_aws_node_group_config[openshift_aws_node_group_type].instance_type }}"
2934
security_groups: "{{ openshift_aws_launch_config_security_group_id | default(ec2sgs.security_groups | map(attribute='group_id')| list) }}"
30-
user_data: |-
31-
#cloud-config
32-
{% if openshift_aws_node_group_type != 'master' %}
33-
write_files:
34-
- path: /root/csr_kubeconfig
35-
owner: root:root
36-
permissions: '0640'
37-
content: {{ openshift_aws_launch_config_bootstrap_token | default('') | to_yaml }}
38-
- path: /root/openshift_settings
39-
owner: root:root
40-
permissions: '0640'
41-
content:
42-
openshift_type: "{{ openshift_aws_node_group_type }}"
43-
runcmd:
44-
- [ systemctl, enable, atomic-openshift-node]
45-
- [ systemctl, start, atomic-openshift-node]
46-
{% endif %}
35+
user_data: "{{ lookup('template', 'user_data.j2') }}"
4736
key_name: "{{ openshift_aws_ssh_key_name }}"
4837
ebs_optimized: False
4938
volumes: "{{ openshift_aws_node_group_config[openshift_aws_node_group_type].volumes }}"

roles/openshift_aws/tasks/provision_instance.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
---
2+
- name: set openshift_node_bootstrap to True when building AMI
3+
set_fact:
4+
openshift_node_bootstrap: True
5+
26
- name: query vpc
37
ec2_vpc_net_facts:
48
region: "{{ openshift_aws_region }}"
@@ -53,10 +57,6 @@
5357
timeout: 300
5458
search_regex: OpenSSH
5559

56-
- name: Pause 10 seconds to ensure ssh actually accepts logins
57-
pause:
58-
seconds: 20
59-
6060
- name: add host to nodes
6161
add_host:
6262
groups: nodes

roles/openshift_aws/tasks/scale_group.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,7 @@
2828
load_balancers: "{{ openshift_aws_node_group_config[openshift_aws_node_group_type].elbs if 'elbs' in openshift_aws_node_group_config[openshift_aws_node_group_type] else omit }}"
2929
wait_for_instances: "{{ openshift_aws_node_group_config[openshift_aws_node_group_type].wait_for_instances | default(False)}}"
3030
vpc_zone_identifier: "{{ subnetout.subnets[0].id }}"
31+
replace_instances: "{{ openshift_aws_node_group_replace_instances if openshift_aws_node_group_replace_instances != [] else omit }}"
32+
replace_all_instances: "{{ omit if openshift_aws_node_group_replace_instances != [] else (openshift_aws_node_group_config[openshift_aws_node_group_type].replace_all_instances | default(omit)) }}"
3133
tags:
3234
- "{{ openshift_aws_node_group_config.tags | combine(openshift_aws_node_group_config[openshift_aws_node_group_type].tags) }}"

roles/openshift_aws/tasks/seal_ami.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
---
2+
- name: Remove any ansible facts created during AMI creation
3+
file:
4+
path: "/etc/ansible/facts.d/{{ item }}"
5+
state: absent
6+
with_items:
7+
- openshift.fact
8+
29
- name: fetch newly created instances
310
ec2_remote_facts:
411
region: "{{ openshift_aws_region }}"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{% if openshift_aws_node_user_data is defined and openshift_aws_node_user_data != '' %}
2+
{{ openshift_aws_node_user_data }}
3+
{% else %}
4+
#cloud-config
5+
write_files:
6+
- path: /root/openshift_bootstrap/openshift_settings.yaml
7+
owner: 'root:root'
8+
permissions: '0640'
9+
content: |
10+
openshift_group_type: {{ openshift_aws_node_group_type }}
11+
{% if openshift_aws_node_group_type != 'master' %}
12+
- path: /etc/origin/node/csr_kubeconfig
13+
owner: 'root:root'
14+
permissions: '0640'
15+
encoding: b64
16+
content: {{ openshift_aws_launch_config_bootstrap_token | b64encode }}
17+
{% endif %}
18+
runcmd:
19+
{% if openshift_aws_node_run_bootstrap_startup %}
20+
- [ ansible-playbook, /root/openshift_bootstrap/bootstrap.yml]
21+
{% endif %}
22+
{% if openshift_aws_node_group_type != 'master' %}
23+
- [ systemctl, enable, {% if openshift_deployment_type == 'openshift-enterprise' %}atomic-openshift{% else %}origin{% endif %}-node]
24+
- [ systemctl, start, {% if openshift_deployment_type == 'openshift-enterprise' %}atomic-openshift{% else %}origin{% endif %}-node]
25+
{% endif %}
26+
{% endif %}

roles/openshift_master/defaults/main.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,88 @@ r_openshift_master_sdn_network_plugin_name: "{{ r_openshift_master_sdn_network_p
5454

5555
openshift_master_image_config_latest_default: "{{ openshift_image_config_latest | default(False) }}"
5656
openshift_master_image_config_latest: "{{ openshift_master_image_config_latest_default }}"
57+
58+
openshift_master_config_dir_default: "{{ (openshift.common.config_base | default('/etc/origin/master')) ~ '/master' }}"
59+
openshift_master_config_dir: "{{ openshift_master_config_dir_default }}"
60+
openshift_master_cloud_provider: "{{ openshift_cloudprovider_kind | default('aws') }}"
61+
62+
openshift_master_node_config_networkconfig_mtu: 1450
63+
64+
openshift_master_node_config_kubeletargs_cpu: 500m
65+
openshift_master_node_config_kubeletargs_mem: 512M
66+
67+
openshift_master_bootstrap_enabled: False
68+
69+
openshift_master_client_binary: "{{ openshift.common.client_binary if openshift is defined else 'oc' }}"
70+
71+
openshift_master_config_imageconfig_format: "{{ oreg_url if oreg_url != '' else 'registry.access.redhat.com/openshift3/ose-${component}:${version}' }}"
72+
73+
# these are for the default settings in a generated node-config.yaml
74+
openshift_master_node_config_default_edits:
75+
- key: nodeName
76+
state: absent
77+
- key: dnsBindAddress
78+
value: 127.0.0.1:53
79+
- key: dnsDomain
80+
value: cluster.local
81+
- key: dnsRecursiveResolvConf
82+
value: /etc/origin/node/resolv.conf
83+
- key: imageConfig.format
84+
value: "{{ openshift_master_config_imageconfig_format }}"
85+
- key: kubeletArguments.cloud-config
86+
value:
87+
- "/etc/origin/cloudprovider/{{ openshift_master_cloud_provider }}.conf"
88+
- key: kubeletArguments.cloud-provider
89+
value:
90+
- "{{ openshift_master_cloud_provider }}"
91+
- key: kubeletArguments.kube-reserved
92+
value:
93+
- "cpu={{ openshift_master_node_config_kubeletargs_cpu }},memory={{ openshift_master_node_config_kubeletargs_mem }}"
94+
- key: kubeletArguments.system-reserved
95+
value:
96+
- "cpu={{ openshift_master_node_config_kubeletargs_cpu }},memory={{ openshift_master_node_config_kubeletargs_mem }}"
97+
- key: enable-controller-attach-detach
98+
value:
99+
- 'true'
100+
- key: networkConfig.mtu
101+
value: 8951
102+
- key: networkConfig.networkPluginName
103+
value: "{{ r_openshift_master_sdn_network_plugin_name }}"
104+
- key: networkPluginName
105+
value: "{{ r_openshift_master_sdn_network_plugin_name }}"
106+
107+
108+
# We support labels for all nodes here
109+
openshift_master_node_config_kubeletargs_default_labels: []
110+
# We do support overrides for node group labels
111+
openshift_master_node_config_kubeletargs_master_labels: []
112+
openshift_master_node_config_kubeletargs_infra_labels: []
113+
openshift_master_node_config_kubeletargs_compute_labels: []
114+
115+
openshift_master_node_config_master:
116+
type: master
117+
edits:
118+
- key: kubeletArguments.node-labels
119+
value: "{{ openshift_master_node_config_kubeletargs_default_labels |
120+
union(openshift_master_node_config_kubeletargs_master_labels) |
121+
union(['type=master']) }}"
122+
openshift_master_node_config_infra:
123+
type: infra
124+
edits:
125+
- key: kubeletArguments.node-labels
126+
value: "{{ openshift_master_node_config_kubeletargs_default_labels |
127+
union(openshift_master_node_config_kubeletargs_infra_labels) |
128+
union(['type=infra']) }}"
129+
openshift_master_node_config_compute:
130+
type: compute
131+
edits:
132+
- key: kubeletArguments.node-labels
133+
value: "{{ openshift_master_node_config_kubeletargs_default_labels |
134+
union(openshift_master_node_config_kubeletargs_compute_labels) |
135+
union(['type=compute']) }}"
136+
137+
openshift_master_node_configs:
138+
- "{{ openshift_master_node_config_infra }}"
139+
- "{{ openshift_master_node_config_compute }}"
140+
141+
openshift_master_bootstrap_namespace: openshift-node

roles/openshift_master/meta/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ galaxy_info:
1313
- cloud
1414
dependencies:
1515
- role: lib_openshift
16+
- role: lib_utils
1617
- role: lib_os_firewall

0 commit comments

Comments
 (0)