diff --git a/.gitignore b/.gitignore index e1cf205905d93c46016f27f9e4df6a1da11cfd86..966ef052e8cb1dfe9ab17eff54ee874231f5dbb0 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ __pycache__ .vagrant/ *.log *.retry +.tox diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 233bc80d8f4b0a2ed98f97e33a6269dd6ef0d882..bd9a4d714377ea51d2cd14419ae059cc9307b5d5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ - 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,27 +9,15 @@ - 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/willthames/ansible-lint - sha: 959ab0f525e9abb19cf75f34381015cf33695f61 + sha: v3.4.12 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 diff --git a/.travis.yml b/.travis.yml index abc583a44f62a169059b177cabed55bfe3ab9183..1bbb982e61430523a834ed3fa375eb2e946f63c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,23 +2,36 @@ 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=pre-commit + - TOXENV=trusty + - &jessie TOXENV=jessie +matrix: + fast_finish: True + allow_failures: + - env: *jessie cache: - pip - directories: - $HOME/.pre-commit 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 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 diff --git a/README.rst b/README.rst index f1701408a0642fc6e309c965c8d4f16bfd177ecd..f68da9fcbf936be67c76bdcfcf57e0aaaf94eff4 100644 --- a/README.rst +++ b/README.rst @@ -29,22 +29,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 ------- diff --git a/ansible.cfg b/ansible.cfg index 905e3c64897217cd1b88acde10920ae04c7c6011..a33a906b7db5fa209df2b129eff0b36c42f661d9 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -2,7 +2,7 @@ library = library host_key_checking = False retry_files_enabled = False -roles_path = .molecule/roles:.molecule/../roles:../:../../ +roles_path = ../:.molecule/roles:.molecule/../roles:../../ command_warnings = True deprecation_warnings = True callback_whitelist = profile_tasks diff --git a/meta/main.yml b/meta/main.yml index 429f203d938d5c13624b3c8ac4477f1b5189afbe..cd5fba290c910c95ab6350f662130bff1cb5163e 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -3,7 +3,7 @@ galaxy_info: description: Provision PHP application server using Apache with mod-php company: Shore technologies license: MIT - min_ansible_version: 2.0 + min_ansible_version: 2.3 platforms: - name: Ubuntu versions: @@ -13,7 +13,7 @@ galaxy_info: - jessie galaxy_tags: [ PHP ] dependencies: - - name: adarnimrod.php5 + - name: php5 src: adarnimrod.php5 - - name: adarnimrod.apache + - name: apache src: adarnimrod.apache diff --git a/molecule.yml b/molecule.yml index 71505be0fa12e1322d9243e436db68866e636b97..423bc098e2bc819d17f2e920de810ce3bfe8ff31 100644 --- a/molecule.yml +++ b/molecule.yml @@ -5,6 +5,10 @@ ansible: diff: True config_file: ../ansible.cfg +molecule: + ignore_paths: + - .tox + dependency: name: galaxy requirements_file: tests/requirements.yml @@ -13,34 +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: remram/debian-9-i386 - name: jessie - box: debian/jessie64 + box: deb/jessie-i386 + - name: wheezy + box: bmorg/debian-wheezy-i386 instances: - name: mod-php 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: mod-php-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: mod-php-trusty - image: ubuntu - image_version: trusty - environment: - DEBIAN_FRONTEND: noninteractive + - '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 diff --git a/tests/playbook.yml b/tests/playbook.yml index f40b4dbd76bbbabf7140d0667881173fa31579df..9fe1fc8d5df65795391b08d6d64ef89f59473439 100644 --- a/tests/playbook.yml +++ b/tests/playbook.yml @@ -1,4 +1,22 @@ --- +- hosts: mod-php-openbsd* + gather_facts: false + roles: + - openbsd-bootstrap + - role: users + users: [] + users_use_sudo: True + users_lock_root_ssh: False + +- hosts: [mod-php-xenial, mod-php-wheezy] + gather_facts: false + roles: + - debian-bootstrap + - role: users + users: [] + users_use_sudo: True + users_lock_root_ssh: False + - hosts: all strategy: free roles: [mod-php] diff --git a/tests/requirements.txt b/tests/requirements.txt index 70cb7661036d9bd7cc73bfb2f4f8978edce7ea4c..1186c3351818f7fb407e6f449cebeea81093c7a9 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,8 +1,8 @@ -ansible==2.2.0.0 -testinfra==1.4.5 -molecule==1.16.1 -ansible-lint==3.4.8 -pre-commit==0.9.4 -piprot==0.9.7 +ansible==2.3.0.0 +testinfra==1.5.5 +molecule==1.24.0 +ansible-lint==3.4.12 python-vagrant==0.5.14 -docker-py==1.10.6 +netaddr==0.7.19 +passlib==1.7.1 +bcrypt==3.1.3 diff --git a/tests/requirements.yml b/tests/requirements.yml index cdc294cd67e8c5b70eed5178580e6edde25e10bb..fccce7574df98d466c55a309273c4060174e8cb0 100644 --- a/tests/requirements.yml +++ b/tests/requirements.yml @@ -1,3 +1,7 @@ --- - src: adarnimrod.openbsd-bootstrap + name: openbsd-bootstrap - src: adarnimrod.debian-bootstrap + name: debian-bootstrap +- src: adarnimrod.users + name: users diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..d6c30800493a9e1098e14488677798b5b7acf0ab --- /dev/null +++ b/tox.ini @@ -0,0 +1,26 @@ +[tox] +skip_install = True +skipsdist = True +envlist = trusty,jessie + +[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