-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
343 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
FROM debian:stretch | ||
MAINTAINER "cytopia" <[email protected]> | ||
|
||
RUN set -x \ | ||
RUN set -eux \ | ||
&& apt-get update \ | ||
&& apt-get install --no-install-recommends --no-install-suggests -y \ | ||
python-apt \ | ||
|
@@ -14,18 +14,18 @@ RUN set -x \ | |
&& rm -rf /var/lib/apt/lists/* \ | ||
&& apt-get purge -y --autoremove | ||
|
||
RUN set -x \ | ||
RUN set -eux \ | ||
&& pip install wheel \ | ||
&& pip install ansible | ||
|
||
# Add user with password-less sudo | ||
RUN set -x \ | ||
RUN set -eux \ | ||
&& useradd -m -s /bin/bash cytopia \ | ||
&& echo "cytopia ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/cytopia | ||
|
||
# Copy files | ||
COPY ./ /home/cytopia/ansible | ||
RUN set -x \ | ||
RUN set -eux \ | ||
&& chown -R cytopia:cytopia /home/cytopia/ansible | ||
|
||
# Switch to user | ||
|
@@ -35,12 +35,12 @@ USER cytopia | |
WORKDIR /home/cytopia/ansible | ||
|
||
# Systemd cannot be checked inside Docker, so replace it with a dummy role | ||
RUN set -x \ | ||
RUN set -eux \ | ||
&& mkdir roles/dummy \ | ||
&& sed -i'' 's/systemd-meta/dummy/g' playbook.yml | ||
|
||
# Randomize roles to install each time the container is build (each travis run) | ||
RUN set -x \ | ||
RUN set -eux \ | ||
&& ROLES_INSTALL="$( for d in $(/bin/ls roles/); do if [ -d roles/${d} ]; then echo $d; fi done | grep -vE '*-meta$' | sort -R )" \ | ||
&& ROLES_REMOVE="$( for d in $(/bin/ls roles/); do if [ -d roles/${d} ]; then echo $d; fi done | grep -vE '*-meta$' | sort -R )" \ | ||
\ | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
DIR = . | ||
FILE = Dockerfile | ||
IMAGE = cytopia/ansible-debian | ||
TAG = latest | ||
|
||
# Ansible variables | ||
VERBOSE= | ||
PROFILE=cytopia-t470p | ||
|
||
.PHONY: help build-docker test-docker-full test-docker-random test-docker-single itest-docker-full itest-docker-random itest-docker-single | ||
|
||
|
||
#-------------------------------------------------------------------------------------------------- | ||
# Default Target | ||
#-------------------------------------------------------------------------------------------------- | ||
|
||
help: | ||
@echo "################################################################################" | ||
@echo "# #" | ||
@echo "# Debian Provisioning with Ansible #" | ||
@echo "# #" | ||
@echo "################################################################################" | ||
@echo | ||
@echo | ||
@echo "------------------------------------------------------------" | ||
@echo " Run tests in Docker" | ||
@echo "------------------------------------------------------------" | ||
@echo | ||
@echo "build-docker Build the testing Docker image (happens automatically during tests)" | ||
@echo | ||
@echo "test-docker-docker-full Run a full test in a Docker (requires PROFILE)" | ||
@echo "test-docker-docker-random Run a full randomized test in a Docker (requires PROFILE)" | ||
@echo "test-docker-docker-single Run the test on a single role in a Docker (requires PROFILE and ROLE)" | ||
@echo | ||
@echo "itest-docker-docker-full Interactive version of test-docker-full (requires PROFILE)" | ||
@echo "itest-docker-docker-random Interactive version of test-docker-random (requires PROFILE)" | ||
@echo "itest-docker-docker-single Interactive version of test-docker-single (requires PROFILE and ROLE)" | ||
@echo | ||
@echo | ||
@echo "------------------------------------------------------------" | ||
@echo " Run tests in Vagrant" | ||
@echo "------------------------------------------------------------" | ||
@echo | ||
@echo "------------------------------------------------------------" | ||
@echo " Deploy your host system" | ||
@echo "------------------------------------------------------------" | ||
@echo | ||
|
||
|
||
#-------------------------------------------------------------------------------------------------- | ||
# Tests with Docker | ||
#-------------------------------------------------------------------------------------------------- | ||
|
||
build-docker: | ||
docker build -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR) | ||
|
||
# Automated tests | ||
test-docker-full: build-docker | ||
docker run --rm -e MY_HOST=$(PROFILE) -e verbose=$(VERBOSE) -t $(IMAGE) | ||
|
||
test-docker-random: build-docker | ||
docker run --rm -e MY_HOST=$(PROFILE) -e verbose=$(VERBOSE) -e random=1 -t $(IMAGE) | ||
|
||
test-docker-single: build-docker | ||
docker run --rm -e MY_HOST=$(PROFILE) -e verbose=$(VERBOSE) -e tag=$(ROLE) -t $(IMAGE) | ||
|
||
# Interactive tests | ||
# When inside the Container execute: ./run-tests.sh | ||
itest-docker-full: build-docker | ||
docker run -it --rm --entrypoint=bash -e MY_HOST=$(PROFILE) -e verbose=$(VERBOSE) -t $(IMAGE) | ||
|
||
itest-docker-random: build-docker | ||
docker run -it --rm --entrypoint=bash -e MY_HOST=$(PROFILE) -e verbose=$(VERBOSE) -e random=1 -t $(IMAGE) | ||
|
||
itest-docker-single: build-docker | ||
docker run -it --rm --entrypoint=bash -e MY_HOST=$(PROFILE) -e verbose=$(VERBOSE) -e tag=$(ROLE) -t $(IMAGE) | ||
|
||
|
||
#-------------------------------------------------------------------------------------------------- | ||
# Tests with Vagrant | ||
#-------------------------------------------------------------------------------------------------- | ||
|
||
# Test your profile with Vagrant | ||
test-vagrant: | ||
vagrant rsync | ||
PROFILE=$(PROFILE) vagrant up --provision | ||
|
||
|
||
#-------------------------------------------------------------------------------------------------- | ||
# Deploy Targets | ||
#-------------------------------------------------------------------------------------------------- | ||
|
||
# (Step 1/3) Ensure required software is present | ||
deploy-init: | ||
DEBIAN_FRONTEND=noninteractive apt-get update -qq | ||
DEBIAN_FRONTEND=noninteractive apt-get install -qq -q --no-install-recommends --no-install-suggests \ | ||
python-apt \ | ||
python-dev \ | ||
python-jmespath \ | ||
python-pip \ | ||
python-setuptools | ||
pip install wheel | ||
pip install ansible | ||
|
||
# (Step 2/3) Add new Debian sources and dist-upgrade your system | ||
deploy-dist-upgrade: | ||
ansible-playbook -i inventory playbook.yml --limit ${PROFILE} --diff -t bootstrap-system --ask-become-pass | ||
DEBIAN_FRONTEND=noninteractive apt-get update -qq | ||
DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -qq -y | ||
|
||
# (Step 3/3) Deploy your system | ||
deploy-tools: | ||
ansible-playbook -i inventory playbook.yml --limit ${PROFILE} --diff --ask-become-pass |
Oops, something went wrong.