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 a working travis config #108

Merged
merged 12 commits into from
Jul 15, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
exclude_paths: []
parseable: true
quiet: true
skip_list: [305]
use_default_rules: true
verbosity: 1
128 changes: 55 additions & 73 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,73 +1,55 @@
---
sudo: required
dist: trusty
language: generic

env:
- >
dist=debian
ver=8
container_id=$(mktemp)
init=/sbin/init
run_opts="--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
EXTRA_VARS='{"role_name":"Rocket.Chat.Ansible","host_name":"localhost"}'
VERBOSE='-vv'
- >
dist=centos
ver=7
container_id=$(mktemp)
init=/usr/lib/systemd/systemd
run_opts="--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
EXTRA_VARS='{"role_name":"Rocket.Chat.Ansible","host_name":"localhost"}'
VERBOSE='-vv'
- >
dist=ubuntu
ver=14.04
container_id=$(mktemp)
init=/sbin/init
run_opts=""
EXTRA_VARS='{"role_name":"Rocket.Chat.Ansible","host_name":"localhost"}'
VERBOSE='-vv'
- >
dist=ubuntu
ver=16.04
container_id=$(mktemp)
init=/sbin/init
run_opts="--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
EXTRA_VARS='{"role_name":"Rocket.Chat.Ansible","host_name":"localhost"}'
VERBOSE='-vv'
- >
dist=ubuntu
ver=18.04
container_id=$(mktemp)
init=/sbin/init
run_opts="--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
EXTRA_VARS='{"role_name":"Rocket.Chat.Ansible","host_name":"localhost"}'
VERBOSE='-vv'

services:
- docker

before_install:
- sudo docker build --rm=true
--file="tests/Dockerfile.${dist}-${ver}"
--tag="${dist}:ansible" tests

before_script:
- sudo docker run --detach
--volume="${PWD}:/etc/ansible/roles/Rocket.Chat.Ansible:ro"
${run_opts} "${dist}:ansible" "${init}" > "${container_id}"

script:
- sudo docker exec --tty "$(cat ${container_id})"
env TERM=xterm ansible-playbook
/etc/ansible/roles/Rocket.Chat.Ansible/tests/provision.yml
--extra-vars="$EXTRA_VARS" $VERBOSE --syntax-check

- sudo docker exec --tty "$(cat ${container_id})"
env TERM=xterm ansible-playbook
/etc/ansible/roles/Rocket.Chat.Ansible/tests/provision.yml
--extra-vars="$EXTRA_VARS" $VERBOSE

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
---
os: linux
dist: xenial

env:
- distribution: centos
version: 7

- distribution: debian
version: stretch

# - distribution: debian
# version: jessie

- distribution: debian
version: buster

- distribution: ubuntu
version: 14.04

- distribution: ubuntu
version: 16.04

- distribution: ubuntu
version: 18.04

# - distribution: ubuntu
# version: 20.04

services:
- docker

before_install:
- 'sudo docker pull ${distribution}:${version}'
- 'sudo docker build --no-cache --rm --file=tests/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests'

script:
- container_id=$(mktemp)
- 'sudo docker run --detach --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro --volume="${PWD}":/etc/ansible/roles/Rocket.Chat.Ansible:ro ${distribution}-${version}:ansible > "${container_id}"'

# Verify Ansible is available in the container.
- sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible --version

# Verify Ansible Scripts
- 'sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/Rocket.Chat.Ansible/tests/travis.yml --syntax-check'
- 'sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/Rocket.Chat.Ansible/tests/travis.yml'
# - >
# sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/Rocket.Chat.Ansible/tests/travis.yml
# | grep -q 'changed=0.*failed=0'
# && (echo 'Idempotence test: pass' && exit 0)
# || (echo 'Idempotence test: fail' && exit 1)
- 'sudo docker rm -f "$(cat ${container_id})"'

#notifications:
# webhooks: https://galaxy.ansible.com/api/v1/notifications/
6 changes: 6 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
extends: default
rules:
line-length:
max: 120
level: warning
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Features
Supported Platforms
-------------------
### Debian
- Jessie (8)
- Strect (9)
- Buster (10)

### Ubuntu
- Bionic Beaver: 18.04 LTS
Expand Down
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ galaxy_info:
- bionic
- name: Debian
versions:
- jessie
- buster
- stretch
galaxy_tags:
- cloud
Expand Down
10 changes: 5 additions & 5 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
- name: "Configure /etc/hosts"
lineinfile:
dest: /etc/hosts
line: "{{ item.line }}"
line: "{{ item.line }}"
regexp: "{{ item.regexp }}"
insertafter: "{{ item.insertafter | default(omit) }}"
insertbefore: "{{ item.insertbefore | default(omit) }}"
Expand All @@ -99,10 +99,6 @@
backrefs: no
register: hosts_change_result

- import_tasks: mongodb.yml
when: (rocket_chat_include_mongodb | bool)
tags: mongodb

- name: Redefine rocket_chat_dep_packages to add dist specific packages if needed
set_fact:
rocket_chat_dep_packages:
Expand All @@ -127,6 +123,10 @@
retries: 2
tags: packages

- import_tasks: mongodb.yml
when: (rocket_chat_include_mongodb | bool)
tags: mongodb

- import_tasks: nodejs.yml
tags: nodejs

Expand Down
44 changes: 22 additions & 22 deletions tests/Dockerfile.centos-7
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
FROM centos:7
# Install systemd -- See https://hub.docker.com/_/centos/
RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs
RUN yum -y update; \
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*; \
rm -f /etc/systemd/system/*.wants/*; \
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*; \
rm -f /lib/systemd/system/anaconda.target.wants/*;
# Install Ansible
RUN yum -y install epel-release
RUN yum -y install git ansible sudo
RUN yum clean all
# Disable requiretty
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
# Install Ansible inventory file
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
VOLUME [ "/sys/fs/cgroup" ]
CMD ["/usr/sbin/init"]
FROM centos:7
# Install systemd -- See https://hub.docker.com/_/centos/
RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs
RUN yum -y update; \
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*; \
rm -f /etc/systemd/system/*.wants/*; \
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*; \
rm -f /lib/systemd/system/anaconda.target.wants/*;
# Install Ansible
RUN yum -y install epel-release
RUN yum -y install git ansible sudo
RUN yum clean all
# Disable requiretty
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
# Install Ansible inventory file
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
VOLUME [ "/sys/fs/cgroup" ]
CMD ["/usr/sbin/init"]
49 changes: 0 additions & 49 deletions tests/Dockerfile.debian-8

This file was deleted.

20 changes: 20 additions & 0 deletions tests/Dockerfile.debian-buster
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM debian:buster

ENV pip_packages "ansible cryptography"

# Install dependencies.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
sudo systemd systemd-sysv \
build-essential wget libffi-dev libssl-dev \
python3-pip python3-dev python3-setuptools python3-wheel \
&& rm -rf /var/lib/apt/lists/* \
&& rm -Rf /usr/share/doc && rm -Rf /usr/share/man \
&& apt-get clean

# Install Ansible via pip.
RUN pip3 install $pip_packages

RUN mkdir -p /etc/ansible && echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts

ENTRYPOINT ["/bin/systemd"]
18 changes: 18 additions & 0 deletions tests/Dockerfile.debian-jessie
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM debian:jessie

RUN apt-get update -y && apt-get install -y --no-install-recommends \
software-properties-common \
build-essential \
libffi-dev \
libssl-dev \
python-dev \
python-pip \
python-yaml \
git \
&& rm -rf /var/lib/apt/lists/*

RUN pip install cryptography --upgrade && pip install ansible

RUN mkdir -p /etc/ansible && echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts

ENTRYPOINT ["/sbin/init"]
19 changes: 19 additions & 0 deletions tests/Dockerfile.debian-stretch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM debian:stretch

RUN apt-get update -y && apt-get install -y --no-install-recommends \
software-properties-common \
build-essential \
libffi-dev \
libssl-dev \
python-dev \
python-pip \
python-yaml \
git \
systemd \
&& rm -rf /var/lib/apt/lists/*

RUN pip install --upgrade setuptools && pip install ansible

RUN mkdir -p /etc/ansible && echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts

ENTRYPOINT ["/bin/systemd"]
22 changes: 11 additions & 11 deletions tests/Dockerfile.ubuntu-14.04
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Dockerfile.ubuntu
FROM ubuntu-upstart:14.04
# Install Ansible
#RUN mv /sbin/initctl.distrib /sbin/initctl
RUN apt-get update -y
RUN apt-get install -y python-software-properties software-properties-common
RUN add-apt-repository -y ppa:ansible/ansible
RUN apt-get update -y
RUN apt-get install -y ansible git-core
# Install Ansible inventory file
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
# Dockerfile.ubuntu
FROM ubuntu-upstart:14.04
# Install Ansible
#RUN mv /sbin/initctl.distrib /sbin/initctl
RUN apt-get update -y
RUN apt-get install -y python-software-properties software-properties-common
RUN add-apt-repository -y ppa:ansible/ansible
RUN apt-get update -y
RUN apt-get install -y ansible git-core
# Install Ansible inventory file
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
Loading