Skip to content

Instantly share code, notes, and snippets.

View maprangzth's full-sized avatar

Komsan Kamsamur maprangzth

View GitHub Profile
@maprangzth
maprangzth / Instructions.md
Created January 15, 2017 15:32 — forked from shreyaskarnik/Instructions.md
Route Docker Logs to ELK Stack
  • With Docker 1.8.0 shipped new log-driver for GELF via UDP, this means that the logs from Docker Container(s) can be shipped directly to the ELK stack for further analysis.
  • This tutorial will illustrate how to use the GELF log-driver with Docker engine.
  • Step 1: Setup ELK Stack:
    • docker run -d --name es elasticsearch
    • docker run -d --name logstash --link es:elasticsearch logstash -v /tmp/logstash.conf:/config-dir/logstash.conf logstash logstash -f /config-dir/logstash.conf
    • Note the config for Logstash can be found at this link
    • docker run --link es:elasticsearch -d kibana
  • Once the ELK stack is up now let's fire up our nginx container which ships its logs to ELK stack.
  • LOGSTASH_ADDRESS=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' logstash)
  • `docker run -d --net=host --log-driver=gelf --log-opt gelf-address=u

Keybase proof

I hereby claim:

  • I am maprangzth on github.
  • I am maprangzth (https://keybase.io/maprangzth) on keybase.
  • I have a public key whose fingerprint is A940 FB57 AC2F E67B 07AB 155F 3BA1 A46D EFE3 96DB

To claim this, I am signing this object:

@maprangzth
maprangzth / ping.conf
Created January 17, 2017 06:13 — forked from chrismeller/ping.conf
My PHP-FPM pool.d config files.
[www]
ping.path = /ping
@maprangzth
maprangzth / Linux Static IP
Created January 23, 2017 04:40 — forked from fernandoaleman/Linux Static IP
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@maprangzth
maprangzth / nginxproxy.md
Created May 2, 2017 15:13 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

เตรียม Server สำหรับทำ Lab Ansible ด้วย LXC

LXC คืออะไร?

LXC - Linux Containers
LXC (Linux Containers) คือ Operating-system-level virtualization หรือเป็นที่รู้จักกันในชื่อ container นั่นเอง ซึ่งมนุษย์ในสายงาน IT ทุกวันนี้(น่าจะ)รู้จักกันดีอยู่แล้ว จริงๆ LXC มีมานานมากแล้วแต่ไม่เป็นที่รู้จักเพราะการใช้งานของมันจะยุ่งยากพอควร (เมื่อเทียบกับ Docker) แต่ไม่ใช่อุปสรรคสำหรับการเรียนรู้ครับ ^^

Container คืออะไร?

อาจารย์ชาญวิทย์ อธิบายไว้แบบนี้:

Container จะเรียกให้ถูกต้องเป๊ะ ๆ คือ Software Container เป็น concept ของการสร้างสภาพแวดล้อมเฉพาะให้ซอฟต์แวร์ทำงานได้โดยไม่กวนกับซอฟต์แวร์ตัวอื่นบนระบบปฏิบัติการเดียวกัน โดยเฉพาะ Sun หรือ Linux นั้นมี concept ของ Container มานานแล้ว เช่น ใน Linux มี LXC เป็นตัวจัดการ container มาตั้งแต่ปี 2007-2008 หรือใน Solaris ก็มีระบบแบบเดียวกันมาตั้งแต่ปี 2004-2005

Ansible พื้นฐานที่ (ตัวเอง) ควรรู้ Ep.04 - Ad-hoc Command

Ansible Logo

ในการใช้งาน Ansible หลักๆ จะมีอยู่ Command-line ให้ใช้งานอยู่สองแบบ คือ

  1. /usr/bin/ansible
  2. /usr/bin/ansible-playbook

ซึ่งใน Ep. นี้เรามาโฟกัสกันที่ /usr/bin/ansible กันก่อน ส่วน /usr/bin/ansible-playbook คืออะไรเดี๋ยวจะมาว่ากันใน Ep. ถัดไป

@maprangzth
maprangzth / create_ansible_user.yml
Created October 22, 2017 06:32
Simple Playbooks for Create User
---
- name: Create Ansible user
hosts: all
remote_user: root
vars:
user_name: maprangzth
user_keys: https://github.com/maprangzth.keys
tasks:
- name: Ensure ansible user exists
user:
@maprangzth
maprangzth / install_apache.yml
Created October 22, 2017 08:38
Simple Playbooks for Install Apache Web Server
---
- name: Install Apache Web Server
hosts: web-server
remote_user: maprangzth
tasks:
- name: Ensure httpd package is latest
yum:
name: httpd
state: latest
notify: Start and enabled httpd service
@maprangzth
maprangzth / install_reqiured_package.yml
Created October 22, 2017 08:39
Simple Playbooks for Explanation About Loop
---
- name: Install reqiured packages
hosts: all
remote_user: maprangzth
tasks:
- name: Ensure EPEL Repo is present
yum:
name: epel-release
state: present
become: True