---
language: python
python: "2.7"

env:
  - SITE=test.yml

before_install:
  # Make sure everything's up to date.
  - sudo apt-get update -qq

install:
  # Install Ansible.
  - pip install ansible

  # Add ansible.cfg to pick up roles path.
  - "{ echo '[defaults]'; echo 'roles_path = ../'; } >> ansible.cfg"

script:
  # Check the role/playbook's syntax.
  - ansible-playbook -i tests/inventory tests/test.yml --syntax-check
  # Run the role/playbook with ansible-playbook.
  - ansible-playbook -i tests/inventory tests/test.yml --sudo
  # Run the role/playbook again, checking to make sure it's idempotent.
  - >
    ansible-playbook -i tests/inventory tests/test.yml --sudo
    | grep -q 'changed=0.*failed=0'
    && (echo 'Idempotence test: pass' && exit 0)
    || (echo 'Idempotence test: fail' && exit 1)
  # Ideally we should add a functional test of some sort here

---
language: python
python: "2.7"
cache: pip

env:
  - SITE=test.yml

before_install:
  # Make sure everything's up to date.
  - sudo apt-get update -qq

install:
  # Install Ansible.
  - pip install ansible ansible-lint

  # Add ansible.cfg to pick up roles path.
  - "{ echo '[defaults]'; echo 'roles_path = ../'; } >> ansible.cfg"

script:
  # Check the role/playbook's syntax.
  - ansible-playbook -i tests/inventory tests/test.yml --syntax-check
  # Complete a lint check on the playbook/role
  - ansible-lint tests/test.yml
  # Run the role/playbook with ansible-playbook.
  - ansible-playbook -i tests/inventory tests/test.yml --sudo
  # Run the role/playbook again, checking to make sure it's idempotent.
  - >
    ansible-playbook -i tests/inventory tests/test.yml --sudo
    | grep -q 'changed=0.*failed=0'
    && (echo 'Idempotence test: pass' && exit 0)
    || (echo 'Idempotence test: fail' && exit 1)
  # Ideally we should add a functional test of some sort here

Add Travic pip caching and ansible lint test
Add Travic pip caching and ansible lint test
