Tomáš Levora | a1d3e82 | 2018-12-19 15:39:22 +0100 | [diff] [blame] | 1 | --- |
| 2 | - name: Install docker |
| 3 | package: |
| 4 | name: 'docker-ce' |
| 5 | state: present |
| 6 | notify: |
| 7 | - Restart Docker |
| 8 | |
| 9 | - name: Install docker python module |
| 10 | package: |
| 11 | name: 'python2-docker' |
| 12 | state: present |
| 13 | |
Petr Ospalý | 98ea828 | 2019-03-25 13:25:45 +0100 | [diff] [blame] | 14 | - name: Install python jsonpointer module |
| 15 | package: |
| 16 | name: 'python-jsonpointer' |
| 17 | state: present |
| 18 | |
Tomáš Levora | a1d3e82 | 2018-12-19 15:39:22 +0100 | [diff] [blame] | 19 | - name: Ensure /etc/docker exists |
| 20 | file: |
| 21 | path: /etc/docker |
| 22 | state: directory |
| 23 | |
Petr Ospalý | f604d49 | 2019-03-04 06:56:33 +0100 | [diff] [blame] | 24 | - name: Setup docker container logging settings |
| 25 | json_mod: |
| 26 | path: /etc/docker/daemon.json |
Samuli Silvius | bf6776c | 2019-03-25 18:46:24 +0200 | [diff] [blame] | 27 | key: '' # the whole JSON document per https://tools.ietf.org/html/rfc6901 |
Petr Ospalý | f604d49 | 2019-03-04 06:56:33 +0100 | [diff] [blame] | 28 | # "value" must be wrapped in single quote "'" with extra space in front of "{" (ansible workaround) |
| 29 | # reference: https://stackoverflow.com/questions/31969872 |
| 30 | value: ' { "log-driver": "json-file", "log-opts": { "max-size": "{{ docker.log_max_size }}", "max-file": "{{ docker.log_max_file }}" } }' |
| 31 | |
Tomáš Levora | a1d3e82 | 2018-12-19 15:39:22 +0100 | [diff] [blame] | 32 | - name: Setup docker dns settings |
Petr Ospalý | f604d49 | 2019-03-04 06:56:33 +0100 | [diff] [blame] | 33 | json_mod: |
Tomáš Levora | a1d3e82 | 2018-12-19 15:39:22 +0100 | [diff] [blame] | 34 | path: /etc/docker/daemon.json |
| 35 | key: dns |
Petr Ospalý | f604d49 | 2019-03-04 06:56:33 +0100 | [diff] [blame] | 36 | # "value" must be wrapped in single quote "'" with extra space in front of "[" (ansible workaround) |
| 37 | # reference: https://stackoverflow.com/questions/31969872 |
| 38 | value: ' [ "{{ hostvars[groups.infrastructure[0]].cluster_ip }}" ]' |
Tomáš Levora | a1d3e82 | 2018-12-19 15:39:22 +0100 | [diff] [blame] | 39 | notify: |
| 40 | - Restart Docker |
| 41 | |
| 42 | - name: Force notified handlers to run at this point |
| 43 | meta: flush_handlers |
| 44 | |
| 45 | - name: Ensure docker is started |
| 46 | systemd: |
| 47 | name: docker |
| 48 | state: started |
Samuli Silvius | bf6776c | 2019-03-25 18:46:24 +0200 | [diff] [blame] | 49 | enabled: true |