Skip to content

Instantly share code, notes, and snippets.

View yuuichi-fujioka's full-sized avatar

yuuichi fujioka yuuichi-fujioka

View GitHub Profile
@yuuichi-fujioka
yuuichi-fujioka / simple_with_statement.py
Created August 19, 2014 00:08
very simple way to implementation of with statement
from contextlib import contextmanager
@contextmanager
def wrapper():
print 'enter'
yield
print 'exit'
def main():
@yuuichi-fujioka
yuuichi-fujioka / local.conf
Last active January 21, 2016 05:29
my local.conf and local.sh
[[local|localrc]]
ADMIN_PASSWORD=openstack
MYSQL_PASSWORD=stackdb
RABBIT_PASSWORD=stackqueue
SERVICE_PASSWORD=$ADMIN_PASSWORD
HOST_IP=$(ip addr show dev br-eth0 | awk '/ inet / { print $2 }' | head -1 | sed 's#/.*##g')
SERVICE_TOKEN=tokentoken
RECLONE=yes
DEST=/opt/stack/
SERVICE_DIR=${DEST}/status
@yuuichi-fujioka
yuuichi-fujioka / auto selection with debconf.sh
Created July 17, 2014 02:05
auto selection with debconf at apt-get install
#!/bin/bash
sudo apt-get install debconf-utils -y
sudo debconf-get-selections | grep ${PACKAGE_NAME} > ${PACKAGE_NAME}.preseed
sudo debconf-set-selections ${PACKAGE_NAME}.preseed
@yuuichi-fujioka
yuuichi-fujioka / create ubuntu base image.sh
Created July 17, 2014 01:02
create ubuntu base image
#!/bin/bash
SUITE=${1:trusty}
sudo debootstrap ${SUITE} ${SUITE}
sed "s/suite/${SUITE}/g" sources.list | sudo tee ${SUITE}/etc/apt/sources.list
sudo tar -C ${SUITE} -c . | sudo docker import - ${SUITE}
@yuuichi-fujioka
yuuichi-fujioka / hostname
Created July 14, 2014 06:45
enforce hsotname by inventory
---
- name: set hostname
hostname: name={{inventory_hostname}}
- name: set hostname to hosts
lineinfile: dest=/etc/hosts regexp='.*127.0.1.1.*' line='127.0.1.1 {{inventory_hostname}}' state=present
@yuuichi-fujioka
yuuichi-fujioka / make.sh
Created July 9, 2014 08:22
create qcow image with base image
#!/bin/bash
qemu-img create -b ${base_img_file_path} -f qcow2 ${new_img_file_path}
@yuuichi-fujioka
yuuichi-fujioka / from cdrom.sh
Created July 9, 2014 08:13
install ubuntu to kvm with virt-isntall
#!/bin/bash
wget http://releases.ubuntu.com/14.04/ubuntu-14.04-server-amd64.iso -O ubuntu-14.04-server-amd64.iso
qemu-img create -f qcow2 ubuntu.img 40G
virt-install --name ubuntu --ram=1024 --vcpus=1 --os-type=linux --hvm --virt-type=kvm --disk=ubuntu.img,format=qcow2,bus=virtio --cdrom=ubuntu-14.04-server-amd64.iso --vnc --vncport=5911 --vnclisten=127.0.0.1 --network=bridge:brex --keymap=ja
@yuuichi-fujioka
yuuichi-fujioka / make template dir.sh
Created July 9, 2014 07:39
this makes skelton for ansible
#!/bin/bash
mkdir host_vars
mkdir group_vars
mkdir -p roles/common/files
mkdir -p roles/common/handlers
mkdir -p roles/common/meta
mkdir -p roles/common/tasks
mkdir -p roles/common/templates
@yuuichi-fujioka
yuuichi-fujioka / install.sh
Created July 9, 2014 02:45
install go and setting environment
#!/bin/bash
sudo apt-get insltall golang
mkdir ~/go
export GOPATH=~/go
export PATH=${PATH};${GOPATH}/bin
@yuuichi-fujioka
yuuichi-fujioka / login.sh
Created July 9, 2014 02:43
login to docker container with nsinit
#!/bin/bash
# this requires super user
cd /var/lib/docker/execdriver/native/${container_id}
nsinit exec /bin/bash