Skip to content
Snippets Groups Projects
Commit 02cc8a74 authored by nimrod's avatar nimrod
Browse files

Merge branch 'master' of /home/nimrod/Documents/Shore/Ansible/example

# Conflicts:
#	.pre-commit-config.yaml
#	meta/main.yml
#	molecule.yml
#	tasks/main.yml
#	tests/playbook.yml
#	tests/requirements.yml
parents 5366d12a 2d8e8d93
No related branches found
No related tags found
No related merge requests found
......@@ -9,3 +9,4 @@ __pycache__
.vagrant/
*.log
*.retry
.tox
- repo: https://github.com/pre-commit/pre-commit-hooks
sha: 7539d8bd1a00a3c1bfd34cdb606d3a6372e83469
sha: v0.7.1
hooks:
- id: check-added-large-files
- id: check-json
......@@ -9,36 +9,20 @@
- id: flake8
- id: check-symlinks
- repo: https://github.com/adarnimrod/ansible-pre-commit.git
sha: 0fadd691465b97db8992cfc66650f630e433324b
sha: v0.6.0
hooks:
- id: ansible-syntax-check
always_run: true
files: tests/playbook.yml
args:
- tests/playbook.yml
- repo: https://github.com/adarnimrod/shell-pre-commit
sha: v0.1.0
hooks:
- id: shell-lint
- repo: https://github.com/willthames/ansible-lint
sha: 959ab0f525e9abb19cf75f34381015cf33695f61
sha: v3.4.13
hooks:
- id: ansible-lint
always_run: true
files: tests/playbook.yml
args:
- tests/playbook.yml
- repo: local
- repo: https://github.com/adarnimrod/python-pre-commit.git
sha: v0.2.0
hooks:
- id: piprot
name: piprot
description: Check up-to-date Python requirements
language: system
entry: piprot --quiet --outdated tests/requirements.txt
files: requirements.txt
always_run: true
- repo: https://www.shore.co.il/git/shell-pre-commit/
sha: 604fe77b53d3514d5ad0f66764c7783850bb6e98
- repo: https://github.com/adarnimrod/shell-pre-commit
sha: v0.5.4
hooks:
- id: shell-lint
files: files/backup.sh
- id: shellcheck
......@@ -2,23 +2,49 @@
language: python
python: "2.7"
dist: trusty
sudo: false
sudo: True
group: beta
services: [docker]
env:
global:
- VBOX_MEMORY=2048
- VBOX_HWVIRTEX=off
matrix:
- TOXENV=openbsd60
- TOXENV=xenial
- TOXENV=trusty
- TOXENV=precise
- &stretch TOXENV=stretch
- &jessie TOXENV=jessie
- TOXENV=wheezy
cache:
- pip
- directories:
- $HOME/.pre-commit
- $HOME/.vagrant.d/boxes
install:
- pip install -r tests/requirements.txt | cat
- ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles
- molecule dependency
- sudo apt-get update
- sudo apt-get install -y linux-headers-$(uname -r) virtualbox
- wget https://releases.hashicorp.com/vagrant/1.9.1/vagrant_1.9.1_x86_64.deb
- sudo dpkg -i vagrant_1.9.1_x86_64.deb
- &pip_install pip install tox-travis | cat
script:
- pre-commit run --all-files
- molecule test --driver docker
- travis_wait 45 tox
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
email: false
on_failure: never
matrix:
fast_finish: True
allow_failures:
- env: *stretch
include:
- env:
TOXENV: pre-commit
install:
- *pip_install
sudo: False
/*
Jenkins pipeline for testing an Ansible role.
Required software on the agent:
- Python 2.7.
- Tox.
- Vagrant.
- Virtualbox.
*/
pipeline {
agent any
environment {
VBOX_HWVIRTEX = off
}
stages {
stage('install') {
steps {
sh 'git submodule update --init --recursive'
}
}
stage('test') {
steps {
parallel (
'pre-commit': {
sh 'tox -e pre-commit'
}
'molecule': {
sh 'tox'
}
)
}
}
}
post {
success {
sh 'tox -e import'
}
}
}
......@@ -33,22 +33,9 @@ See :code:`tests/playbook.yml`.
Testing
-------
Testing requires Python 2.7 and either Docker or Vagrant and Virtualbox.
Install the Python dependencies, dependent roles and roles required for
testing:
.. code:: shell
pip install -r tests/requirements.txt
ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles
molecule dependency
To run the full test suite:
.. code:: shell
pre-commit run --all-files
molecule test --platform all
Testing requires Python 2.7, Tox, Vagrant and Virtualbox. To test simply run
:code:`tox`. `Pre-commit <http://pre-commit.com/>`_ is also setup for this
project.
License
-------
......
......@@ -4,16 +4,17 @@ galaxy_info:
description: Provision a MySQL server
company: Shore technologies
license: MIT
min_ansible_version: 2.0
min_ansible_version: 2.3
platforms:
- name: Debian
versions:
- wheezy
- jessie
- stretch
- name: Ubuntu
versions:
- precise
- trusty
- xenial
- trusty
- precise
- name: Debian
versions:
- stretch
- jessie
- wheezy
galaxy_tags: [mysql]
dependencies: []
......@@ -5,6 +5,10 @@ ansible:
diff: True
config_file: ../ansible.cfg
molecule:
ignore_paths:
- .tox
dependency:
name: galaxy
requirements_file: tests/requirements.yml
......@@ -13,29 +17,35 @@ vagrant:
providers:
- name: virtualbox
type: virtualbox
options:
cpus: 1
platforms:
- name: openbsd60
box: fnichol/openbsd-6.0-i386
- name: xenial
box: ubuntu/xenial32
- name: trusty
box: ubuntu/trusty32
- name: precise
box: hashicorp/precise32
- name: stretch
box: koalephant/debian9-i386
- name: jessie
box: debian/jessie64
box: deb/jessie-i386
- name: wheezy
box: bmorg/debian-wheezy-i386
instances:
- name: mysql
options:
append_platform_to_hostname: yes
raw_config_args:
- 'vm.boot_timeout = 600'
- 'vm.synced_folder ".", "/vagrant", disabled: true'
- 'vbguest.auto_update = false'
- 'landrush.enabled = false'
- 'landrush_ip.override = false'
docker:
containers:
- name: mysql-jessie
image: debian
image_version: jessie
command: /sbin/init
privileged: True
volume_mounts:
- /sys/fs/cgroup:/sys/fs/cgroup
- /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
environment:
DEBIAN_FRONTEND: noninteractive
container: docker
- 'vbguest.auto_update = false if Vagrant.has_plugin?("vbguest")'
- 'landrush.enabled = false if Vagrant.has_plugin?("landrush")'
- 'landrush_ip.override = false if Vagrant.has_plugin?("landrush")'
- |
vm.provider "virtualbox" do |v|
v.customize "pre-boot", ["modifyvm", :id, "--hwvirtex", ENV['VBOX_HWVIRTEX']] if ENV.has_key?('VBOX_HWVIRTEX')
v.memory = ENV['VBOX_MEMORY'].to_i if ENV.has_key?('VBOX_MEMORY')
end
---
- hosts: mysql-openbsd*
gather_facts: false
roles:
- openbsd-bootstrap
- role: users
users: []
users_use_sudo: True
users_lock_root_ssh: False
- hosts: [mysql-xenial, mysql-wheezy]
gather_facts: false
roles:
- debian-bootstrap
- role: users
users: []
users_use_sudo: True
users_lock_root_ssh: False
- hosts: all
strategy: free
roles:
- role: ca-store
- role: mysql
......
ansible==2.2.0.0
testinfra==1.4.5
molecule==1.17.0
ansible-lint==3.4.9
pre-commit==0.9.4
piprot==0.9.7
python-vagrant==0.5.14
docker-py==1.10.6
netaddr==0.7.18
passlib==1.7.0
bcrypt==3.1.2
ansible==2.3.1.0
testinfra==1.6.4
molecule==1.25.0
ansible-lint==3.4.13
python-vagrant==0.5.15
netaddr==0.7.19
passlib==1.7.1
bcrypt==3.1.3
......@@ -3,5 +3,7 @@
name: openbsd-bootstrap
- src: adarnimrod.debian-bootstrap
name: debian-bootstrap
- src: adarnimrod.users
name: users
- src: adarnimrod.ca-store
name: ca-store
......@@ -3,10 +3,10 @@ from testinfra.utils.ansible_runner import AnsibleRunner
testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all')
def test_example(Command):
assert Command('uname').rc == 0
def test_example(host):
assert host.run('uname').rc == 0
def test_root(Command, Sudo):
with Sudo():
assert Command('whoami').stdout.strip() == 'root'
def test_root(host):
with host.sudo():
assert host.run('whoami').stdout.strip() == 'root'
tox.ini 0 → 100644
[tox]
skip_install = True
skipsdist = True
envlist = openbsd60,xenial,trusty,precise,stretch,jessie,wheezy
[testenv]
envdir = {toxinidir}/.tox/molecule
deps = -rtests/requirements.txt
passenv = HOME VBOX* ANSIBLE_*
whitelist_externals =
sh
commands =
sh -c "ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles"
molecule test --platform {envname}
[testenv:pre-commit]
deps =
-rtests/requirements.txt
pre-commit
passenv = HOME VBOX* ANSIBLE_*
whitelist_externals =
sh
commands =
sh -c "ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles"
molecule dependency
pre-commit run --all-files
[testenv:import]
envdir = {toxinidir}/.tox/molecule
deps = -rtests/requirements.txt
commands = ansible-galaxy import -v
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment