Skip to content
Snippets Groups Projects
Commit 07a35cdd authored by nimrod's avatar nimrod
Browse files

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

# Conflicts:
#	.travis.yml
#	molecule.yml
#	tasks/main.yml
#	tests/playbook.yml
#	tests/requirements.yml
parents e5b9b935 7f5d2c7b
No related branches found
No related tags found
No related merge requests found
...@@ -9,3 +9,4 @@ __pycache__ ...@@ -9,3 +9,4 @@ __pycache__
.vagrant/ .vagrant/
*.log *.log
*.retry *.retry
.tox
- 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,27 +9,15 @@ ...@@ -9,27 +9,15 @@
- 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: 0fadd691465b97db8992cfc66650f630e433324b 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/willthames/ansible-lint - repo: https://github.com/willthames/ansible-lint
sha: 959ab0f525e9abb19cf75f34381015cf33695f61 sha: v3.4.12
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
description: Check up-to-date Python requirements
language: system
entry: piprot --quiet --outdated tests/requirements.txt
files: requirements.txt
always_run: true
...@@ -2,23 +2,41 @@ ...@@ -2,23 +2,41 @@
language: python language: python
python: "2.7" python: "2.7"
dist: trusty dist: trusty
sudo: false sudo: True
group: beta group: beta
services: [docker] env:
global:
- VBOX_MEMORY=2048
matrix:
- TOXENV=pre-commit
- TOXENV=openbsd60
- TOXENV=xenial
- TOXENV=trusty
- TOXENV=precise
- &stretch TOXENV=stretch
- &jessie TOXENV=jessie
- TOXENV=wheezy
matrix:
fast_finish: True
allow_failures:
- env: *stretch
- env: *jessie
cache: cache:
- pip - pip
- directories: - directories:
- $HOME/.pre-commit - $HOME/.pre-commit
install: install:
- pip install -r tests/requirements.txt | cat - sudo apt-get update
- ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles - sudo apt-get install -y linux-headers-$(uname -r) virtualbox
- molecule dependency - 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 tox-travis | cat
script: script:
- pre-commit run --all-files - travis_wait 45 tox
- travis_wait 45 molecule test --driver docker
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
...@@ -34,22 +34,9 @@ See :code:`tests/playbook.yml`. ...@@ -34,22 +34,9 @@ See :code:`tests/playbook.yml`.
Testing Testing
------- -------
Testing requires Python 2.7 and either Docker or Vagrant and Virtualbox. Testing requires Python 2.7, Tox, Vagrant and Virtualbox. To test simply run
Install the Python dependencies, dependent roles and roles required for :code:`tox`. `Pre-commit <http://pre-commit.com/>`_ is also setup for this
testing: 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
------- -------
......
...@@ -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
...@@ -13,53 +17,35 @@ vagrant: ...@@ -13,53 +17,35 @@ vagrant:
providers: providers:
- name: virtualbox - name: virtualbox
type: virtualbox type: virtualbox
options:
cpus: 1
platforms: platforms:
- name: openbsd - name: openbsd60
box: kaorimatz/openbsd-6.0-amd64 box: fnichol/openbsd-6.0-i386
- name: jessie
box: debian/jessie64
- name: xenial - name: xenial
box: ubuntu/xenial64 box: ubuntu/xenial32
- name: trusty - name: trusty
box: ubuntu/trusty64 box: ubuntu/trusty32
- name: precise
box: hashicorp/precise32
- name: stretch
box: remram/debian-9-i386
- name: jessie
box: deb/jessie-i386
- name: wheezy
box: bmorg/debian-wheezy-i386
instances: instances:
- name: nginx - name: nginx
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' - 'vbguest.auto_update = false if Vagrant.has_plugin?("vbguest")'
- 'landrush.enabled = false' - 'landrush.enabled = false if Vagrant.has_plugin?("landrush")'
- 'landrush_ip.override = false' - 'landrush_ip.override = false if Vagrant.has_plugin?("landrush")'
- |
docker: vm.provider "virtualbox" do |v|
containers: v.customize "pre-boot", ["modifyvm", :id, "--hwvirtex", "off"]
- name: nginx-xenial v.memory = ENV['VBOX_MEMORY'].to_i if ENV.has_key?('VBOX_MEMORY')
image: ubuntu end
image_version: xenial
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
- name: nginx-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
- name: nginx-trusty
image: ubuntu-upstart
image_version: trusty
command: /sbin/init
environment:
DEBIAN_FRONTEND: noninteractive
container: docker
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
that: that:
- ansible_os_family in aliases_file - ansible_os_family in aliases_file
- ansible_os_family in nginx_user - ansible_os_family in nginx_user
- ansible_pkg_mgr != 'openbsd_pkg' or ansible_distribution_release in nginx_openbsd_pkg - ansible_pkg_mgr != 'openbsd_pkg' or ansible_distribution_version in nginx_openbsd_pkg
- name: Check if dhparams file exists - name: Check if dhparams file exists
stat: stat:
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
- name: pkg install - name: pkg install
when: ansible_pkg_mgr == 'openbsd_pkg' when: ansible_pkg_mgr == 'openbsd_pkg'
openbsd_pkg: openbsd_pkg:
name: '{{ nginx_openbsd_pkg[ansible_distribution_release] }}' name: '{{ nginx_openbsd_pkg[ansible_distribution_version] }}'
state: present state: present
- name: Alias emails to root - name: Alias emails to root
......
--- ---
- hosts: nginx-openbsd - hosts: nginx-openbsd*
gather_facts: false gather_facts: false
roles: [openbsd-bootstrap] roles:
- openbsd-bootstrap
- role: users
users: []
users_use_sudo: True
users_lock_root_ssh: False
- hosts: nginx-xenial - hosts: [nginx-xenial, nginx-wheezy]
gather_facts: false gather_facts: false
roles: [debian-bootstrap] roles:
- debian-bootstrap
- role: users
users: []
users_use_sudo: True
users_lock_root_ssh: False
- hosts: all - hosts: all
serial: 1
roles: roles:
- ca-store - ca-store
- nginx - nginx
......
ansible==2.2.0.0 ansible==2.3.0.0
testinfra==1.4.5 testinfra==1.5.5
molecule==1.17.0 molecule==1.23.2
ansible-lint==3.4.9 ansible-lint==3.4.12
pre-commit==0.9.4
piprot==0.9.7
python-vagrant==0.5.14 python-vagrant==0.5.14
docker-py==1.10.6 netaddr==0.7.19
netaddr==0.7.18 passlib==1.7.1
passlib==1.7.0 bcrypt==3.1.3
bcrypt==3.1.2
...@@ -5,3 +5,5 @@ ...@@ -5,3 +5,5 @@
name: debian-bootstrap name: debian-bootstrap
- src: adarnimrod.ca-store - src: adarnimrod.ca-store
name: ca-store name: ca-store
- src: adarnimrod.users
name: users
tox.ini 0 → 100644
[tox]
skip_install = True
skipsdist = True
envlist = openbsd60,xenial,trusty,precise,stretch,jessie,wheezy
[testenv]
envdir = {toxinidir}/.tox
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]
envdir = {toxinidir}/.tox
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment