Sriram Yagnaraman | 9c26e07 | 2020-04-09 09:32:04 +0000 | [diff] [blame^] | 1 | --- |
| 2 | # ============LICENSE_START======================================================= |
| 3 | # Copyright (C) 2019 The Nordix Foundation. All rights reserved. |
| 4 | # ================================================================================ |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | # SPDX-License-Identifier: Apache-2.0 |
| 18 | # ============LICENSE_END========================================================= |
| 19 | |
| 20 | # NOTE (fdegir): gpg-agent is required for being able to run apt-key add |
| 21 | - name: Install gpg-agent |
| 22 | apt: |
| 23 | name: gpg-agent |
| 24 | state: present |
| 25 | update_cache: true |
| 26 | |
| 27 | - name: Add docker apt key |
| 28 | apt_key: |
| 29 | url: https://download.docker.com/linux/ubuntu/gpg |
| 30 | state: present |
| 31 | |
| 32 | # NOTE(fdegir): ansible apt_repository gives segmentation fault so failling back to command |
| 33 | - name: Add docker apt repository |
| 34 | command: |- |
| 35 | add-apt-repository \ |
| 36 | "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable" |
| 37 | changed_when: false |
| 38 | |
| 39 | - name: Run apt update |
| 40 | apt: |
| 41 | update_cache: true |
| 42 | |
| 43 | - name: Config docker proxy |
| 44 | block: |
| 45 | - name: Check that /etc/systemd/system/docker.service.d exists |
| 46 | stat: |
| 47 | path: "/etc/systemd/system/docker.service.d" |
| 48 | register: dir_stats |
| 49 | |
| 50 | - name: Create /etc/systemd/system/docker.service.d if not exists |
| 51 | file: |
| 52 | path: "/etc/systemd/system/docker.service.d" |
| 53 | state: directory |
| 54 | when: not dir_stats.stat.exists |
| 55 | |
| 56 | - name: Create proxy conf file under /etc/systemd/system/docker.service.d/ |
| 57 | file: |
| 58 | path: "/etc/systemd/system/docker.service.d/http-proxy.conf" |
| 59 | state: touch |
| 60 | |
| 61 | - name: Config docker proxy in http-proxy.conf |
| 62 | blockinfile: |
| 63 | dest: "/etc/systemd/system/docker.service.d/http-proxy.conf" |
| 64 | block: | |
| 65 | [Service] |
| 66 | Environment="HTTP_PROXY={{ idf.proxy_settings.http_proxy }}" |
| 67 | Environment="HTTPS_PROXY={{ idf.proxy_settings.https_proxy }}" |
| 68 | Environment="NO_PROXY={{ idf.proxy_settings.no_proxy }}" |
| 69 | when: |
| 70 | idf.proxy_settings is defined |
| 71 | |
| 72 | - name: Install packages on {{ ansible_os_family }} |
| 73 | include_tasks: "install-packages-{{ ansible_os_family }}.yml" |
| 74 | |
| 75 | # vim: set ts=2 sw=2 expandtab: |