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 | |
| 14 | - name: Ensure /etc/docker exists |
| 15 | file: |
| 16 | path: /etc/docker |
| 17 | state: directory |
| 18 | |
Petr Ospalý | f604d49 | 2019-03-04 06:56:33 +0100 | [diff] [blame^] | 19 | - name: Setup docker container logging settings |
| 20 | json_mod: |
| 21 | path: /etc/docker/daemon.json |
| 22 | key: '' # the whole JSON document per https://tools.ietf.org/html/rfc6901 |
| 23 | # "value" must be wrapped in single quote "'" with extra space in front of "{" (ansible workaround) |
| 24 | # reference: https://stackoverflow.com/questions/31969872 |
| 25 | value: ' { "log-driver": "json-file", "log-opts": { "max-size": "{{ docker.log_max_size }}", "max-file": "{{ docker.log_max_file }}" } }' |
| 26 | |
Tomáš Levora | a1d3e82 | 2018-12-19 15:39:22 +0100 | [diff] [blame] | 27 | - name: Setup docker dns settings |
Petr Ospalý | f604d49 | 2019-03-04 06:56:33 +0100 | [diff] [blame^] | 28 | json_mod: |
Tomáš Levora | a1d3e82 | 2018-12-19 15:39:22 +0100 | [diff] [blame] | 29 | path: /etc/docker/daemon.json |
| 30 | key: dns |
Petr Ospalý | f604d49 | 2019-03-04 06:56:33 +0100 | [diff] [blame^] | 31 | # "value" must be wrapped in single quote "'" with extra space in front of "[" (ansible workaround) |
| 32 | # reference: https://stackoverflow.com/questions/31969872 |
| 33 | value: ' [ "{{ hostvars[groups.infrastructure[0]].cluster_ip }}" ]' |
Tomáš Levora | a1d3e82 | 2018-12-19 15:39:22 +0100 | [diff] [blame] | 34 | notify: |
| 35 | - Restart Docker |
| 36 | |
| 37 | - name: Force notified handlers to run at this point |
| 38 | meta: flush_handlers |
| 39 | |
| 40 | - name: Ensure docker is started |
| 41 | systemd: |
| 42 | name: docker |
| 43 | state: started |
| 44 | enabled: yes |