Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ansible linting under Ansible 2.x #757

Merged
merged 1 commit into from Feb 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -16,5 +16,7 @@ matrix:
env: TOXENV=flake8
- python: 2.7
env: TOXENV=ansible-lint
- python: 2.7
env: TOXENV=ansible-lint ANSIBLE_VERSION='>=2.0'

sudo: false
10 changes: 10 additions & 0 deletions README.md
Expand Up @@ -134,3 +134,13 @@ To run an upgrade of an existing openstack-ansible installation:
Please note the following behaviors that are **destructive**:
* `/etc/rpc_deploy` will be deprecated and the file structure moved to
`/etc/openstack_deploy`.

# Linting

If you would like to lint against a version of ansible that is not the
default, set the `ANSIBLE_VERSION` environment variable to the proper pip
version specification:

```
ANSIBLE_VERSION='>=2.0' tox -e ansible-lint
```
5 changes: 1 addition & 4 deletions scripts/linting-ansible.sh
Expand Up @@ -21,13 +21,10 @@ if [[ -z "$VIRTUAL_ENV" ]] ; then
echo "WARNING: Not running hacking inside a virtual environment."
fi

# Put local inventory in a var so we're not polluting the file system too much
LOCAL_INVENTORY='[all]\nlocalhost ansible_connection=local'

pushd rpcd/playbooks/
echo "Running ansible-playbook syntax check"
# Do a basic syntax check on all playbooks and roles.
ansible-playbook -i <(echo $LOCAL_INVENTORY) --syntax-check *.yml --list-tasks
ansible-playbook -i 'localhost,' --syntax-check *.yml --list-tasks
# Perform a lint check on all playbooks and roles.
ansible-lint --version
echo "Running ansible-lint"
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Expand Up @@ -4,10 +4,11 @@ skipsdist = True
envlist = flake8,ansible-lint

[testenv]
passenv = ANSIBLE_VERSION
basepython = python2.7
deps =
ansible>=1.9.1,<2.0.0
-rtest-requirements.txt
ansible{env:ANSIBLE_VERSION:>=1.9.1,<2.0.0}

[testenv:flake8]
commands =
Expand Down