blob: e380ba1fb17069d2106024ad33bc37bc0920cdf0 (
plain)
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
|
---
- name: Install OpenShift Node package
yum: pkg=openshift-node state=installed
- local_action: command /usr/bin/mktemp -d /tmp/openshift-ansible-XXXXXXX
register: mktemp
- name: Retrieve OpenShift Master credentials
local_action: command /usr/bin/rsync --compress --archive --rsh 'ssh -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' root@{{ openshift_master_public_ips[0] }}:/var/lib/openshift/openshift.local.certificates/admin/ {{ mktemp.stdout }}
ignore_errors: yes
- file: path=/var/lib/openshift/openshift.local.certificates/admin state=directory
- name: Store OpenShift Master credentials
local_action: command /usr/bin/rsync --compress --archive --rsh 'ssh -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' {{ mktemp.stdout }}/ root@{{ openshift_public_ip }}:/var/lib/openshift/openshift.local.certificates/admin
ignore_errors: yes
- local_action: file name={{ mktemp.stdout }} state=absent
- name: Configure OpenShift Node settings
lineinfile:
dest: /etc/sysconfig/openshift-node
regexp: '^OPTIONS='
line: "OPTIONS=\"--master=https://{{ openshift_master_ips[0] }}:8443 --hostname={{ openshift_hostname }} --loglevel={{ openshift_node_debug_level }}\""
notify:
- restart openshift-node
- name: Set default registry url
lineinfile:
dest: /etc/sysconfig/openshift-node
regexp: '^IMAGES='
line: "IMAGES={{ openshift_registry_url }}"
when: openshift_registry_url is defined
notify:
- restart openshift-node
- name: Set OpenShift node facts
include: "{{ role_path | dirname }}/openshift_common/tasks/set_facts.yml"
facts:
- section: node
option: debug_level
value: "{{ openshift_node_debug_level }}"
- section: node
option: public_ip
value: "{{ openshift_public_ip }}"
- section: node
option: externally_managed
value: "{{ openshift_node_manage_service_externally }}"
# fixme: Once the openshift_cluster playbook is published state should be started
# Always bounce service to pick up new credentials
- name: Start and enable openshift-node
service: name=openshift-node enabled=yes state=restarted
when: not openshift_node_manage_service_externally
- name: Disable openshift-node if openshift-node is managed externally
service: name=openshift-node enabled=false
when: openshift_node_manage_service_externally
# TODO: create an os_vars role that has generic env related config and move
# the root kubeconfig setting there, cannot use dependencies to force ordering
# with openshift_node and openshift_master because the way conditional
# dependencies work with current ansible would also exclude the
# openshift_common dependency.
- name: Create .kube directory
file:
path: /root/.kube
state: directory
mode: 0700
- name: Configure root user kubeconfig
command: cp /var/lib/openshift/openshift.local.certificates/admin/.kubeconfig /root/.kube/.kubeconfig
args:
creates: /root/.kube/.kubeconfig
- name: Register node (if not already registered)
openshift_register_node:
name: "{{ openshift_hostname }}"
api_version: v1beta1
cpu: "{{ openshift_node_resources.cpu }}"
memory: "{{ openshift_node_resources.memory }}"
pod_cidr: "{{ openshift_node_resources.cidr }}"
host_ip: "{{ ansible_default_ipv4.address }}"
labels: "{{ openshift_node_labels }}"
annotations: "{{ openshift_node_annotations }}"
# TODO: support customizing other attributes such as: client_config,
# client_cluster, client_context, client_user
# TODO: updated for v1beta3 changes after rebase: hostnames, external_ips,
# internal_ips, external_id
|