Skip to content
Snippets Groups Projects
Commit 2571354c authored by nimrod's avatar nimrod
Browse files

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

# Conflicts:
#	.gitignore
#	.pre-commit-config.yaml
#	.travis.yml
#	meta/main.yml
#	tasks/main.yml
parents acb13ae1 d1c54835
No related branches found
No related tags found
No related merge requests found
...@@ -9,5 +9,6 @@ __pycache__ ...@@ -9,5 +9,6 @@ __pycache__
.vagrant/ .vagrant/
*.log *.log
*.retry *.retry
.tox
tests/files/id_rsa tests/files/id_rsa
tests/files/id_rsa.pub tests/files/id_rsa.pub
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
sha: 7539d8bd1a00a3c1bfd34cdb606d3a6372e83469 sha: v0.7.1
hooks: hooks:
- id: check-added-large-files - id: check-added-large-files
- id: check-json - id: check-json
...@@ -9,31 +9,19 @@ ...@@ -9,31 +9,19 @@
- id: flake8 - id: flake8
- id: check-symlinks - id: check-symlinks
- repo: https://github.com/adarnimrod/ansible-pre-commit.git - repo: https://github.com/adarnimrod/ansible-pre-commit.git
sha: v0.5.0 sha: v0.6.0
hooks: hooks:
- id: ansible-syntax-check - 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 - repo: https://github.com/willthames/ansible-lint
sha: 959ab0f525e9abb19cf75f34381015cf33695f61 sha: v3.4.13
hooks: hooks:
- id: ansible-lint - id: ansible-lint
always_run: true
files: tests/playbook.yml files: tests/playbook.yml
args: - repo: https://github.com/adarnimrod/python-pre-commit.git
- tests/playbook.yml sha: v0.2.0
- repo: local
hooks: hooks:
- id: piprot - id: piprot
name: piprot - repo: https://github.com/adarnimrod/shell-pre-commit
description: Check up-to-date Python requirements sha: v0.1.0
language: system hooks:
entry: piprot --outdated tests/requirements.txt - id: shell-lint
files: requirements.txt
always_run: true
--- ---
language: python language: python
python: ["2.7", "3.5"] python: "2.7"
dist: trusty dist: trusty
sudo: True sudo: True
group: beta group: beta
env: env:
- platform: openbsd60 global:
- &openbsd59 platform=openbsd59 - VBOX_MEMORY=2048
- platform: xenial - VBOX_HWVIRTEX=off
- platform: trusty
- platform: precise
- &stretch platform=stretch
- platform: jessie
- platform: wheezy
matrix: matrix:
fast_finish: True - TOXENV=openbsd60
allow_failures: - TOXENV=xenial
- python: "3.5" - TOXENV=trusty
- env: *openbsd59 - TOXENV=precise
- env: *stretch - &stretch TOXENV=stretch
- &jessie TOXENV=jessie
- TOXENV=wheezy
cache: cache:
- pip - pip
- directories: - directories:
...@@ -29,14 +27,23 @@ install: ...@@ -29,14 +27,23 @@ install:
- sudo apt-get install -y linux-headers-$(uname -r) virtualbox - 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 - 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 - sudo dpkg -i vagrant_1.9.1_x86_64.deb
- pip install -r tests/requirements.txt | cat - &pip_install pip install tox-travis | cat
- ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles
- molecule dependency
script: script:
- pre-commit run --all-files - travis_wait 45 tox
- travis_wait 45 molecule test --platform $platform
notifications: notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/ webhooks: https://galaxy.ansible.com/api/v1/notifications/
email: false 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'
}
}
}
...@@ -30,21 +30,9 @@ See :code:`tests/playbook.yml`. ...@@ -30,21 +30,9 @@ See :code:`tests/playbook.yml`.
Testing Testing
------- -------
Testing requires Python 2.7, Vagrant and Virtualbox. Install the Python Testing requires Python 2.7, Tox, Vagrant and Virtualbox. To test simply run
dependencies, dependent roles and roles required for testing: :code:`tox`. `Pre-commit <http://pre-commit.com/>`_ is also setup for this
project.
.. 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
License License
------- -------
......
...@@ -3,18 +3,20 @@ galaxy_info: ...@@ -3,18 +3,20 @@ galaxy_info:
description: Provision gitreceive description: Provision gitreceive
company: Shore technologies company: Shore technologies
license: MIT license: MIT
min_ansible_version: 2.0 min_ansible_version: 2.3
platforms: platforms:
- name: OpenBSD - name: OpenBSD
versions: versions:
- 5.9
- 6.0 - 6.0
- name: Debian
versions:
- jessie
- name: Ubuntu - name: Ubuntu
versions: versions:
- trusty
- xenial - xenial
- trusty
- precise
- name: Debian
versions:
- stretch
- jessie
- wheezy
galaxy_tags: [ ci, git ] galaxy_tags: [ ci, git ]
dependencies: [] dependencies: []
...@@ -5,6 +5,10 @@ ansible: ...@@ -5,6 +5,10 @@ ansible:
diff: True diff: True
config_file: ../ansible.cfg config_file: ../ansible.cfg
molecule:
ignore_paths:
- .tox
dependency: dependency:
name: galaxy name: galaxy
requirements_file: tests/requirements.yml requirements_file: tests/requirements.yml
...@@ -18,8 +22,6 @@ vagrant: ...@@ -18,8 +22,6 @@ vagrant:
platforms: platforms:
- name: openbsd60 - name: openbsd60
box: fnichol/openbsd-6.0-i386 box: fnichol/openbsd-6.0-i386
- name: openbsd59
box: fnichol/openbsd-5.9-i386
- name: xenial - name: xenial
box: ubuntu/xenial32 box: ubuntu/xenial32
- name: trusty - name: trusty
...@@ -37,11 +39,13 @@ vagrant: ...@@ -37,11 +39,13 @@ vagrant:
options: options:
append_platform_to_hostname: yes append_platform_to_hostname: yes
raw_config_args: raw_config_args:
- 'vm.boot_timeout = 600'
- 'vm.synced_folder ".", "/vagrant", disabled: true' - 'vm.synced_folder ".", "/vagrant", disabled: true'
- 'vbguest.auto_update = false if Vagrant.has_plugin?("vbguest")' - 'vbguest.auto_update = false if Vagrant.has_plugin?("vbguest")'
- 'landrush.enabled = false if Vagrant.has_plugin?("landrush")' - 'landrush.enabled = false if Vagrant.has_plugin?("landrush")'
- 'landrush_ip.override = false if Vagrant.has_plugin?("landrush")' - 'landrush_ip.override = false if Vagrant.has_plugin?("landrush")'
- | - |
vm.provider "virtualbox" do |v| vm.provider "virtualbox" do |v|
v.customize "pre-boot", ["modifyvm", :id, "--hwvirtex", "off"] 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 end
ansible==2.2.1.0 ansible==2.3.0.0
testinfra==1.5.3 testinfra==1.6.3
molecule==1.19.1 molecule==1.24.0
ansible-lint==3.4.10 ansible-lint==3.4.13
pre-commit==0.12.2 python-vagrant==0.5.15
piprot==0.9.7
python-vagrant==0.5.14
netaddr==0.7.19 netaddr==0.7.19
passlib==1.7.0 passlib==1.7.1
bcrypt==3.1.2 bcrypt==3.1.3
...@@ -3,10 +3,10 @@ from testinfra.utils.ansible_runner import AnsibleRunner ...@@ -3,10 +3,10 @@ from testinfra.utils.ansible_runner import AnsibleRunner
testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all') testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all')
def test_example(Command): def test_example(host):
assert Command('uname').rc == 0 assert host.run('uname').rc == 0
def test_root(Command, Sudo): def test_root(host):
with Sudo(): with host.sudo():
assert Command('whoami').stdout.strip() == 'root' 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