Skip to content

Instantly share code, notes, and snippets.

View clcollins's full-sized avatar

Christopher Collins clcollins

View GitHub Profile
#!/bin/bash
# Script that can be run to cleanup a Jenkins slave server that's used to build docker images
# Tries to account for the fact that a job might be running and using images & containers
# Adjust the Docker command to match your environment (esp. the $HOST hostname)
# TLS included as script it designed to be run from the master
DOCKER_TLS_VERIFY=1
DOCKER="docker --tlscacert /ca.pem --tlscert /cert.pem --tlskey /key.pem -H ${HOST}"
RUNNING_CONTAINERS=$($DOCKER ps -q)
@clcollins
clcollins / format-disks.yml
Last active September 16, 2016 16:30
Snippet of Ansible Playbook for auto-expanding a volume group based on disks on the server
---
## Snippet of Ansible Playbook for auto-expanding a volume group based on disks on the server
### Format Partitions ###
- name: Format | find disks
command: find /dev -regex "/dev/sd[b-z]" -exec echo "{}," \;
register: extra_pvs
- name: Format | expand vg if extra_pvs exist
# defaultpv comes last, because extra_pvs are formatted to have a comma on the end
@clcollins
clcollins / dkr.sh
Created February 23, 2017 15:25
Wrapper to handle Docker TLS connection flags
#!/bin/bash
usage () {
cat << EOF
Usage: dkr HOSTNAME
dkr HOSTNAME COMMAND [arg...]
A wrapper around Docker to simplify using TLS connections
In the first form, will watch the output of "docker ps" and "docker images" on the remote host.

Docker Build Pipeline with Remote Asset Compilation

Problem

To compile code into assets/artifacts and build a Docker image with the resulting code only, and no compilers/devel packages/libraries, you have a workflow like so:

@clcollins
clcollins / git-prompt
Created April 18, 2017 16:35
Git Prompt for bash
# Found on Reddit - cannot now remember where
# Modified by Chris Collins to suite his tastes
git rev-parse 2> /dev/null && git status --porcelain -b | awk '
/^## / {
branch = $0;
sub(/^## /, "", branch);
sub(/\.\.\..*/, "", branch);
if ($0 ~ /ahead /) {
@clcollins
clcollins / enable_namespaces_el7.sh
Last active April 25, 2017 20:41
Enable User Namespaces for Docker on EL7-based Systems
#!/bin/bash
# Super basic script outlining the steps to enable namespace support for Docker on
# el7-base systems (CentOS7, RHEL7, etc).
set -e
echo "Enabling user_namespace kernel option..."
grubby --args="user_namespace.enable=1" --update-kernel="$(grubby --default-kernel)"
@clcollins
clcollins / ansible_error.txt
Created May 22, 2017 20:22
Error & Inventory file from OpenShift Origin Ansible install
fatal: [10.0.11.227]: FAILED! => {"changed": false, "cmd": ["/usr/local/bin/oc", "create", "-n", "openshift", "-f", "/etc/origin/examples/image-streams/image-streams-centos7.json"], "delta": "0:00:00.648866", "end": "2017-05-22 19:52:08.699647", "failed": true, "failed_when_result": true, "rc": 1, "start": "2017-05-22 19:52:08.050781", "stderr": "Unable to connect to the server: dial tcp: lookup <HOSTNAME OF ELB FOR MASTERS> on 10.0.0.2:53: no such host", "stderr_lines": ["Unable to connect to the server: dial tcp: lookup <HOSTNAME OF ELB FOR MASTERS> on 10.0.0.2:53: no such host"], "stdout": "", "stdout_lines": []}
@clcollins
clcollins / chnserver_deploy.sh
Last active May 15, 2019 15:16
CHN-Server Docker Compose file
#!/bin/bash
set -o errexit
set -o nounset
main () {
local mongo_repo="https://github.com/CommunityHoneyNetwork/mongodb.git"
local mongo_commit="c95ab34ba961b4e29b9973a7eec2d0133f15be5c"
local redis_repo="https://github.com/CommunityHoneyNetwork/redis.git"
local redis_commit="b7ad930a8d7a0296fb2fadf955e2a58c3aee73e4"
@clcollins
clcollins / Dockerfile
Last active May 15, 2019 15:17
mkdocs in a Docker container
FROM ubuntu:17.10
MAINTAINER Chris Collins <[email protected]>
ENV PKGS python python-pip nginx runit
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y $PKGS
RUN pip install mkdocs
ADD default /etc/nginx/sites-enabled/default
@clcollins
clcollins / docker-compose.yml
Created September 12, 2017 22:39
Docker Compose-based, single-server deploy of CHN Server
version: '2'
services:
mongodb:
build:
dockerfile: ./Dockerfile-centos
context: https://github.com/CommunityHoneyNetwork/mongodb.git
image: mongodb:centos
ports:
- "127.0.0.1:27017:27017"
volumes: