Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
language: python
dist: focal
python: "3.9"
python: "3.8"
services:
- docker

Expand All @@ -26,7 +26,8 @@ script:
- shellcheck ./.travis/*.sh

after_script:
- ./.travis/do-tests.sh
- cd ..
- ./ansible-ovhbastion/.travis/do-tests.sh

after_success:
- ./.travis/version.sh
Expand Down
16 changes: 8 additions & 8 deletions .travis/do-tests.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/bin/bash
DOCKER_CONTAINER_NAME="${DOCKER_CONTAINER_NAME:-ansible-test}"
DOCKER_BUILD_NAME="${1:-testct}"
DOCKER_INVENTORY_FILE="${DOCKER_INVENTORY_FILE:-local_docker}"
DOCKER_INVENTORY_FILE="${DOCKER_INVENTORY_FILE:-docker_local}"
DOCKER_PLAYBOOK_FILE="${DOCKER_PLAYBOOK_FILE:-docker-playbook.yml}"
DOCKERFILE_PATH="tests/Dockerfile"
INVENTORY_PATH="tests/${DOCKER_INVENTORY_FILE}"
PLAYBOOK_PATH="tests/${DOCKER_PLAYBOOK_FILE}"
ROLE_DIR="/etc/ansible/roles/ansible-ovhbastion"
TEST_FILES_DIR="ansible-ovhbastion/tests"
DOCKERFILE_PATH="${TEST_FILES_DIR}/"
INVENTORY_PATH="${TEST_FILES_DIR}/${DOCKER_INVENTORY_FILE}"
PLAYBOOK_OLD_PATH="${TEST_FILES_DIR}/${DOCKER_PLAYBOOK_FILE}"
PLAYBOOK_PATH="${DOCKER_PLAYBOOK_FILE}"

# TRAVIS_PULL_REQUEST is false when the source of the pipeline is NOT a pull request
# if the source of the pipeline is a not a pull request (i.e., main branch),
Expand All @@ -19,10 +20,9 @@ fi
# Init a virtual environment
docker build "${DOCKERFILE_PATH}" -t "${DOCKER_BUILD_NAME}"
docker run -ti --privileged --name "${DOCKER_CONTAINER_NAME}" -d -P "${DOCKER_BUILD_NAME}"

# Run ansible role against environment
rm -rf .git
sudo mkdir -p "${ROLE_DIR}"
sudo cp -r "${TRAVIS_BUILD_DIR}/*" "${ROLE_DIR}/"
cp "${PLAYBOOK_OLD_PATH}" .
if [[ -f "${PLAYBOOK_PATH}" ]]; then
ansible-playbook -i "${INVENTORY_PATH}" "${PLAYBOOK_PATH}" -vvv
else
Expand Down
2 changes: 1 addition & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
name:
- python-pip
- python-setuptools
when: ansible_facts['python_version'] is version('3', '<=')
when: ansible_facts['python_version'] is version('3', '<')

- name: install python3 pip
apt:
Expand Down
2 changes: 1 addition & 1 deletion tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM ubuntu:20.04

RUN apt-get update && apt-get install -y openssh-server sudo python unzip
RUN mkdir /var/run/sshd
RUN echo 'root:$password' | chpasswd
RUN echo 'root:sshtestpw' | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config

EXPOSE 22
Expand Down
10 changes: 6 additions & 4 deletions tests/docker-playbook.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
- hosts: local
become: true
roles:
- ansible-ovhbastion
- hosts: local
become: true
vars:
ansible_python_interpreter: /usr/bin/python3
roles:
- ansible-ovhbastion
File renamed without changes.