This repository has been archived by the owner on Jun 12, 2020. It is now read-only.
forked from donat-b/ansible-restic
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from paulfantom/molecule2
[minor] molecule 2.x tests and support for ubuntu bionic and debian stretch
- Loading branch information
Showing
16 changed files
with
275 additions
and
53 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (C) 2018 Pawel Krupa (@paulfantom) - All Rights Reserved | ||
# Permission to copy and modify is granted under the MIT license | ||
# | ||
# Script to automatically do a couple of things: | ||
# - generate a new tag according to semver (https://semver.org/) | ||
# - generate CHANGELOG.md by using https://github.com/skywinder/github-changelog-generator | ||
# - sync CHANGELOG with GitHub releases by using https://github.com/mattbrictson/chandler | ||
# | ||
# Tags are generated by searching for a keyword in last commit message. Keywords are: | ||
# - [patch] or [fix] to bump patch number | ||
# - [minor], [feature] or [feat] to bump minor number | ||
# - [major] or [breaking change] to bump major number | ||
# All keywords MUST be surrounded with square braces. | ||
# | ||
# Script uses git mechanisms for locking, so it can be used in parallel builds | ||
# | ||
# Requirements: | ||
# - GH_TOKEN variable set with GitHub token. Access level: repo.public_repo | ||
# - docker | ||
# - git-semver python package (pip install git-semver) | ||
|
||
# Exit when latest commit is tagged | ||
[[ $(git tag --points-at) ]] && exit 0 | ||
|
||
# Some basic variables | ||
GIT_MAIL="paulfantom@gmail.com" | ||
GIT_USER="paulfantom" | ||
ORGANIZATION=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $1}') | ||
PROJECT=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $2}') | ||
GALAXY_URL="https://galaxy.ansible.com/${ORGANIZATION}/${PROJECT#ansible-}" | ||
|
||
# Git config | ||
git config --global user.email "${GIT_MAIL}" | ||
git config --global user.name "${GIT_USER}" | ||
GIT_URL=$(git config --get remote.origin.url) | ||
GIT_URL=${GIT_URL#*//} | ||
|
||
# Generate TAG | ||
GIT_TAG=none | ||
echo "Last commit message: $TRAVIS_COMMIT_MESSAGE" | ||
case "${TRAVIS_COMMIT_MESSAGE}" in | ||
*"[patch]"*|*"[fix]"* ) GIT_TAG=$(git semver --next-patch) ;; | ||
*"[minor]"*|*"[feat]"*|*"[feature]"* ) GIT_TAG=$(git semver --next-minor) ;; | ||
*"[major]"*|*"[breaking change]"* ) GIT_TAG=$(git semver --next-major) ;; | ||
*) echo "Keyword not detected. Doing nothing" ;; | ||
esac | ||
if [ "$GIT_TAG" != "none" ]; then | ||
echo "Assigning new tag: $GIT_TAG" | ||
git tag "$GIT_TAG" -a -m "Automatic tag generation for travis build no. $TRAVIS_BUILD_NUMBER" | ||
git push "https://${GH_TOKEN}:@${GIT_URL}" --tags || exit 0 | ||
fi | ||
|
||
# Generate CHANGELOG.md | ||
git checkout master | ||
git pull | ||
docker run -it --rm -v "$(pwd)":/usr/local/src/your-app ferrarimarco/github-changelog-generator \ | ||
-u "${ORGANIZATION}" -p "${PROJECT}" --token "${GH_TOKEN}" \ | ||
--release-url "${GALAXY_URL}" \ | ||
--unreleased-label "**Next release**" --no-compare-link | ||
|
||
git add CHANGELOG.md | ||
git commit -m '[ci skip] Automatic changelog update' | ||
|
||
git push "https://${GH_TOKEN}:@${GIT_URL}" || exit 0 | ||
|
||
# Sync changelog to github releases | ||
if [ "$GIT_TAG" != "none" ]; then | ||
docker run -e CHANDLER_GITHUB_API_TOKEN="${GH_TOKEN}" -v "$(pwd)":/chandler -ti whizark/chandler push "${GIT_TAG}" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
extends: default | ||
ignore: | | ||
.travis/ | ||
.travis.yml | ||
meta/ | ||
|
||
rules: | ||
braces: | ||
max-spaces-inside: 1 | ||
level: error | ||
brackets: | ||
max-spaces-inside: 1 | ||
level: error | ||
line-length: disable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
- name: Create | ||
hosts: localhost | ||
connection: local | ||
gather_facts: false | ||
no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" | ||
tasks: | ||
- name: Create molecule instance(s) | ||
docker_container: | ||
name: "{{ item.name }}" | ||
docker_host: "{{ item.docker_host | default('unix://var/run/docker.sock') }}" | ||
hostname: "{{ item.name }}" | ||
image: "{{ item.image }}" | ||
state: started | ||
recreate: false | ||
log_driver: json-file | ||
command: "{{ item.command | default(omit) }}" | ||
privileged: "{{ item.privileged | default(omit) }}" | ||
volumes: "{{ item.volumes | default(omit) }}" | ||
capabilities: "{{ item.capabilities | default(omit) }}" | ||
exposed_ports: "{{ item.exposed_ports | default(omit) }}" | ||
published_ports: "{{ item.published_ports | default(omit) }}" | ||
ulimits: "{{ item.ulimits | default(omit) }}" | ||
networks: "{{ item.networks | default(omit) }}" | ||
dns_servers: "{{ item.dns_servers | default(omit) }}" | ||
register: server | ||
with_items: "{{ molecule_yml.platforms }}" | ||
async: 7200 | ||
poll: 0 | ||
|
||
- name: Wait for instance(s) creation to complete | ||
async_status: | ||
jid: "{{ item.ansible_job_id }}" | ||
register: docker_jobs | ||
until: docker_jobs.finished | ||
retries: 300 | ||
with_items: "{{ server.results }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
- name: Destroy | ||
hosts: localhost | ||
connection: local | ||
gather_facts: false | ||
no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" | ||
tasks: | ||
- name: Destroy molecule instance(s) | ||
docker_container: | ||
name: "{{ item.name }}" | ||
docker_host: "{{ item.docker_host | default('unix://var/run/docker.sock') }}" | ||
state: absent | ||
force_kill: "{{ item.force_kill | default(true) }}" | ||
register: server | ||
with_items: "{{ molecule_yml.platforms }}" | ||
async: 7200 | ||
poll: 0 | ||
|
||
- name: Wait for instance(s) deletion to complete | ||
async_status: | ||
jid: "{{ item.ansible_job_id }}" | ||
register: docker_jobs | ||
until: docker_jobs.finished | ||
retries: 300 | ||
with_items: "{{ server.results }}" | ||
|
||
- name: Delete docker network(s) | ||
docker_network: | ||
name: "{{ item }}" | ||
docker_host: "{{ item.docker_host | default('unix://var/run/docker.sock') }}" | ||
state: absent | ||
with_items: "{{ molecule_yml.platforms | molecule_get_docker_networks }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: docker | ||
lint: | ||
name: yamllint | ||
platforms: | ||
- name: bionic | ||
image: paulfantom/ubuntu-molecule:18.04 | ||
privileged: true | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
- name: xenial | ||
image: paulfantom/ubuntu-molecule:16.04 | ||
privileged: true | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
- name: stretch | ||
image: paulfantom/debian-molecule:9 | ||
privileged: true | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
- name: jessie | ||
image: paulfantom/debian-molecule:8 | ||
privileged: true | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
- name: centos7 | ||
image: paulfantom/centos-molecule:7 | ||
privileged: true | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
- name: fedora | ||
image: paulfantom/fedora-molecule:27 | ||
privileged: true | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
provisioner: | ||
name: ansible | ||
lint: | ||
name: ansible-lint | ||
playbooks: | ||
create: create.yml | ||
prepare: prepare.yml | ||
converge: playbook.yml | ||
destroy: destroy.yml | ||
scenario: | ||
name: default | ||
verifier: | ||
name: testinfra | ||
lint: | ||
name: flake8 | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
- name: Prepare | ||
hosts: all | ||
gather_facts: false | ||
tasks: | ||
- name: Ensure cron.d exists in docker containers | ||
file: | ||
state: 'directory' | ||
path: '/etc/cron.d' |
6 changes: 4 additions & 2 deletions
6
tests/test_default.py → molecule/default/tests/test_default.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.