summaryrefslogtreecommitdiffstats
path: root/roles/docker/tasks/configure.yml
blob: 04eeafe03ce94747e7a50b8648a663afcdb96298 (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
---
#- name: Remove docker
#  yum: name="{{ item }}" state="absent"
#  with_items: [ docker, docker-client, docker-common ]

- name: install docker
  register: docker_install_result
  include_tasks: install.yml

- name: start docker
  register: docker_start_result
  service: name="docker" state="started"
  when: not docker_reconfigure

- name: Configure bridge-nf-call-iptables with sysctl
  sysctl: name="net.bridge.bridge-nf-call-iptables"  value=1 state=present sysctl_set=yes

- name: Configure bridge-nf-call-ip6tables with sysctl
  sysctl: name="net.bridge.bridge-nf-call-ip6tables"  value=1 state=present sysctl_set=yes

- name: Determine if loopback
  shell: docker info | grep 'Data file:.*loop'
  register: loop_device_check
  failed_when: false
  changed_when: loop_device_check.rc == 0
  when: not docker_reconfigure

- set_fact: docker_reinit=false

- set_fact:  docker_reinit=true
  vars:
    check: "{{ loop_device_check | default({}) }}" 
    lv: "{{ ansible_lvm['lvs'][docker_lv] | default({}) }}"
    vg: "{{ lv['vg'] | default('') }}"
  when:
    - docker_install_result is changed
    - docker_start_result is changed
    - ansible_lvm['lvs'][docker_lv] is not defined

# Pass option docker_reconfigure to run this...
- set_fact: docker_reinit="{{ loop_back or wrong_root_vg or wrong_docker_vg }}"
  vars:
    check: "{{ loop_device_check | default({}) }}" 
    lv: "{{ ansible_lvm['lvs'][docker_lv] | default({}) }}"
    vg: "{{ lv['vg'] | default('') }}"
    root_lv: "{{ ansible_lvm['lvs'][docker_root_lv] | default({}) }}"
    root_vg: "{{ root_lv['vg'] | default('') }}"
    loop_back: "{{ check.rc | default(9) == 0  }}"
    wrong_root_vg: "{{ docker_setup_root and ((root_vg == '') or (vg != root_vg)) }}"
    wrong_docker_vg: "{{ docker_storage_vg is defined and (docker_storage_vg != vg) }}"
  when:
    - docker_reconfigure | default(false)
    
- import_tasks: storage.yml
  when: docker_reinit

- name: extend vg
  lvol: vg="{{ ansible_lvm['lvs'][docker_lv]['vg'] }}" lv="{{ docker_lv }}" size="{{ docker_volume_size }}"
  when: 
    - not docker_reinit
    - docker_volume_size is defined

- name: extend root vg
  lvol: vg="{{ ansible_lvm['lvs'][docker_root_lv]['vg'] }}" lv="{{ docker_root_lv }}" size="{{ docker_root_volume_size }}"
  when: 
    - not docker_reinit
    - docker_setup_root
    - docker_root_volume_size is defined

# By default there is systemd driver installed. It is removed during OpenShift installation, but is still there during prepare stage
# The parameters to docker can be set trough OpenShift and currently are moved there.
#- name: Limit size of container log files
#  ghetto_json:
#    path: "/etc/docker/daemon.json"
#    log-driver: "json-file"
#    log-opts.max-size: "{{ docker_max_log_size }}" 
#    log-opts.max-file: "{{ docker_max_log_files }}"
#  notify:
#    - restart docker

- name: start docker
  service: name="docker" enabled=yes state=started