Skip to content

Instantly share code, notes, and snippets.

View theqwan-chengwei's full-sized avatar

Cheng Wei theqwan-chengwei

  • The Qwan 得寬科技
  • Taipei, Taiwan
View GitHub Profile
$client = Client::getInstance();
$client->getEngine()->setPath('/bin/phantomjs');
// $client->getEngine()->addOption('--ignore-ssl-errors=true');
$client->getEngine()->addOption('--ssl-protocol=any');
$client->getEngine()->addOption('--web-security=false');
$client->getEngine()->debug(true);
$request = $client->getMessageFactory()->createCaptureRequest();
$response = $client->getMessageFactory()->createResponse();
#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
# remove unused volumes:
# find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(

DevOps Taiwan Meetup #3 CM 大亂鬥 - 下半場活動

本次的 DevOps Meetup #3,主題是「配置管理工具大亂鬥」,因此我們事先準備了幾種 CM Tools 常見的使用情境及對 CM Tools 的疑問。

讓各位講者可以事先針對這些情境與題目準備內容,屆時在 Meetup 現場可以與大家分享。

再次感謝各位講者的配合,謝謝大家!

講者座談 Q & A 預備題目

#!/bin/bash
# 請在所有的 apt-get install 後面補上 -y
sudo apt-get install software-properties-common
if ! grep -q "ansible/ansible" /etc/apt/sources.list /etc/apt/sources.list.d/*; then
sudo apt-add-repository -y ppa:ansible/ansible
fi
#!/bin/bash
start-container
docker exec dev_server apt-get install php-xdebug
docker run -d -i --name addgit ci/ansible:dev sh
docker exec addgit apk update
docker exec addgit apk add git
docker commit addgit ci/ansible:dev
docker rm -f addgit
#!/bin/bash
DATA=$(curl -X POST https://api.dropboxapi.com/2/users/get_space_usage --header 'Authorization: Bearer your_token' --header 'Content-Type: application/json' --data 'null')
used=$(echo $DATA | sed 's/}//g' | awk '{ print $2}' | sed 's/,//g')
allocated=$(echo $DATA | sed 's/}//g' | awk '{ print $7}')
echo "total space(bytes):" $allocated
echo " used space(bytes):" $used
@theqwan-chengwei
theqwan-chengwei / Vagrantfile
Last active June 20, 2016 17:55
vagrantfile bento/ubuntu-14.04 ans provision.sh
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "bento/ubuntu-14.04"
config.vm.provision "shell" do |s|
s.path = "provision.sh"
end
@theqwan-chengwei
theqwan-chengwei / fix_CVE-2016–3714_imagetragick.yml
Last active June 6, 2016 08:51
ImageTragick (CVE-2016–3714). use ansible update policy file to disable the vulnerable ImageMagick coders.
---
- name: check ImageMagick folder exists
stat:
path: /etc/ImageMagick
register: check_imagemagick_folder_exists
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- name: apt-get update imagemagick 8:6.7.7.10-6ubuntu3.1
apt: pkg={{ item }} state=latest
@theqwan-chengwei
theqwan-chengwei / check_docker_container.sh
Created February 26, 2016 04:24 — forked from ekristen/check_docker_container.sh
Bash Script for Nagios to Check Status of Docker Container
#!/bin/bash
# Author: Erik Kristensen
# Email: erik@erikkristensen.com
# License: MIT
# Nagios Usage: check_nrpe!check_docker_container!_container_id_
# Usage: ./check_docker_container.sh _container_id_
#
# The script checks if a container is running.
# OK - running
@theqwan-chengwei
theqwan-chengwei / fix_CVE-2016-0777_0778.yml
Last active January 15, 2016 04:20
透過 ansible 修復 CVE-2016-0777、CVE-2016-0778,執行的時候記得輸入自己的 host
#ansible 1.9.2
- name: fix_CVE-2016-0777_0778
hosts: "{{ myhost }}"
sudo: True
sudo_user: root
tasks:
- name: upgrade openssh
apt: name={{ item }} state=latest update_cache=yes
with_items: