Commit bbbc0591 authored by Ross McDonald's avatar Ross McDonald
Browse files

Merge pull request #11 from rossmcdonald/ross-develop

Docker Improvements
parents ca292ab8 051605d0
The MIT License (MIT)
Copyright (c) 2016 Ross McDonald
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
......@@ -17,7 +17,7 @@ influxdb_load_sample_data: no
influxdb_sample_database_name: sample_database
influxdb_sample_measurement_name: random_ints
influxdb_bind_hostname: "{{ ansible_hostname }}"
influxdb_bind_hostname: ''
influxdb_install_python_client: no
......
......@@ -13,4 +13,4 @@ RUN mkdir -p $PROJECT_DIR
WORKDIR $PROJECT_DIR
VOLUME $PROJECT_DIR
ENTRYPOINT [ "ansible-playbook", "-c", "local", "-e", "is_docker=true", "-i", "localhost," ]
ENTRYPOINT [ "ansible-playbook", "-M", "/root", "-c", "local", "-e", "is_docker=true", "-i", "localhost," ]
......@@ -13,4 +13,4 @@ RUN mkdir -p $PROJECT_DIR
WORKDIR $PROJECT_DIR
VOLUME $PROJECT_DIR
ENTRYPOINT [ "ansible-playbook", "-c", "local", "-e", "is_docker=true", "-i", "localhost," ]
ENTRYPOINT [ "ansible-playbook", "-M", "/root", "-c", "local", "-e", "is_docker=true", "-i", "localhost," ]
FROM opensuse:13.2
MAINTAINER Ross McDonald <mcdonaldrossc+docker@gmail.com>
RUN zypper -n in ansible
ENV PROJECT_DIR /root
RUN mkdir -p $PROJECT_DIR
WORKDIR $PROJECT_DIR
VOLUME $PROJECT_DIR
ENTRYPOINT [ "ansible-playbook", "-M", "/root", "-c", "local", "-e", "is_docker=true", "-i", "localhost," ]
FROM opensuse:leap
MAINTAINER Ross McDonald <mcdonaldrossc+docker@gmail.com>
RUN zypper -n in ansible
ENV PROJECT_DIR /root
RUN mkdir -p $PROJECT_DIR
WORKDIR $PROJECT_DIR
VOLUME $PROJECT_DIR
ENTRYPOINT [ "ansible-playbook", "-M", "/root", "-c", "local", "-e", "is_docker=true", "-i", "localhost," ]
......@@ -15,4 +15,4 @@ RUN mkdir -p $PROJECT_DIR
WORKDIR $PROJECT_DIR
VOLUME $PROJECT_DIR
ENTRYPOINT [ "ansible-playbook", "-c", "local", "-e", "is_docker=true", "-i", "localhost," ]
ENTRYPOINT [ "ansible-playbook", "-M", "/root", "-c", "local", "-e", "is_docker=true", "-i", "localhost," ]
......@@ -15,4 +15,4 @@ RUN mkdir -p $PROJECT_DIR
WORKDIR $PROJECT_DIR
VOLUME $PROJECT_DIR
ENTRYPOINT [ "ansible-playbook", "-c", "local", "-e", "is_docker=true", "-i", "localhost," ]
ENTRYPOINT [ "ansible-playbook", "-M", "/root", "-c", "local", "-e", "is_docker=true", "-i", "localhost," ]
......@@ -15,4 +15,4 @@ RUN mkdir -p $PROJECT_DIR
WORKDIR $PROJECT_DIR
VOLUME $PROJECT_DIR
ENTRYPOINT [ "ansible-playbook", "-c", "local", "-e", "is_docker=true", "-i", "localhost," ]
ENTRYPOINT [ "ansible-playbook", "-M", "/root", "-c", "local", "-e", "is_docker=true", "-i", "localhost," ]
......@@ -7,10 +7,14 @@ function err {
}
echo "Building CentOS containers..."
docker build -f Dockerfile_centos_6 -t ansible.influxdb.centos.6:latest . || err "Could not build CentOS 6 container"
docker build -f Dockerfile_centos_7 -t ansible.influxdb.centos.7:latest . || err "Could not build CentOS 6 container"
docker build -f Dockerfile_centos_6 -t ansible:centos6 . || err "Could not build CentOS 6 container"
docker build -f Dockerfile_centos_7 -t ansible:centos7 . || err "Could not build CentOS 6 container"
echo "Building Ubuntu containers..."
docker build -f Dockerfile_ubuntu_trusty -t ansible.influxdb.ubuntu.trusty:latest . || err "Could not build Ubuntu Trusty container"
docker build -f Dockerfile_ubuntu_wily -t ansible.influxdb.ubuntu.wily:latest . || err "Could not build Ubuntu Wily container"
docker build -f Dockerfile_ubuntu_xenial -t ansible.influxdb.ubuntu.xenial:latest . || err "Could not build Ubuntu Xenial container"
docker build -f Dockerfile_ubuntu_trusty -t ansible:ubuntu_trusty . || err "Could not build Ubuntu Trusty container"
docker build -f Dockerfile_ubuntu_wily -t ansible:ubuntu_wily . || err "Could not build Ubuntu Wily container"
docker build -f Dockerfile_ubuntu_xenial -t ansible:ubuntu_xenial . || err "Could not build Ubuntu Xenial container"
echo "Building Ubuntu containers..."
docker build -f Dockerfile_opensuse_harlequin -t ansible:opensuse_harlequin . || err "Could not build OpenSuse Harlequin container"
docker build -f Dockerfile_opensuse_leap -t ansible:opensuse_leap . || err "Could not build OpenSuse Leap container"
#!/bin/bash
function err {
echo "ERROR: $@"
exit 1
}
current_directory="$(pwd)"
# Check for Docker
which docker &>/dev/null || err "Docker is required to run Ansible playbooks."
# Validate the Docker image is available (assuming images are named)
docker_image="$1"
docker images | awk "{ print \$1 \":\" \$2 }" | grep "$1" &>/dev/null || err "Could not find Docker image: $docker_image"
# Create symlinks to previous directory (assumes the influxdb module is in a module directory)
# module_dirs="$(ls -1 ../)"
# echo "Creating symlinks for each folder in '$(dirname $current_directory)' so that Ansible can find them..."
# for dir in ${module_dirs[@]}; do
# test -h ./$dir && err "Stopping due to current directory containing symlink $dir"
# test -d ./$dir && err "Stopping due to current directory containing dir $dir"
# ln -s ../$dir $dir
# done
echo "Running in Docker: $@"
docker run \
--rm \
-v $(pwd):/root \
$@
# Remove symlinks so that current directory is clean
# echo "Clearing symlinks..."
# for dir in ${module_dirs[@]}; do rm $dir; done
exit 0
......@@ -13,23 +13,32 @@
register: influxdb_started
when: influxdb_start_service
- name: Pause to ensure InfluxDB service is up
pause:
seconds: 5
- name: Wait for InfluxDB to come up
wait_for:
host: "{{ influxdb_bind_hostname | default(\"localhost\", true) }}"
port: "{{ influxdb_http_port }}"
delay: 5
timeout: 30
when: influxdb_started.changed and influxdb_start_service
- name: Collect service status
command: service influxdb status
register: influxdb_service_status
when: influxdb_start_service
ignore_errors: yes
register: influxdb_start_attempt
- name: Run tail on log
command: tail /var/log/influxdb/influxd.log
register: influxdb_tail_output
when: influxdb_start_attempt.failed is defined and influxdb_start_attempt.failed == True
- name: Show log output
debug:
msg: "{{ influxdb_tail_output.stdout_lines }}"
when: influxdb_start_attempt.failed is defined and influxdb_start_attempt.failed == True
- name: Assert status of InfluxDB service
assert:
that:
- "influxdb_service_status.rc == 0"
when: influxdb_start_service
- "influxdb_start_attempt == 0"
when: influxdb_started.changed and influxdb_start_service and influxdb_start_attempt.failed is defined and influxdb_start_attempt.failed == True
- include: demo.yml
tags: [influxdb, demo]
when: influxdb_load_sample_data and influxdb_http_auth_enabled == "false" and influxdb_start_service
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment