summaryrefslogtreecommitdiffstats
path: root/ansible
diff options
context:
space:
mode:
authorJan Benedikt <j.benedikt@partner.samsung.com>2020-03-17 11:31:39 +0100
committerJan Benedikt <j.benedikt@partner.samsung.com>2020-04-23 16:14:54 +0200
commitb6455eefd0709cf8bac67a254c2e5a7913370eb3 (patch)
tree35989b038c1b6291e98c596b3254247de8f01094 /ansible
parent4fd6349133f5ffbd96795dedd4549ef0612c9ab5 (diff)
Adding Ubuntu support in Ansible - docker role
Extending ansible playbooks of ubuntu support. Creating new test with Ubuntu image for Molecule in docker role. Issue-ID: OOM-1671 Signed-off-by: Jan Benedikt <j.benedikt@partner.samsung.com> Change-Id: I4786dcd4b2de3f8d189db3b619c3d75315302506
Diffstat (limited to 'ansible')
-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: