summaryrefslogtreecommitdiffstats
path: root/roles/container_runtime/tasks/main.yml
blob: 6d68082b1a4663f4f9b6cf0680da2b650bbb7b58 (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
---
- include_tasks: udev_workaround.yml
  when: docker_udev_workaround | default(False) | bool

- name: Add enterprise registry, if necessary
  set_fact:
    l2_docker_additional_registries: "{{ l2_docker_additional_registries + [openshift_docker_ent_reg] }}"
  when:
    - openshift.common.deployment_type == 'openshift-enterprise'
    - openshift_docker_ent_reg != ''
    - openshift_docker_ent_reg not in l2_docker_additional_registries
    - not openshift_use_crio_only | bool

- name: Use Package Docker if Requested
  include_tasks: package_docker.yml
  when:
    - not openshift_docker_use_system_container
    - not openshift_use_crio_only

- name: Ensure /var/lib/containers exists
  file:
    path: /var/lib/containers
    state: directory

- name: Fix SELinux Permissions on /var/lib/containers
  command: "restorecon -R /var/lib/containers/"
  changed_when: false

- name: Use System Container Docker if Requested
  include_tasks: systemcontainer_docker.yml
  when:
    - openshift_docker_use_system_container
    - not openshift_use_crio_only

- name: Add CRI-O usage Requested
  include_tasks: systemcontainer_crio.yml
  when:
    - openshift_use_crio
    - openshift_docker_is_node_or_master | bool

- name: stat the docker data dir
  stat:
    path: "{{ docker_default_storage_path }}"
  register: dockerstat

- when:
    - openshift_use_crio
    - dockerstat.stat.islnk is defined and not (dockerstat.stat.islnk | bool)
  block:
    - name: stop the current running docker
      systemd:
        state: stopped
        name: "{{ openshift_docker_service_name }}"

    - name: copy "{{ docker_default_storage_path }}" to "{{ docker_alt_storage_path }}"
      command: "cp -r {{ docker_default_storage_path }} {{ docker_alt_storage_path }}"
      register: results
      failed_when:
        - results.rc != 0

    - name: "Set the selinux context on {{ docker_alt_storage_path }}"
      command: "semanage fcontext -a -e {{ docker_default_storage_path }} {{ docker_alt_storage_path }}"
      register: results
      failed_when:
        - results.rc == 1
        - "'already exists' not in results.stderr"

    - name: "restorecon the {{ docker_alt_storage_path }}"
      command: "restorecon -r {{ docker_alt_storage_path }}"

    - name: Remove the old docker location
      file:
        state: absent
        path: "{{ docker_default_storage_path }}"

    - name: Setup the link
      file:
        state: link
        src: "{{ docker_alt_storage_path }}"
        path: "{{ docker_default_storage_path }}"

    - name: start docker
      systemd:
        state: started
        name: "{{ openshift_docker_service_name }}"