---
language: python
python: "2.7"

# This role needs sudo, thus we can't use the new container infrastructure
# sudo: false
sudo: required

services:
  - docker

# Install ansible
addons:
  apt:
    packages:
    - python-pip

install:
  # Install ansible
  - pip install ansible

  # Check ansible version
  - ansible --version

  # Resolve dependencies(When target role isn't installed via Ansible Galaxy, auto resolution of dependencies doesn't occur.
  - ansible-galaxy install FGtatsuro.python-requirements futurice.pip

before_script:
  - docker run -it -d --name container python:2 /bin/bash
  # Workaround: Docker connection plugin of Ansible requires that
  # Python is installed at specified path(/usr/bin/python) in the target container
  - docker exec container ln -s /usr/local/bin/python /usr/bin/python

script:
  # Basic role syntax check
  - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
  # - ansible-playbook tests/test.yml -i tests/inventory -l localhost --connection=local -vvvv
  - ansible-playbook tests/test.yml -i tests/inventory -l container --connection=docker -vvvv
  - bundle install
  # - bundle exec rake spec SPEC_TARGET=localhost
  - bundle exec rake spec SPEC_TARGET=container

after_script:
  - docker rm -f container

notifications:
  webhooks: https://galaxy.ansible.com/api/v1/notifications/

---
# https://docs.travis-ci.com/user/multi-os/
matrix:
  include:
    - os: osx
      language: generic
      env:
        - TARGET=localhost
        - CONNECTION=local
    - os: linux
      dist: trusty
      language: python
      python: 2.7
      services:
        - docker
      addons:
        apt:
          packages:
          - python-pip
      before_script:
        - docker run -it -d --name container python:2 /bin/bash
        # Workaround: Docker connection plugin of Ansible requires that
        # Python is installed at specified path(/usr/bin/python) in the target container
        - docker exec container ln -s /usr/local/bin/python /usr/bin/python
      after_script:
        - docker rm -f container
      env:
        - TARGET=container
        - CONNECTION=docker

# This role needs sudo, thus we can't use the new container infrastructure
# sudo: false
sudo: required

install:
  - pip install ansible
  # Resolve dependencies(When target role isn't installed via Ansible Galaxy, auto resolution of dependencies doesn't occur.
  - ansible-galaxy install FGtatsuro.python-requirements futurice.pip

script:
  # Basic role syntax check
  - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
  - ansible-playbook tests/test.yml -i tests/inventory -l ${TARGET} --connection=${CONNECTION} -vvvv
  - bundle install
  - bundle exec rake spec SPEC_TARGET=${TARGET}

notifications:
  webhooks: https://galaxy.ansible.com/api/v1/notifications/

Add tests for OSX on TravisCI.
Add tests for OSX on TravisCI.
