[tox]
minversion = 2.0
skipsdist = True
envlist = linters

[testenv]
usedevelop = True
install_command =
    pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
#deps =
#    -r{toxinidir}/test-requirements.txt
commands =
    /usr/bin/find . -type f -name "*.pyc" -delete
passenv =
    HOME
    http_proxy
    HTTP_PROXY
    https_proxy
    HTTPS_PROXY
    ANSIBLE_FORCE_COLOR
    no_proxy
    NO_PROXY
whitelist_externals =
    bash
    rm
    sudo
setenv =
    VIRTUAL_ENV={envdir}

[testenv:ansible]
#deps =
#    {[testenv]deps}
setenv =
    {[testenv]setenv}
    ANSIBLE_HOST_KEY_CHECKING = False
    ANSIBLE_SSH_CONTROL_PATH = /tmp/%%h-%%r
    ANSIBLE_ACTION_PLUGINS = {homedir}/.ansible/roles/plugins/action
    ANSIBLE_CALLBACK_PLUGINS = {homedir}/.ansible/roles/plugins/callback
    ANSIBLE_FILTER_PLUGINS = {homedir}/.ansible/roles/plugins/filter
    ANSIBLE_LOOKUP_PLUGINS = {homedir}/.ansible/roles/plugins/lookup
    ANSIBLE_LIBRARY = {homedir}/.ansible/roles/plugins/library
    ANSIBLE_ROLES_PATH = {homedir}/.ansible/roles:{toxinidir}/playbooks/roles
commands =
    rm -rf {homedir}/.ansible/roles

[testenv:ansible-lint]
#deps =
#    {[testenv:ansible]deps}
setenv =
    {[testenv:ansible]setenv}
commands =
    ansible-lint -x ANSIBLE0016 {toxinidir}


[testenv:ansible-syntax]
#deps =
#    {[testenv:ansible]deps}
setenv =
    {[testenv:ansible]setenv}
commands =
    {[testenv:ansible]commands}
    ansible-playbook -i {toxinidir}/tests/inventory \
                     --syntax-check \
                     --list-tasks \
                     -e "rolename={toxinidir}" \
                     {toxinidir}/tests/test.yml

[testenv:venv]
commands = {posargs}
