Browse Source
Add Molecule to Docker role (#5129)
* Add Molecule for container-engine/docker
* Add bootstrap-os to Molecule prepare stage
pull/5953/head
aharrisson
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
61 additions and
0 deletions
-
roles/container-engine/docker/molecule/default/molecule.yml
-
roles/container-engine/docker/molecule/default/playbook.yml
-
roles/container-engine/docker/molecule/default/prepare.yml
-
roles/container-engine/docker/molecule/default/tests/test_default.py
|
|
@ -0,0 +1,29 @@ |
|
|
|
--- |
|
|
|
driver: |
|
|
|
name: vagrant |
|
|
|
provider: |
|
|
|
name: libvirt |
|
|
|
lint: |
|
|
|
name: yamllint |
|
|
|
options: |
|
|
|
config-file: ../../../.yamllint |
|
|
|
platforms: |
|
|
|
- name: kubespray-docker |
|
|
|
box: generic/ubuntu1804 |
|
|
|
cpus: 2 |
|
|
|
memory: 1024 |
|
|
|
provisioner: |
|
|
|
name: ansible |
|
|
|
env: |
|
|
|
ANSIBLE_ROLES_PATH: ../../../../ |
|
|
|
config_options: |
|
|
|
defaults: |
|
|
|
callback_whitelist: profile_tasks |
|
|
|
lint: |
|
|
|
name: ansible-lint |
|
|
|
options: |
|
|
|
c: ../../../.ansible-lint |
|
|
|
verifier: |
|
|
|
name: testinfra |
|
|
|
lint: |
|
|
|
name: flake8 |
|
|
@ -0,0 +1,7 @@ |
|
|
|
--- |
|
|
|
- name: Converge |
|
|
|
hosts: all |
|
|
|
become: true |
|
|
|
roles: |
|
|
|
- role: kubespray-defaults |
|
|
|
- role: docker |
|
|
@ -0,0 +1,6 @@ |
|
|
|
--- |
|
|
|
- name: Prepare |
|
|
|
hosts: all |
|
|
|
gather_facts: False |
|
|
|
roles: |
|
|
|
- role: bootstrap-os |
|
|
@ -0,0 +1,19 @@ |
|
|
|
import os |
|
|
|
|
|
|
|
import testinfra.utils.ansible_runner |
|
|
|
|
|
|
|
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( |
|
|
|
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') |
|
|
|
|
|
|
|
|
|
|
|
def test_docker_service(host): |
|
|
|
docker = host.service("docker") |
|
|
|
assert docker.is_running |
|
|
|
assert docker.is_enabled |
|
|
|
|
|
|
|
|
|
|
|
def test_docker_run(host): |
|
|
|
with host.sudo(): |
|
|
|
cmd = host.command("docker run hello-world") |
|
|
|
assert cmd.rc == 0 |
|
|
|
assert "Hello from Docker!" in cmd.stdout |