Hyunsun Moon | e484834 | 2020-02-16 04:28:55 -0800 | [diff] [blame] | 1 | # Copyright 2020-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | --- |
| 16 | |
| 17 | - name: Install dependencies for Docker |
| 18 | apt: |
Hyunsun Moon | 6c6db95 | 2020-03-04 20:50:51 -0800 | [diff] [blame^] | 19 | name: "{{ item }}" |
| 20 | state: present |
| 21 | with_items: |
Hyunsun Moon | e484834 | 2020-02-16 04:28:55 -0800 | [diff] [blame] | 22 | - apt-transport-https |
| 23 | - ca-certificates |
| 24 | - curl |
| 25 | - software-properties-common |
Hyunsun Moon | e484834 | 2020-02-16 04:28:55 -0800 | [diff] [blame] | 26 | tags: docker |
| 27 | |
| 28 | - name: Add Docker GPG key |
Hyunsun Moon | 6c6db95 | 2020-03-04 20:50:51 -0800 | [diff] [blame^] | 29 | apt_key: |
| 30 | url: https://download.docker.com/linux/ubuntu/gpg |
| 31 | state: present |
Hyunsun Moon | e484834 | 2020-02-16 04:28:55 -0800 | [diff] [blame] | 32 | tags: docker |
| 33 | |
| 34 | - name: Add Docker repository |
Hyunsun Moon | 6c6db95 | 2020-03-04 20:50:51 -0800 | [diff] [blame^] | 35 | apt_repository: |
| 36 | repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable |
| 37 | update_cache: yes |
| 38 | state: present |
Hyunsun Moon | e484834 | 2020-02-16 04:28:55 -0800 | [diff] [blame] | 39 | tags: docker |
| 40 | |
| 41 | - name: Install Docker CE |
| 42 | apt: |
| 43 | name: docker-ce={{ docker_version }} |
| 44 | state: present |
| 45 | update_cache: yes |
| 46 | tags: docker |
| 47 | |
| 48 | - name: Add current user to "docker" group |
| 49 | user: |
| 50 | name: "{{ ansible_user }}" |
Hyunsun Moon | 6c6db95 | 2020-03-04 20:50:51 -0800 | [diff] [blame^] | 51 | groups: |
| 52 | - docker |
Hyunsun Moon | e484834 | 2020-02-16 04:28:55 -0800 | [diff] [blame] | 53 | append: true |
| 54 | tags: docker |
| 55 | |
| 56 | - name: Configure Docker daemon options |
| 57 | copy: |
| 58 | dest: /etc/docker/daemon.json |
| 59 | content: "{{ docker_daemon_options | to_json }}" |
| 60 | register: docker_register_options |
| 61 | notify: restart docker |
| 62 | tags: docker |
| 63 | |
| 64 | - name: Reload systemd daemon |
| 65 | systemd: |
| 66 | daemon_reload: true |
| 67 | when: docker_register_options is changed |
| 68 | tags: docker |