aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/testbed-setup/ansible/roles/docker
diff options
context:
space:
mode:
authorpmikus <pmikus@cisco.com>2020-05-20 15:05:49 +0000
committerpmikus <pmikus@cisco.com>2020-05-20 15:05:49 +0000
commit5c7b32f5ba60acae88af6e838c79639d68a4fcad (patch)
tree601fe25983529d20abf31b43f9b21ab8bdf35e12 /resources/tools/testbed-setup/ansible/roles/docker
parent1881e1a4a59c3bd4a8574a1a0239a781874a48ec (diff)
Infra: Ansible maintenance
+ As per last discoveries when running from_scratch vs. append_only Signed-off-by: pmikus <pmikus@cisco.com> Change-Id: I8b44314185bbc157a67136730dc6146d133c7cc4
Diffstat (limited to 'resources/tools/testbed-setup/ansible/roles/docker')
-rw-r--r--resources/tools/testbed-setup/ansible/roles/docker/defaults/main.yaml25
-rw-r--r--resources/tools/testbed-setup/ansible/roles/docker/handlers/main.yaml5
-rw-r--r--resources/tools/testbed-setup/ansible/roles/docker/meta/main.yaml6
-rw-r--r--resources/tools/testbed-setup/ansible/roles/docker/tasks/main.yaml79
-rw-r--r--resources/tools/testbed-setup/ansible/roles/docker/tasks/ubuntu_bionic.yaml36
5 files changed, 87 insertions, 64 deletions
diff --git a/resources/tools/testbed-setup/ansible/roles/docker/defaults/main.yaml b/resources/tools/testbed-setup/ansible/roles/docker/defaults/main.yaml
index 4f2cae9b75..6c445aa42a 100644
--- a/resources/tools/testbed-setup/ansible/roles/docker/defaults/main.yaml
+++ b/resources/tools/testbed-setup/ansible/roles/docker/defaults/main.yaml
@@ -2,29 +2,30 @@
# file: roles/docker/defaults/main.yaml
# Version options.
-docker_edition: 'ce'
-docker_version: '19.03.3'
-docker_apt_package: '5:{{ docker_version }}~3-0~{{ ansible_distribution | lower }}-{{ ansible_distribution_release }}'
-docker_apt_package_state: present
+docker_edition: "ce"
+docker_package: "docker-{{ docker_edition }}"
+docker_package_state: present
# Service options.
docker_service_state: started
docker_service_enabled: true
docker_restart_handler_state: restarted
-# Used only for Debian/Ubuntu. Switch 'stable' to 'edge' if needed.
-docker_apt_release_channel: 'edge'
-docker_apt_repository: 'deb https://download.docker.com/linux/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} {{ docker_apt_release_channel }}'
+# Used only for Debian/Ubuntu.
+docker_apt_release_channel: "stable"
+docker_apt_key: "https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg"
+docker_apt_key_state: present
+docker_apt_repository: "deb https://download.docker.com/linux/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} {{ docker_apt_release_channel }}"
docker_apt_repository_state: present
# A list of users who will be added to the docker group.
docker_users:
- - 'testuser'
+ - "testuser"
# Proxy settings.
docker_daemon_environment_http:
- - 'HTTP_PROXY={{ proxy_env.http_proxy }}'
- - 'NO_PROXY={{ proxy_env.no_proxy }}'
+ - "HTTP_PROXY={{ proxy_env.http_proxy }}"
+ - "NO_PROXY={{ proxy_env.no_proxy }}"
docker_daemon_environment_https:
- - 'HTTPS_PROXY={{ proxy_env.https_proxy }}'
- - 'NO_PROXY={{ proxy_env.no_proxy }}'
+ - "HTTPS_PROXY={{ proxy_env.https_proxy }}"
+ - "NO_PROXY={{ proxy_env.no_proxy }}"
diff --git a/resources/tools/testbed-setup/ansible/roles/docker/handlers/main.yaml b/resources/tools/testbed-setup/ansible/roles/docker/handlers/main.yaml
index d33c63fae8..4dfcd0b867 100644
--- a/resources/tools/testbed-setup/ansible/roles/docker/handlers/main.yaml
+++ b/resources/tools/testbed-setup/ansible/roles/docker/handlers/main.yaml
@@ -3,6 +3,5 @@
- name: Restart Docker
service:
- name: 'docker'
- state: '{{ docker_restart_handler_state }}'
- tags: restart-docker
+ name: "docker"
+ state: "{{ docker_restart_handler_state }}"
diff --git a/resources/tools/testbed-setup/ansible/roles/docker/meta/main.yaml b/resources/tools/testbed-setup/ansible/roles/docker/meta/main.yaml
new file mode 100644
index 0000000000..0dc7d19507
--- /dev/null
+++ b/resources/tools/testbed-setup/ansible/roles/docker/meta/main.yaml
@@ -0,0 +1,6 @@
+---
+# file: roles/docker/meta/main.yaml
+
+dependencies: []
+
+
diff --git a/resources/tools/testbed-setup/ansible/roles/docker/tasks/main.yaml b/resources/tools/testbed-setup/ansible/roles/docker/tasks/main.yaml
index 1f7fdf6692..d3eef82781 100644
--- a/resources/tools/testbed-setup/ansible/roles/docker/tasks/main.yaml
+++ b/resources/tools/testbed-setup/ansible/roles/docker/tasks/main.yaml
@@ -1,49 +1,72 @@
---
# file: roles/docker/tasks/main.yaml
-- name: Docker - Install distribution - release - machine prerequisites
- include_tasks: '{{ ansible_distribution|lower }}_{{ ansible_distribution_release }}.yaml'
- tags: install-docker
+- include_tasks: "{{ ansible_distribution|lower }}_{{ ansible_distribution_release }}.yaml"
+ tags:
+ - docker-inst-dependencies
-- name: Docker - Create Service Directory
+- name: Inst - Docker
+ package:
+ name: "{{ docker_package }}"
+ state: "{{ docker_package_state }}"
+ notify:
+ - "Restart Docker"
+ tags:
+ - docker-inst-package
+
+- name: Conf - Docker Service
+ service:
+ name: docker
+ state: "{{ docker_service_state }}"
+ enabled: "{{ docker_service_enabled }}"
+ tags:
+ - docker-conf-service
+
+- name: Conf - Docker Service Directory
file:
- path: '/etc/systemd/system/docker.service.d'
- state: 'directory'
- tags: install-docker
+ path: "/etc/systemd/system/docker.service.d"
+ state: "directory"
+ tags:
+ - docker-conf-service
-- name: Docker - Setup HTTP Proxy
+- name: Conf - Docker HTTP Proxy
template:
- src: 'templates/docker.service.proxy.http'
- dest: '/etc/systemd/system/docker.service.d/http-proxy.conf'
- owner: 'root'
- group: 'root'
- mode: '0644'
+ src: "templates/docker.service.proxy.http"
+ dest: "/etc/systemd/system/docker.service.d/http-proxy.conf"
+ owner: "root"
+ group: "root"
+ mode: "0644"
notify:
- - 'Restart Docker'
+ - "Restart Docker"
when: >
proxy_env is defined and
proxy_env.http_proxy is defined
- tags: install-docker
+ tags:
+ - docker-conf-service
-- name: Docker - Setup HTTPS Proxy
+- name: Conf - Docker HTTPS Proxy
template:
- src: 'templates/docker.service.proxy.https'
- dest: '/etc/systemd/system/docker.service.d/https-proxy.conf'
- owner: 'root'
- group: 'root'
- mode: '0644'
+ src: "templates/docker.service.proxy.https"
+ dest: "/etc/systemd/system/docker.service.d/https-proxy.conf"
+ owner: "root"
+ group: "root"
+ mode: "0644"
notify:
- - 'Restart Docker'
+ - "Restart Docker"
when: >
proxy_env is defined and
proxy_env.https_proxy is defined
- tags: install-docker
+ tags:
+ - docker-conf-service
-- name: Docker - Set specific users to docker group
+- name: Conf - Users to Docker Group
user:
- name: '{{ item }}'
- groups: 'docker'
+ name: "{{ item }}"
+ groups: "docker"
append: True
- with_items: '{{ docker_users }}'
+ loop: "{{ docker_users }}"
when: docker_users
- tags: install-docker
+ tags:
+ - docker-conf-user
+
+- meta: flush_handlers
diff --git a/resources/tools/testbed-setup/ansible/roles/docker/tasks/ubuntu_bionic.yaml b/resources/tools/testbed-setup/ansible/roles/docker/tasks/ubuntu_bionic.yaml
index 32643b1119..a38a0af110 100644
--- a/resources/tools/testbed-setup/ansible/roles/docker/tasks/ubuntu_bionic.yaml
+++ b/resources/tools/testbed-setup/ansible/roles/docker/tasks/ubuntu_bionic.yaml
@@ -1,33 +1,27 @@
---
# file: roles/docker/tasks/ubuntu_bionic.yaml
-- name: Docker repository - Dependencies
+- name: Inst - Dependencies
apt:
name:
- - 'apt-transport-https'
- - 'ca-certificates'
- - 'software-properties-common'
- state: 'present'
+ - "apt-transport-https"
+ - "ca-certificates"
+ - "gpg-agent"
+ - "software-properties-common"
+ state: "present"
cache_valid_time: 3600
install_recommends: False
- tags: install-docker
+ tags: docker-inst-dependencies
-- name: Docker repository - Add an Apt signing key
+- name: Conf - Add APT Key
apt_key:
- url: 'https://download.docker.com/linux/ubuntu/gpg'
- state: 'present'
- tags: install-docker
+ url: "{{ docker_apt_key }}"
+ state: "{{ docker_apt_key_state }}"
+ tags: docker-conf-apt
-- name: Docker repository - Install APT repository
+- name: Conf - Install APT Repository
apt_repository:
- repo: '{{ docker_apt_repository }}'
- state: '{{ docker_apt_repository_state }}'
+ repo: "{{ docker_apt_repository }}"
+ state: "{{ docker_apt_repository_state }}"
update_cache: True
- tags: install-docker
-
-- name: Install Docker
- apt:
- name: 'docker-{{ docker_edition }}={{ docker_apt_package }}'
- state: '{{ docker_apt_package_state }}'
- force: True
- tags: install-docker
+ tags: docker-conf-apt