Skip to content

Instantly share code, notes, and snippets.

View kojiwell's full-sized avatar

Koji Tanaka kojiwell

View GitHub Profile
@kojiwell
kojiwell / docker-shared-nw.md
Last active May 12, 2020 04:15
This is how to create a bridge between Docker containers and outside and create containers with the IP addresses you want to assign.

Docker - Create a Bridge and Shared Network

Sometimes I want to use Docker containers like regular VMs, creating a bridge on a Docker host, having containers on the same subnet with IP addresses I want to assign, and then logging into them via port 22. (No port forwarding, please.) So here's how to do it.

On this example, I use Vagrant and VirtualBox on my MacBook and create containers with IP addresses shown on the table below. Once you go through these steps, you should be able to extend the idea into your on-premises network.

@kojiwell
kojiwell / exclude_specific_users_from_pam_slurm.rst
Created September 25, 2015 16:07
Exclude specific users from pam_slurm restriction

CAUTION: Please test this on a test machine/VM before you actually do this on your slurm compute node.

Step 1. Make sure pam_listfile.so exists on your system. The following command is an example on Redhat 6:

ls -la /lib64/security/pam_listfile.so

Step 2. Create user list (e.g. /etc/ssh/allowed_users):

@kojiwell
kojiwell / deploy_salt.yml
Last active November 6, 2023 02:08
OpenStack Heat template example: Deploy Salt Cluster with HOT
heat_template_version: 2013-05-23
description: Deploy Salt Cluster
parameters:
keyname:
type: string
description: Key name for loggin in to instances
imagename:
type: string
@kojiwell
kojiwell / debootstrap.sh
Created August 30, 2013 18:59
Debootstrap installs Debian/Ubuntu on a directory, which is very useful for creating a custom cloud image:-)
# Install debootstrap
aptitude -y install debootstrap
# Check available version
ls /usr/share/debootstrap/scripts/
# For example, install Raring on /mnt/raring
debootstrap raring /mnt/raring
#cloud-config
#
# cloudinit-example.yaml
#
# Enable root login.
disable_root: false
# Install packages
package_update: true
packages:
#!/bin/bash
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
#
# setup_python-2.7.4.sh - Installs Python-2.7.4 and 3 useful modules, setuptools, pip, virtualenv.
#
aptitude update
aptitude -y install build-essential
# Set your work directory and install directory.
@kojiwell
kojiwell / keystone_user_get.py
Last active December 16, 2015 21:59
There is an example to get user by USER_ID on the keystone-api documentation.(https://keystoneclient.readthedocs.org/en/latest/api.html) But usually we want to get user by USER_NAME. Here's the way to do that.
#!/usr/bin/env python
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
from keystoneclient.v2_0 import client
from keystoneclient import utils
keystone = client.Client(username='admin',
password='admin_password',
tenant_name='admin_tenant',
cacert='/path/to/cacert.pem',
@kojiwell
kojiwell / install_pdsh.py
Last active December 16, 2015 20:39
An example of fabric recipe
#!/usr/bin/env python
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
import os
import sys
from fabric.api import *
from fabric.contrib import *
from cuisine import *
env.use_ssh_config = True
@kojiwell
kojiwell / ps1.sh
Created April 30, 2013 20:09
Customize PS1 on linux terminal
#
# add this line on .bashrc
#
# Custom PS1
export PS1="[\$(date +%k:%M:%S)]\u@\h \W> "
@kojiwell
kojiwell / sed_file.py
Last active December 16, 2015 19:39
sed -i -e 's/old_word/new_word/' /path/to/filename.conf in python
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
#
# sed_file.py is;
#
# sed -i -e 's/old_word/new_word/' /path/to/filename.conf
#
import fileinput, sys
for line in fileinput.input('/path/to/filename.conf', inplace=True):
line = line.replace('old_word', 'new_word')