summaryrefslogtreecommitdiffstats
path: root/roles/openshift_node/tasks/bootstrap.yml
blob: 4abd060c452ed567652a2ccac1ae68ff9ca06b83 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
- name: include package installs
  import_tasks: install_rpms.yml
  when: not (openshift_is_atomic | default(False) | bool)

- name: create the directory for node
  file:
    state: directory
    path: "/etc/systemd/system/{{ openshift_service_type }}-node.service.d"

- name: laydown systemd override
  copy:
    dest: "/etc/systemd/system/{{ openshift_service_type }}-node.service.d/override.conf"
    content: |
      [Unit]
      After=cloud-init.service

- name: update the sysconfig to have necessary variables
  lineinfile:
    dest: "/etc/sysconfig/{{ openshift_service_type }}-node"
    line: "{{ item.line | default(omit) }}"
    regexp: "{{ item.regexp }}"
    state: "{{ item.state | default('present') }}"
  with_items:
  # add the kubeconfig
  - line: "KUBECONFIG={{ openshift_node_config_dir }}/bootstrap.kubeconfig"
    regexp: "^KUBECONFIG=.*"
  # remove the config file.  This comes from openshift_facts
  - line: "CONFIG_FILE={{ openshift_node_config_dir }}/node-config.yaml"
    regexp: "^CONFIG_FILE=.*"

- name: include aws sysconfig credentials
  import_tasks: aws.yml
  when: not (openshift_node_use_instance_profiles | default(False))

#- name: update the ExecStart to have bootstrap
#  lineinfile:
#    dest: "/usr/lib/systemd/system/{{ openshift_service_type }}-node.service"
#    line: "{% raw %}ExecStart=/usr/bin/openshift start node --bootstrap --kubeconfig=${KUBECONFIG} $OPTIONS{% endraw %}"
#    regexp: "^ExecStart=.*"

- name: "disable {{ openshift_service_type }}-node"  # and {{ openshift_service_type }}-master services"
  systemd:
    name: "{{ item }}"
    enabled: no
  with_items:
  - "{{ openshift_service_type }}-node.service"
#  - "{{ openshift_service_type }}-master.service"

- name: Check for RPM generated config marker file .config_managed
  stat:
    path: /etc/origin/.config_managed
  register: rpmgenerated_config

- name: create directories for bootstrapping
  file:
    state: directory
    dest: "{{ item }}"
  with_items:
  - /root/openshift_bootstrap
  - /var/lib/origin/openshift.local.config
  - /var/lib/origin/openshift.local.config/node
  - "/etc/docker/certs.d/docker-registry.default.svc:5000"

- name: laydown the bootstrap.yml file for on boot configuration
  copy:
    src: bootstrap.yml
    dest: /root/openshift_bootstrap/bootstrap.yml

- name: symlink master ca for docker-registry
  file:
    src: "{{ item }}"
    dest: "/etc/docker/certs.d/docker-registry.default.svc:5000/{{ item | basename }}"
    state: link
    force: yes
  with_items:
  - "{{ openshift_node_config_dir }}/node-client-ca.crt"

- when: rpmgenerated_config.stat.exists
  block:
  - name: Remove RPM generated config files if present
    file:
      path: "/etc/origin/{{ item }}"
      state: absent
    with_items:
    - master
    - .config_managed

  # with_fileglob doesn't work correctly due to a few issues.
  # Could change this to fileglob when it gets fixed.
  - name: find all files in /etc/origin/node so we can remove them
    find:
      path: /etc/origin/node/
    register: find_results

  - name: Remove everything except the resolv.conf required for node
    file:
      path: "{{ item.path }}"
      state: absent
    when:
    - "'resolv.conf' not in item.path"
    - "'node-dnsmasq.conf' not in item.path"
    with_items: "{{ find_results.files }}"