stack_car 0.2.5 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,148 @@
1
+ docker_ubuntu
2
+ ========
3
+
4
+ [![Build Status](https://travis-ci.org/angstwad/docker.ubuntu.svg)](https://travis-ci.org/angstwad/docker.ubuntu)
5
+
6
+ Installs Docker on:
7
+
8
+ * Ubuntu 12.04+
9
+ * Debian 8.5+
10
+
11
+ This role differs from other roles in that it specifically follows docker.io installation instructions for each distribution version.
12
+
13
+ **Example Play**:
14
+ ```
15
+ ---
16
+ - name: Run docker.ubuntu
17
+ hosts: docker
18
+ roles:
19
+ - angstwad.docker_ubuntu
20
+ ```
21
+
22
+ **Please see [this playbook](https://github.com/angstwad/ansible-docker-rackspace) as a more advanced example of how to utilize this role.**
23
+
24
+ Applying the role to servers is pretty simple:
25
+ ```
26
+ - name: Install Docker on Rax Server
27
+ hosts: all
28
+ roles:
29
+ - angstwad.docker_ubuntu
30
+ ```
31
+
32
+ Overriding the role's default variables is also pretty straightforward:
33
+ ```
34
+ - name: Install Docker on Rax Server
35
+ hosts: all
36
+ roles:
37
+ - role: angstwad.docker_ubuntu
38
+ ssh_port: 2222
39
+ kernel_pkg_state: present
40
+ ```
41
+
42
+
43
+ Requirements
44
+ ------------
45
+
46
+ Requires python-pycurl for apt modules.
47
+
48
+ Role Variables
49
+ --------------
50
+
51
+ These are the defaults, which can be set to present to prevent a reboot if the latest linux-image-extra, cgroup-lite packages are already installed.
52
+ The following role variables are defined:
53
+
54
+ ```
55
+ ---
56
+ # docker-engine is the default package name
57
+ docker_pkg_name: docker-engine
58
+ docker_apt_cache_valid_time: 600
59
+
60
+ # docker dns path for docker.io package ( changed at ubuntu 14.04 from docker to docker.io )
61
+ docker_defaults_file_path: /etc/default/docker
62
+
63
+ # Important if running Ubuntu 12.04-13.10 and ssh on a non-standard port
64
+ ssh_port: 22
65
+ # Place to get apt repository key
66
+ apt_key_url: hkp://p80.pool.sks-keyservers.net:80
67
+ # apt repository key signature
68
+ apt_key_sig: 58118E89F3A912897C070ADBF76221572C52609D
69
+ # Name of the apt repository for docker
70
+ apt_repository: deb https://apt.dockerproject.org/repo {{ ansible_lsb.id|lower }}-{{ ansible_lsb.codename|lower }} main
71
+ # The following help expose a docker port or to add additional options when
72
+ # running docker daemon. The default is to not use any special options.
73
+ #docker_opts: >
74
+ # -H unix://
75
+ # -H tcp://0.0.0.0:2375
76
+ # --log-level=debug
77
+ docker_opts: ""
78
+ # List of users to be added to 'docker' system group (disabled by default)
79
+ # SECURITY WARNING: 
80
+ # Be aware that granted users can easily get full root access on the docker host system!
81
+ docker_group_members: []
82
+
83
+ # configurable proxies: a reasonable default is to re-use the proxy from ansible_env:
84
+ # docker_http_proxy: "{{ ansible_env.http_proxy|default('') }}"
85
+ # Notes:
86
+ # if docker_http_proxy=="" the role sets HTTP_PROXY="" (useful to 'empty' existing ENV var)
87
+ # if docker_http_proxy is undefined the role will not set/modify any ENV vars
88
+ docker_http_proxy:
89
+ docker_https_proxy:
90
+
91
+ # Flags for whether to install pip packages
92
+ pip_install_pip: true
93
+ pip_install_setuptools: true
94
+ pip_install_docker_py: true
95
+ pip_install_docker_compose: true
96
+ install_docker_py_on_1604: false
97
+
98
+ # Versions for the python packages that are installed
99
+ pip_version_pip: latest
100
+ pip_version_setuptools: latest
101
+ pip_version_docker_py: latest
102
+ pip_version_docker_compose: latest
103
+
104
+ # If this variable is set to true kernel updates and host restarts are permitted.
105
+ # Warning: Use with caution in production environments.
106
+ kernel_update_and_reboot_permitted: no
107
+
108
+ # Set to 'yes' or 'true' to enable updates (sets 'latest' in apt module)
109
+ update_docker_package: no
110
+ # Change these to 'present' if you're running Ubuntu 12.04-13.10 and are fine with less-than-latest packages
111
+ kernel_pkg_state: latest
112
+ cgroup_lite_pkg_state: latest
113
+ dmsetup_pkg_state: latest
114
+ # Force an install of the kernel extras, in case you're suffering from some issue related to the
115
+ # static binary provided by upstream Docker. For example, see this GitHub Issue in Docker:
116
+ # https://github.com/docker/docker/issues/12750
117
+ # Warning: Installing kernel extras is potentially interruptive/destructive and will install backported
118
+ # kernel if running 12.04.
119
+ install_kernel_extras: false
120
+ # Install Xorg packages for backported kernels. This is usually unnecessary except for environments
121
+ # where an X/Unit desktop is actively being used. If you're not using an X/Unity on 12.04, you
122
+ # won't need to enable this.
123
+ install_xorg_pkgs: false
124
+ ```
125
+
126
+ Dependencies
127
+ ------------
128
+
129
+ None.
130
+
131
+ Testing
132
+ -------
133
+
134
+ To test the role in a Vagrant environment just run `vagrant up`. This will
135
+ create three VMs:
136
+
137
+ * Ubuntu 12.04
138
+ * Ubuntu 14.04
139
+ * Debian Jessie 8.5
140
+
141
+ and it will provision them by applying this role with Ansible.
142
+
143
+ Requires `ansible-playbook` to be in the path.
144
+
145
+ License
146
+ -------
147
+
148
+ Apache v2.0
@@ -0,0 +1,63 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby ts=2 sw=2 tw=0 et :
3
+
4
+ role = File.basename(File.expand_path(File.dirname(__FILE__)))
5
+
6
+ ENV['ANSIBLE_ROLES_PATH'] = "../"
7
+
8
+ boxes = [
9
+ {
10
+ :name => "ubuntu-1204",
11
+ :box => "ubuntu/precise64",
12
+ :ip => '10.0.77.11',
13
+ :cpu => "33",
14
+ :ram => "256"
15
+ },
16
+ {
17
+ :name => "ubuntu-1404",
18
+ :box => "ubuntu/trusty64",
19
+ :ip => '10.0.77.12',
20
+ :cpu => "33",
21
+ :ram => "256"
22
+ },
23
+ {
24
+ :name => "ubuntu-1604",
25
+ :box => "ubuntu/xenial64",
26
+ :ip => '10.0.77.13',
27
+ :cpu => "33",
28
+ :ram => "512"
29
+ },
30
+ {
31
+ :name => "debian-jessie",
32
+ :box => "debian/jessie64",
33
+ :ip => '10.0.77.14',
34
+ :cpu => "33",
35
+ :ram => "256"
36
+ },
37
+ ]
38
+
39
+ Vagrant.configure("2") do |config|
40
+ boxes.each do |box|
41
+ config.vm.define box[:name] do |vms|
42
+ vms.vm.box = box[:box]
43
+ vms.vm.box_url = box[:url]
44
+
45
+ vms.vm.provider "virtualbox" do |v|
46
+ v.customize ["modifyvm", :id, "--cpuexecutioncap", box[:cpu]]
47
+ v.customize ["modifyvm", :id, "--memory", box[:ram]]
48
+ end
49
+
50
+ vms.vm.network :private_network, ip: box[:ip]
51
+
52
+ # neccessary for ubuntu 16.04 and harmless for the rest
53
+ vms.vm.provision :shell do |shell|
54
+ shell.inline = "DEBIAN_FRONTEND=noninteractive apt-get -y install python-simplejson"
55
+ end
56
+
57
+ vms.vm.provision :ansible do |ansible|
58
+ ansible.playbook = "tests/vagrant.yml"
59
+ ansible.verbose = "vv"
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,70 @@
1
+ ---
2
+ # docker-engine is the default package name
3
+ docker_pkg_name: docker-engine
4
+ docker_apt_cache_valid_time: 600
5
+
6
+ # docker dns path for docker.io package ( changed at ubuntu 14.04 from docker to docker.io )
7
+ docker_defaults_file_path: /etc/default/docker
8
+
9
+ # Important if running Ubuntu 12.04-13.10 and ssh on a non-standard port
10
+ ssh_port: 22
11
+ # Place to get apt repository key
12
+ apt_key_url: hkp://p80.pool.sks-keyservers.net:80
13
+ # apt repository key signature
14
+ apt_key_sig: 58118E89F3A912897C070ADBF76221572C52609D
15
+ # Name of the apt repository for docker
16
+ apt_repository: deb https://apt.dockerproject.org/repo {{ ansible_lsb.id|lower }}-{{ ansible_lsb.codename|lower }} main
17
+ # The following help expose a docker port or to add additional options when
18
+ # running docker daemon. The default is to not use any special options.
19
+ #docker_opts: >
20
+ # -H unix://
21
+ # -H tcp://0.0.0.0:2375
22
+ # --log-level=debug
23
+ docker_opts: ""
24
+ # List of users to be added to 'docker' system group (disabled by default)
25
+ # SECURITY WARNING: 
26
+ # Be aware that granted users can easily get full root access on the docker host system!
27
+ docker_group_members: []
28
+
29
+ # configurable proxies: a reasonable default is to re-use the proxy from ansible_env:
30
+ # docker_http_proxy: "{{ ansible_env.http_proxy|default('') }}"
31
+ # Notes:
32
+ # if docker_http_proxy=="" the role sets HTTP_PROXY="" (useful to 'empty' existing ENV var)
33
+ # if docker_http_proxy is undefined the role will not set/modify any ENV vars
34
+ docker_http_proxy:
35
+ docker_https_proxy:
36
+
37
+ # Flags for whether to install pip packages
38
+ pip_install_pip: true
39
+ pip_install_setuptools: true
40
+ pip_install_docker_py: true
41
+ pip_install_docker_compose: true
42
+ install_docker_py_on_1604: false
43
+
44
+ # Versions for the python packages that are installed
45
+ pip_version_pip: latest
46
+ pip_version_setuptools: latest
47
+ pip_version_docker_py: latest
48
+ pip_version_docker_compose: latest
49
+
50
+ # If this variable is set to true kernel updates and host restarts are permitted.
51
+ # Warning: Use with caution in production environments.
52
+ kernel_update_and_reboot_permitted: no
53
+
54
+ # Set to 'yes' or 'true' to enable updates (sets 'latest' in apt module)
55
+ update_docker_package: no
56
+
57
+ # Change these to 'present' if you're running Ubuntu 12.04-13.10 and are fine with less-than-latest packages
58
+ kernel_pkg_state: latest
59
+ cgroup_lite_pkg_state: latest
60
+ dmsetup_pkg_state: latest
61
+ # Force an install of the kernel extras, in case you're suffering from some issue related to the
62
+ # static binary provided by upstream Docker. For example, see this GitHub Issue in Docker:
63
+ # https://github.com/docker/docker/issues/12750
64
+ # Warning: Installing kernel extras is potentially interruptive/destructive and will install backported
65
+ # kernel if running 12.04.
66
+ install_kernel_extras: false
67
+ # Install Xorg packages for backported kernels. This is usually unnecessary except for environments
68
+ # where an X/Unit desktop is actively being used. If you're not using an X/Unity on 12.04, you
69
+ # won't need to enable this.
70
+ install_xorg_pkgs: false
@@ -0,0 +1,9 @@
1
+ ---
2
+ - hosts: all
3
+ become: yes
4
+ roles:
5
+ - { role: ./,
6
+ docker_opts: "-H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock --dns 8.8.8.8 --dns 8.8.4.4"
7
+ }
8
+
9
+ #- include: integration-tests.yml
@@ -0,0 +1,13 @@
1
+ ---
2
+ # handlers file for docker.ubuntu
3
+ - name: Start Docker
4
+ service: name=docker state=started
5
+
6
+ - name: Reload systemd
7
+ command: systemctl daemon-reload
8
+
9
+ - name: Restart docker
10
+ service: name=docker state=restarted
11
+
12
+ - name: Restart dockerio
13
+ service: name=docker.io state=restarted
@@ -0,0 +1,2 @@
1
+ [local]
2
+ localhost
@@ -0,0 +1,25 @@
1
+ ---
2
+ galaxy_info:
3
+ author: Paul Durivage
4
+ description: Docker on Ubuntu greater than 12.04
5
+ license: Apache v2.0
6
+ min_ansible_version: 1.2
7
+ platforms:
8
+ - name: Debian
9
+ versions:
10
+ - jessie
11
+ - name: Ubuntu
12
+ versions:
13
+ - precise
14
+ - trusty
15
+ - xenial
16
+ categories:
17
+ - development
18
+ - packaging
19
+ - system
20
+ dependencies: []
21
+ # List your role dependencies here, one per line. Only
22
+ # dependencies available via galaxy should be listed here.
23
+ # Be sure to remove the '[]' above if you add dependencies
24
+ # to this list.
25
+
@@ -0,0 +1,65 @@
1
+ - name: Install backported trusty kernel onto 12.04
2
+ apt:
3
+ pkg: "{{ item }}"
4
+ state: "{{ kernel_pkg_state }}"
5
+ update_cache: yes
6
+ cache_valid_time: 600
7
+ with_items:
8
+ - linux-image-generic-lts-trusty
9
+ - linux-headers-generic-lts-trusty
10
+ register: kernel_result
11
+ when: "ansible_distribution_version|version_compare('12.04', '=')"
12
+
13
+ - name: Install Xorg packages for backported kernels (very optional)
14
+ apt:
15
+ pkg: "{{ item }}"
16
+ state: installed
17
+ update_cache: yes
18
+ cache_valid_time: 600
19
+ with_items:
20
+ - xserver-xorg-lts-trusty
21
+ - libgl1-mesa-glx-lts-trusty
22
+ register: xorg_pkg_result
23
+ when: "install_xorg_pkgs and (kernel_result|changed or kernel_result|success)"
24
+
25
+ - name: Install latest kernel for Ubuntu 13.04+
26
+ apt:
27
+ pkg: "{{ item }}"
28
+ state: "{{ kernel_pkg_state }}"
29
+ update_cache: yes
30
+ cache_valid_time: 600
31
+ with_items:
32
+ - "linux-image-extra-{{ ansible_kernel }}"
33
+ - linux-image-extra-virtual
34
+ when: "ansible_distribution_version|version_compare('13.04', '=')
35
+ or ansible_distribution_version|version_compare('13.10', '=')
36
+ or install_kernel_extras"
37
+
38
+ # Fix for https://github.com/dotcloud/docker/issues/4568
39
+ - name: Install cgroup-lite for Ubuntu 13.10
40
+ apt:
41
+ pkg: cgroup-lite
42
+ state: "{{ cgroup_lite_pkg_state }}"
43
+ update_cache: yes
44
+ cache_valid_time: 600
45
+ register: cgroup_lite_result
46
+ when: "ansible_distribution_version|version_compare('13.10', '=')"
47
+
48
+ - name: Reboot instance
49
+ command: /sbin/shutdown -r now
50
+ register: reboot_result
51
+ when: "(ansible_distribution_version|version_compare('12.04', '=') and kernel_result|changed)
52
+ or (ansible_distribution_version|version_compare('13.10', '=') and cgroup_lite_result|changed)
53
+ or xorg_pkg_result|changed"
54
+
55
+ - name: Wait for instance to come online (10 minute timeout)
56
+ become: no
57
+ local_action:
58
+ module: wait_for
59
+ host: "{{ ansible_ssh_host|default(inventory_hostname) }}"
60
+ port: "{{ ansible_ssh_port|default(ssh_port) }}"
61
+ delay: 30
62
+ timeout: 600
63
+ state: started
64
+ when: "(ansible_distribution_version|version_compare('12.04', '=') and reboot_result|changed)
65
+ or (ansible_distribution_version|version_compare('13.10', '=') and cgroup_lite_result|changed)"
@@ -0,0 +1,261 @@
1
+ ---
2
+ # tasks file for docker.ubuntu
3
+ - name: Fail if not a new release of Ubuntu
4
+ fail:
5
+ msg: "{{ ansible_distribution_version }} is not an acceptable version of Ubuntu for this role"
6
+ when: ansible_lsb.id|lower == "ubuntu" and ( ansible_distribution_version|version_compare('12.04', '<') or ansible_distribution_version|version_compare('12.10', '=') )
7
+
8
+ - name: Fail if not a new release of Debian
9
+ fail:
10
+ msg: "{{ ansible_distribution_version }} is not an acceptable version of Debian for this role"
11
+ when: ansible_lsb.id|lower == "debian" and ansible_distribution_version|version_compare('8.5', '<')
12
+
13
+ - name: Update kernel, kernel extras, Xorg pkgs, and related tasks
14
+ include: kernel_check_and_update.yml
15
+ when: kernel_update_and_reboot_permitted or install_kernel_extras
16
+
17
+ # Fix for https://github.com/docker/docker/issues/23347
18
+ - name: Install dmsetup for Ubuntu 16.04
19
+ apt:
20
+ pkg: dmsetup
21
+ state: "{{ dmsetup_pkg_state }}"
22
+ update_cache: "{{ 'yes' if dmsetup_pkg_state=='latest' else 'no' }}"
23
+ cache_valid_time: "{{ docker_apt_cache_valid_time }}"
24
+ register: dmsetup_result
25
+ when: ansible_distribution_version|version_compare('16.04', '=')
26
+
27
+ - name: Read uname
28
+ shell: uname -r
29
+ register: uname_output
30
+ changed_when: false
31
+ always_run: yes
32
+
33
+ - name: Install linux-image-extra-* packages to enable AuFS driver
34
+ apt:
35
+ pkg: "{{ item }}"
36
+ state: present
37
+ update_cache: yes
38
+ cache_valid_time: "{{ docker_apt_cache_valid_time }}"
39
+ with_items:
40
+ - linux-image-extra-{{ uname_output.stdout }}
41
+ - linux-image-extra-virtual
42
+ when: ansible_distribution_version|version_compare('14.04', '>=')
43
+
44
+ - name: Run dmsetup for Ubuntu 16.04
45
+ command: dmsetup mknodes
46
+ when: dmsetup_result.changed
47
+
48
+ - name: Add Docker repository key
49
+ apt_key:
50
+ id: "{{ apt_key_sig }}"
51
+ keyserver: "{{ apt_key_url }}"
52
+ state: present
53
+ register: add_repository_key
54
+ ignore_errors: true
55
+
56
+ - name: Alternative | Add Docker repository key
57
+ shell: "curl -sSL {{ apt_key_url }} | sudo apt-key add -"
58
+ when: add_repository_key|failed
59
+
60
+ - name: HTTPS APT transport for Docker repository
61
+ apt:
62
+ name: apt-transport-https
63
+ state: present
64
+
65
+ - name: Add Docker repository and update apt cache
66
+ apt_repository:
67
+ repo: "{{ apt_repository }}"
68
+ mode: '644'
69
+ update_cache: yes
70
+ state: present
71
+
72
+ - name: Install (or update) docker package
73
+ apt:
74
+ name: "{{ docker_pkg_name }}"
75
+ state: "{{ 'latest' if update_docker_package else 'present' }}"
76
+ update_cache: "{{ update_docker_package }}"
77
+ cache_valid_time: "{{ docker_apt_cache_valid_time }}"
78
+
79
+ - name: Set systemd playbook var
80
+ set_fact:
81
+ is_systemd: false
82
+ changed_when: false
83
+
84
+ - name: Set systemd playbook var
85
+ set_fact:
86
+ is_systemd: true
87
+ when: ( ansible_lsb.id|lower == "ubuntu" and ansible_distribution_version|version_compare('15.04', '>=') or ansible_lsb.id|lower == "debian" )
88
+
89
+ - name: Set docker daemon options
90
+ copy:
91
+ content: "DOCKER_OPTS=\"{{ docker_opts.rstrip() }}\""
92
+ dest: /etc/default/docker
93
+ owner: root
94
+ group: root
95
+ mode: 0644
96
+ notify:
97
+ - Restart docker
98
+ when: docker_opts != "" and not is_systemd
99
+
100
+ - name: Create systemd configuration directory for Docker service (systemd)
101
+ file:
102
+ dest: /etc/systemd/system/docker.service.d
103
+ state: directory
104
+ owner: root
105
+ group: root
106
+ mode: 0755
107
+ when: docker_opts != "" and is_systemd
108
+
109
+ - name: Set docker daemon options (systemd)
110
+ copy:
111
+ content: |
112
+ [Service]
113
+ Environment="DOCKER_OPTS={{ docker_opts.rstrip() }}"
114
+ dest: /etc/systemd/system/docker.service.d/env.conf
115
+ owner: root
116
+ group: root
117
+ mode: 0644
118
+ notify:
119
+ - Reload systemd
120
+ - Restart docker
121
+ when: docker_opts != "" and is_systemd
122
+
123
+ - name: Ensure docker daemon options used (systemd)
124
+ template:
125
+ src: docker.conf
126
+ dest: /etc/systemd/system/docker.service.d/docker.conf
127
+ notify:
128
+ - Reload systemd
129
+ - Restart docker
130
+ when: docker_opts != "" and is_systemd
131
+
132
+ - name: Fix DNS in docker.io
133
+ lineinfile:
134
+ dest: "{{ docker_defaults_file_path }}"
135
+ regexp: "DOCKER_OPTS="
136
+ line: 'DOCKER_OPTS="--dns {{ ansible_docker0.ipv4.address }}"'
137
+ register: dns_fix
138
+ notify: Restart dockerio
139
+ when: docker_pkg_name == 'docker.io'
140
+
141
+ - meta: flush_handlers
142
+ when: "dns_fix|changed"
143
+
144
+ - pause:
145
+ seconds: 1
146
+ when: "dns_fix|changed"
147
+
148
+ # We must install pip via apt before we can use the pip module below
149
+ - name: Install pip, python-dev package with apt
150
+ apt:
151
+ pkg: "{{ item }}"
152
+ state: latest
153
+ update_cache: yes
154
+ cache_valid_time: "{{ docker_apt_cache_valid_time }}"
155
+ with_items:
156
+ - python-dev
157
+ - python-pip
158
+
159
+ # Display an informative message if the docker-compose version needs to be downgraded
160
+ - name: Docker-compose version downgrade
161
+ debug:
162
+ msg: >-
163
+ Downgrading docker-compose version to {{ _pip_version_docker_compose }} because of docker-compose > 1.10
164
+ requiring docker python package (instead of the docker-py one) which is incompatible with the docker_container
165
+ module in Ansible < 2.3
166
+ when: pip_install_docker_compose and _pip_version_docker_compose != pip_version_docker_compose
167
+
168
+ # Upgrade pip with pip to fix angstwad/docker.ubuntu/pull/35 and docker-py/issues/525
169
+ - name: Install pip, setuptools, docker-py and docker-compose with pip
170
+ pip:
171
+ name: "{{ item.name }}"
172
+ state: "{{ 'latest' if item.version=='latest' else 'present' }}"
173
+ version: "{{ item.version if item.version!='latest' else omit }}"
174
+ with_items:
175
+ - name: pip
176
+ version: "{{ pip_version_pip }}"
177
+ install: "{{ pip_install_pip }}"
178
+ - name: setuptools
179
+ version: "{{ pip_version_setuptools }}"
180
+ install: "{{ pip_install_setuptools }}"
181
+ - name: docker-py
182
+ version: "{{ pip_version_docker_py }}"
183
+ install: "{{ pip_install_docker_py and (install_docker_py_on_1604 or not ansible_distribution_version|version_compare('16.04', '>=')) }}"
184
+ - name: docker-compose
185
+ version: "{{ _pip_version_docker_compose }}"
186
+ install: "{{ pip_install_docker_compose }}"
187
+ when: item.install|bool
188
+
189
+ - name: Check if /etc/updatedb.conf exists
190
+ stat:
191
+ path: /etc/updatedb.conf
192
+ register: updatedb_conf_exists
193
+
194
+ - name: Ensure updatedb does not index /var/lib/docker
195
+ lineinfile:
196
+ dest: /etc/updatedb.conf
197
+ state: present
198
+ backrefs: yes
199
+ regexp: '^PRUNEPATHS="(/var/lib/docker )?(.*)"$'
200
+ line: 'PRUNEPATHS="/var/lib/docker \2"'
201
+ when: updatedb_conf_exists.stat.exists
202
+
203
+ - name: Check if /etc/default/ufw exists
204
+ stat:
205
+ path: /etc/default/ufw
206
+ register: ufw_default_exists
207
+
208
+ - name: Change ufw default forward policy from drop to accept
209
+ lineinfile:
210
+ dest: /etc/default/ufw
211
+ regexp: "^DEFAULT_FORWARD_POLICY="
212
+ line: "DEFAULT_FORWARD_POLICY=\"ACCEPT\""
213
+ when: ufw_default_exists.stat.exists
214
+
215
+ - name: Set docker HTTP_PROXY if docker_http_proxy defined
216
+ lineinfile:
217
+ dest: /etc/default/docker
218
+ regexp: "^export HTTP_PROXY="
219
+ line: "export HTTP_PROXY=\"{{docker_http_proxy}}\""
220
+ state: present
221
+ when: docker_http_proxy is defined and (docker_http_proxy != None)
222
+ notify:
223
+ - Restart docker
224
+ tags: proxy
225
+
226
+ - name: Set docker HTTPS_PROXY if docker_https_proxy defined
227
+ lineinfile:
228
+ dest: /etc/default/docker
229
+ regexp: "^export HTTPS_PROXY="
230
+ line: "export HTTPS_PROXY=\"{{docker_https_proxy}}\""
231
+ state: present
232
+ when: docker_https_proxy is defined and (docker_https_proxy != None)
233
+ notify:
234
+ - Restart docker
235
+ tags: proxy
236
+
237
+ - name: Start docker
238
+ service:
239
+ name: docker
240
+ state: started
241
+ when: docker_pkg_name.find('lxc-docker') != -1 or docker_pkg_name.find('docker-engine') != -1
242
+
243
+ - name: Start docker.io
244
+ service:
245
+ name: docker.io
246
+ state: started
247
+ when: docker_pkg_name == 'docker.io'
248
+
249
+ # ATTENTION: this task can potentially create new users!
250
+ - name: Add users to the docker group
251
+ user:
252
+ name: "{{ item }}"
253
+ groups: docker
254
+ append: yes
255
+ with_items: "{{docker_group_members}}"
256
+ when: docker_group_members is defined
257
+
258
+ - name: update facts if docker0 is not defined
259
+ setup:
260
+ filter: "ansible_docker0"
261
+ when: ansible_docker0 is not defined
@@ -0,0 +1,3 @@
1
+ [Service]
2
+ ExecStart=
3
+ ExecStart=/usr/bin/docker daemon -H fd:// $DOCKER_OPTS
@@ -0,0 +1,10 @@
1
+ ---
2
+ # test file for docker.ubuntu role on vagrant
3
+ - hosts: all
4
+ become: yes
5
+ vars:
6
+ docker_group_members:
7
+ - "{{ ansible_ssh_user }}"
8
+ roles:
9
+ - role: docker.ubuntu
10
+ kernel_update_and_reboot_permitted: yes
@@ -0,0 +1,9 @@
1
+ ---
2
+ # Downgrade docker-compose version if ansible version < 2.3 and docker-compose > 1.9.0
3
+ # Because of docker-compose 1.10+ requires docker python package (instead of the docker-py one)
4
+ # which is incompatible with the docker_container module in Ansible < 2.3
5
+ # TODO: update ansible version in the comparison when https://github.com/ansible/ansible/issues/20492 gets fixed.
6
+ _pip_version_docker_compose: >-
7
+ {{ '1.9.0' if ansible_version.full | version_compare('2.3', '<=')
8
+ and (pip_version_docker_compose=='latest' or pip_version_docker_compose | version_compare('1.9.0', '>'))
9
+ else pip_version_docker_compose }}