Skip to content

Commit cb14a7a

Browse files
author
Kenny Woodson
committed
Do not remove files for bootstrap if resolv or dns.
1 parent 457e0f8 commit cb14a7a

File tree

12 files changed

+174
-23
lines changed

12 files changed

+174
-23
lines changed

playbooks/aws/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ The current expected work flow should be to provide an AMI with access to Opensh
4343

4444
```yaml
4545
---
46-
# when creating an AMI set this to True
47-
# when installing a cluster set this to False
48-
openshift_node_bootstrap: True
49-
5046
# specify a clusterid
5147
# openshift_aws_clusterid: default
5248

playbooks/aws/openshift-cluster/build_ami.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@
5151
set_fact:
5252
ansible_ssh_user: root
5353

54+
- hosts: nodes
55+
gather_facts: no
56+
tasks:
57+
- name: set openshift_node_bootstrap to True for ami building
58+
set_fact:
59+
openshift_node_bootstrap: True
60+
5461
- name: normalize groups
5562
include: ../../byo/openshift-cluster/initialize_groups.yml
5663

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:

roles/openshift_aws/defaults/main.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ openshift_aws_node_group_config_node_volumes:
9090
delete_on_termination: True
9191

9292
openshift_aws_node_group_config_tags: "{{ openshift_aws_clusterid | build_instance_tags(openshift_aws_kubernetes_cluster_status) }}"
93+
openshift_aws_node_group_termination_policy: Default
94+
openshift_aws_node_group_replace_instances: []
95+
openshift_aws_node_group_replace_all_instances: False
96+
openshift_aws_node_group_config_extra_labels: {}
9397

9498
openshift_aws_node_group_config:
9599
tags: "{{ openshift_aws_node_group_config_tags }}"
@@ -106,7 +110,11 @@ openshift_aws_node_group_config:
106110
tags:
107111
host-type: master
108112
sub-host-type: default
113+
labels:
114+
type: master
109115
wait_for_instances: True
116+
termination_policy: "{{ openshift_aws_node_group_termination_policy }}"
117+
replace_all_instances: "{{ openshift_aws_node_group_replace_all_instances }}"
110118
compute:
111119
instance_type: m4.xlarge
112120
ami: "{{ openshift_aws_ami }}"
@@ -120,6 +128,10 @@ openshift_aws_node_group_config:
120128
tags:
121129
host-type: node
122130
sub-host-type: compute
131+
labels:
132+
type: compute
133+
termination_policy: "{{ openshift_aws_node_group_termination_policy }}"
134+
replace_all_instances: "{{ openshift_aws_node_group_replace_all_instances }}"
123135
infra:
124136
instance_type: m4.xlarge
125137
ami: "{{ openshift_aws_ami }}"
@@ -133,6 +145,10 @@ openshift_aws_node_group_config:
133145
tags:
134146
host-type: node
135147
sub-host-type: infra
148+
labels:
149+
type: infra
150+
termination_policy: "{{ openshift_aws_node_group_termination_policy }}"
151+
replace_all_instances: "{{ openshift_aws_node_group_replace_all_instances }}"
136152

137153
openshift_aws_elb_security_groups:
138154
- "{{ openshift_aws_clusterid }}"
@@ -207,3 +223,27 @@ openshift_aws_vpc:
207223
az: "us-east-1e"
208224
- cidr: 172.31.16.0/20
209225
az: "us-east-1a"
226+
227+
openshift_aws_node_config_location: /etc/origin/node/node-config.yaml
228+
openshift_aws_node_config_changes:
229+
- key: imageConfig.format
230+
value: "{% raw %}registry.ops.openshift.com/openshift3/ose-${component}:${version}{% endraw %}"
231+
- key: kubeletArguments.cloud-config
232+
value:
233+
- /etc/origin/cloudprovider/aws.conf
234+
- key: kubeletArguments.cloud-provider
235+
value:
236+
- aws
237+
- key: kubeletArguments.kube-reserved
238+
value:
239+
- cpu=500m,memory=512M
240+
- key: kubeletArguments.system-reserved
241+
value:
242+
- cpu=500m,memory=512M
243+
- key: kubeletArguments.enable-controller-attach-detach
244+
value:
245+
- 'true'
246+
- key: networkConfig.mtu
247+
value: 8951
248+
- key: networkConfig.networkPluginName
249+
value: redhat/openshift-ovs-subnet

roles/openshift_aws/tasks/build_ami.yml

Lines changed: 4 additions & 0 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
- when: openshift_aws_create_vpc | bool
37
name: create a vpc
48
include: vpc.yml

roles/openshift_aws/tasks/launch_config.yml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,7 @@
2222
image_id: "{{ openshift_aws_ami }}"
2323
instance_type: "{{ openshift_aws_node_group_config[openshift_aws_node_group_type].instance_type }}"
2424
security_groups: "{{ ec2sgs.security_groups | map(attribute='group_id')| list }}"
25-
user_data: |-
26-
#cloud-config
27-
{% if openshift_aws_node_group_type != 'master' %}
28-
write_files:
29-
- path: /root/csr_kubeconfig
30-
owner: root:root
31-
permissions: '0640'
32-
content: {{ openshift_aws_launch_config_bootstrap_token | default('') | to_yaml }}
33-
- path: /root/openshift_settings
34-
owner: root:root
35-
permissions: '0640'
36-
content:
37-
openshift_type: "{{ openshift_aws_node_group_type }}"
38-
runcmd:
39-
- [ systemctl, enable, atomic-openshift-node]
40-
- [ systemctl, start, atomic-openshift-node]
41-
{% endif %}
25+
user_data: "{{ lookup('template', 'user_data.j2') }}"
4226
key_name: "{{ openshift_aws_ssh_key_name }}"
4327
ebs_optimized: False
4428
volumes: "{{ openshift_aws_node_group_config[openshift_aws_node_group_type].volumes }}"

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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#cloud-config
2+
{% if openshift_aws_node_group_type != 'master' %}
3+
write_files:
4+
- path: /root/csr_kubeconfig
5+
owner: root:root
6+
permissions: '0640'
7+
content: {{ openshift_aws_launch_config_bootstrap_token | default('') | to_yaml }}
8+
- path: /root/openshift_settings.yaml
9+
owner: root:root
10+
permissions: '0640'
11+
content:
12+
openshift_group_type: {{ openshift_aws_node_group_type }}
13+
openshift_group_type_labels: {{ openshift_aws_node_group_config_extra_labels | combine(openshift_aws_node_group_config[openshift_aws_node_group_type].labels) }}
14+
openshift_node_config_location: {{ openshift_aws_node_config_location }}
15+
openshift_node_config_changes: {{ openshift_aws_node_config_changes | to_json }}
16+
runcmd:
17+
- [ ansible-playbook, /root/bootstrap.yml]
18+
- [ systemctl, enable, atomic-openshift-node]
19+
- [ systemctl, start, atomic-openshift-node]
20+
{% endif %}

roles/openshift_node/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ openshift_node_ami_prep_packages:
1111
- "{{ openshift_service_type }}-node"
1212
- "{{ openshift_service_type }}-docker-excluder"
1313
- "{{ openshift_service_type }}-sdn-ovs"
14+
- openshift-ansible-roles
1415
- ansible
1516
- openvswitch
1617
- docker
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/ansible-playbook
2+
---
3+
- hosts: localhost
4+
gather_facts: yes
5+
vars:
6+
origin_dns:
7+
file: /etc/dnsmasq.d/origin-dns.conf
8+
lines:
9+
- regex: ^listen-address
10+
state: absent
11+
- regex: "^except-interface"
12+
line: except-interface=lo
13+
after: EOF
14+
state: present
15+
node_dns:
16+
file: /etc/dnsmasq.d/node-dnsmasq.conf
17+
lines:
18+
- regex: "^server=/in-addr.arpa/127.0.0.1$"
19+
line: server=/in-addr.arpa/127.0.0.1
20+
- regex: "^server=/cluster.local/127.0.0.1$"
21+
line: server=/cluster.local/127.0.0.1
22+
23+
tasks:
24+
- include_vars: openshift_settings.yaml
25+
26+
- name: include yedit
27+
include_role:
28+
name: /usr/share/ansible/openshift-ansible/roles/lib_utils
29+
30+
- name: make yedit calls for node_config_changes
31+
yedit:
32+
src: "{{ openshift_node_config_location }}"
33+
edits: "{{ openshift_node_config_changes }}"
34+
backup: True
35+
36+
- name: fetch node labels
37+
yedit:
38+
src: "{{ openshift_node_config_location }}"
39+
state: list
40+
key: kubeletArguments.node-labels
41+
register: yedout
42+
43+
- debug: var=yedout
44+
45+
- name: make yedit calls for node labels
46+
yedit:
47+
src: "{{ openshift_node_config_location }}"
48+
key: kubeletArguments.node-labels
49+
value: []
50+
backup: True
51+
when: yedout.result == None
52+
53+
- name: make yedit calls for node labels
54+
yedit:
55+
src: "{{ openshift_node_config_location }}"
56+
key: kubeletArguments.node-labels
57+
value: "{{ item.key | string }}={{ item.value | string }}"
58+
update: "{{ True if yedout.result != None else omit }}"
59+
append: "{{ True if yedout.result == None else omit }}"
60+
curr_value: "{{ item.key | string }}={{ item.value | string }}"
61+
backup: True
62+
with_dict: "{{ openshift_group_type_labels }}"
63+
64+
- name: set the data for node_dns
65+
lineinfile:
66+
create: yes
67+
insertafter: EOF
68+
path: "{{ node_dns.file }}"
69+
regexp: "{{ item.regex }}"
70+
line: "{{ item.line | default(omit) }}"
71+
with_items: "{{ node_dns.lines }}"
72+
73+
- name: set the data for origin_dns
74+
lineinfile:
75+
create: yes
76+
state: "{{ item.state | default('present') }}"
77+
insertafter: "{{ item.after | default(omit) }}"
78+
path: "{{ origin_dns.file }}"
79+
regexp: "{{ item.regex }}"
80+
line: "{{ item.line | default(omit)}}"
81+
with_items: "{{ origin_dns.lines }}"
82+

roles/openshift_node/tasks/bootstrap.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
path: /etc/origin/.config_managed
4343
register: rpmgenerated_config
4444

45+
- name: laydown the bootstrap.yml file for on boot configuration
46+
copy:
47+
src: bootstrap.yml
48+
dest: /root/bootstrap.yml
49+
4550
- when: rpmgenerated_config.stat.exists
4651
block:
4752
- name: Remove RPM generated config files if present
@@ -50,6 +55,7 @@
5055
state: absent
5156
with_items:
5257
- master
58+
- .config_managed
5359

5460
# with_fileglob doesn't work correctly due to a few issues.
5561
# Could change this to fileglob when it gets fixed.
@@ -62,5 +68,7 @@
6268
file:
6369
path: "{{ item.path }}"
6470
state: absent
65-
when: "'resolv.conf' not in item.path or 'node-dnsmasq.conf' not in item.path"
71+
when:
72+
- "'resolv.conf' not in item.path"
73+
- "'node-dnsmasq.conf' not in item.path"
6674
with_items: "{{ find_results.files }}"

0 commit comments

Comments
 (0)