Skip to content

Instantly share code, notes, and snippets.

@waja
Last active November 17, 2023 16:10
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save waja/c53996e1062ac2e6da06a6d842ee82cd to your computer and use it in GitHub Desktop.
Save waja/c53996e1062ac2e6da06a6d842ee82cd to your computer and use it in GitHub Desktop.
Ansible molecule Gitlab CI
# See https://gitlab.com/richardskumat/ansible-role-client-debian-role/-/blob/master/.gitlab-ci.yml
image: qwe1/dind-ansible-molecule:latest
variables:
# DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
# https://gitlab.com/gitlab-org/gitlab-ce/issues/64959
# 19.03 had some breaking changes compared to 18.09
DOCKER_TLS_CERTDIR: ""
services:
- docker:dind
stages:
- test
before_script:
- docker info
- ansible --version
- molecule --version
test_d10:
stage: test
tags:
- ansible
variables:
MOLECULE_DISTRO: "geerlingguy/docker-debian10-ansible:testing"
script:
- cd roles/common
- molecule test
# need to setup a Matrix (https://docs.gitlab.com/ee/ci/yaml/#parallel-matrix-jobs)
#test_d8:
# stage: test
# tags:
# - ansible
# variables:
# MOLECULE_DISTRO: "geerlingguy/docker-debian8-ansible:testing"
# script:
# - cd roles/common
# - molecule test
#test_d9:
# stage: test
# tags:
# - ansible
# variables:
# MOLECULE_DISTRO: "geerlingguy/docker-debian9-ansible:testing"
# script:
# - cd roles/common
# - molecule test
---
# See https://github.com/ContinuousSecurityTooling/ansible-role-secure-docker/blob/master/molecule/default/molecule.yml
# See https://gitlab.com/richardskumat/ansible-role-client-debian-role/-/blob/master/molecule/default/molecule.yml
dependency:
name: galaxy
driver:
name: docker
lint: |
set -e
yamllint -c molecule/default/yaml-lint.yml .
ansible-lint -c molecule/default/ansible-lint.yml
platforms:
- name: instance
image: "${MOLECULE_DISTRO:-qwe1/docker-debian:10-nonfree}"
command: ${MOLECULE_DOCKER_COMMAND:-""}
# capabilities:
# - SYS_ADMIN # Needed to change hostname via playbook
# see https://github.com/ansible/ansible/issues/19681#issuecomment-450425779
# - AUDIT_CONTROL
# - AUDIT_READ
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
# groups:
# - testgroup
provisioner:
name: ansible
log: true
config_options:
defaults:
local_tmp: /tmp/.ansible-$USER/tmp
remote_tmp: /tmp/.ansible-$USER/tmp
connection_options:
ansible_user: root
inventory:
links:
group_vars: ../../../../inventories/production/group_vars/
host_vars: ../../../../inventories/production/host_vars/
playbooks:
converge: playbook.yml
options:
vvv: true
scenario:
name: default
@waja
Copy link
Author

waja commented Mar 13, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment