summaryrefslogtreecommitdiffstats
path: root/ansible/roles
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-04-30 09:26:19 +0000
committerGerrit Code Review <gerrit@onap.org>2020-04-30 09:26:19 +0000
commite085fdfa7b61ef742dfe5da0fdc8b72c7eff571c (patch)
treebecc453f45387addc27c040f0f6af5d8b255a693 /ansible/roles
parent76be40b0c8651b276ceed260936c6a8cf103520d (diff)
parentb6455eefd0709cf8bac67a254c2e5a7913370eb3 (diff)
Merge "Adding Ubuntu support in Ansible - docker role"
Diffstat (limited to 'ansible/roles')
-rw-r--r--ansible/roles/docker/defaults/main.yml8
-rw-r--r--ansible/roles/docker/molecule/default/molecule.yml2
-rw-r--r--ansible/roles/docker/molecule/default/tests/test_default.py17
-rw-r--r--ansible/roles/docker/molecule/ubuntu/molecule.yml46
-rw-r--r--ansible/roles/docker/tasks/main.yml11
5 files changed, 66 insertions, 18 deletions
diff --git a/ansible/roles/docker/defaults/main.yml b/ansible/roles/docker/defaults/main.yml
index 1922f64b..33a86e2d 100644
--- a/ansible/roles/docker/defaults/main.yml
+++ b/ansible/roles/docker/defaults/main.yml
@@ -2,3 +2,11 @@
docker:
log_max_size: 100m
log_max_file: 3
+packages:
+ RedHat:
+ - python-docker-py
+ - python-jsonpointer
+ Debian:
+ - python3-docker
+ - python3-json-pointer
+ - iproute2
diff --git a/ansible/roles/docker/molecule/default/molecule.yml b/ansible/roles/docker/molecule/default/molecule.yml
index 1e800ee9..efa7f0ae 100644
--- a/ansible/roles/docker/molecule/default/molecule.yml
+++ b/ansible/roles/docker/molecule/default/molecule.yml
@@ -29,6 +29,8 @@ provisioner:
host_vars:
infrastructure-server:
cluster_ip: 1.2.3.4
+scenario:
+ name: default
verifier:
name: testinfra
options:
diff --git a/ansible/roles/docker/molecule/default/tests/test_default.py b/ansible/roles/docker/molecule/default/tests/test_default.py
index a8adeb65..a73572fd 100644
--- a/ansible/roles/docker/molecule/default/tests/test_default.py
+++ b/ansible/roles/docker/molecule/default/tests/test_default.py
@@ -1,5 +1,6 @@
import os
import pytest
+import json
import testinfra.utils.ansible_runner
@@ -23,13 +24,9 @@ def test_docker_daemon_file(host):
assert f.exists
assert f.user == 'root'
assert f.group == 'root'
- assert f.content_string == """{
- "log-opts": {
- "max-size": "100m",
- "max-file": "3"
- },
- "dns": [
- "1.2.3.4"
- ],
- "log-driver": "json-file"
-}"""
+ print(f.content_string)
+ json_data = json.loads(f.content_string)
+ assert json_data["log-driver"] == "json-file"
+ assert json_data["log-opts"]["max-size"] == "100m"
+ assert json_data["log-opts"]["max-file"] == "3"
+ assert json_data["dns"][0] == "1.2.3.4"
diff --git a/ansible/roles/docker/molecule/ubuntu/molecule.yml b/ansible/roles/docker/molecule/ubuntu/molecule.yml
new file mode 100644
index 00000000..8325ffb3
--- /dev/null
+++ b/ansible/roles/docker/molecule/ubuntu/molecule.yml
@@ -0,0 +1,46 @@
+---
+dependency:
+ name: galaxy
+driver:
+ name: docker
+lint:
+ name: yamllint
+platforms:
+ - name: infrastructure-server
+ image: molecule-${PREBUILD_PLATFORM_DISTRO:-ubuntu}:${PREBUILD_DISTRO_VERSION:-18.04}
+ pre_build_image: true
+ privileged: true
+ command: ${MOLECULE_DOCKER_COMMAND:-""}
+ groups:
+ - infrastructure
+ networks:
+ - name: docker_install
+ purge_networks: true
+ volumes:
+ - /var/lib/docker
+provisioner:
+ name: ansible
+ lint:
+ name: ansible-lint
+ playbooks:
+ prepare: ../default/prepare.yml
+ converge: ../default/playbook.yml
+ env:
+ ANSIBLE_ROLES_PATH: ../../../../test/roles
+ ANSIBLE_LIBRARY: ../../../../library
+ inventory:
+ host_vars:
+ infrastructure-server:
+ cluster_ip: 1.2.3.4
+ remote_tmp: $HOME/.ansible/tmp
+scenario:
+ name: ubuntu
+verifier:
+ name: testinfra
+ options:
+ verbose: true
+ lint:
+ name: flake8
+ options:
+ ignore: W291 # trailing whitespace
+ directory: ../default/tests/
diff --git a/ansible/roles/docker/tasks/main.yml b/ansible/roles/docker/tasks/main.yml
index cd731b11..60060826 100644
--- a/ansible/roles/docker/tasks/main.yml
+++ b/ansible/roles/docker/tasks/main.yml
@@ -6,16 +6,11 @@
notify:
- Restart Docker
-- name: Install docker python module
+- name: Install required packages
package:
- name: 'python-docker-py'
- state: present
-
-
-- name: Install python jsonpointer module
- package:
- name: 'python-jsonpointer'
+ name: "{{ item }}"
state: present
+ loop: "{{ packages[ansible_os_family] }}"
- name: Ensure /etc/docker exists
file: