Created
February 17, 2013 02:42
-
-
Save sechiro/4969815 to your computer and use it in GitHub Desktop.
fabfile.py for my home server.
Target environment:
Machine: VM on VMware ESX 5.1.0a, OS: Ubuntu 12.04 LTS Server (Installed with OpenSSH Service)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*- coding:utf-8 -*- | |
from fabric import api | |
hostlist = [] | |
for fourth_octet in [20, 21, 22, 23, 24]: | |
hostlist.append("192.168.11." + str(fourth_octet)) | |
api.env.hosts = hostlist | |
#api.env.password = 'password' | |
print 'Target: ', | |
print api.env.hosts | |
def deploy_vmwaretools(): | |
archive_name = 'VMwareTools-9.0.0-782409.tar.gz' # Local file in current dir | |
api.put(archive_name, '/tmp') | |
api.run('ls /tmp') | |
with api.cd('/tmp'): | |
api.run('tar xf ' + archive_name) | |
with api.cd('/tmp/vmware-tools-distrib'): | |
api.sudo('./vmware-install.pl') | |
def add_ssh_nodns(): | |
api.sudo('echo "UseDNS no" >> /etc/ssh/sshd_config') | |
api.sudo('tail','/etc/ssh/sshd_config') | |
api.sudo('sudo service ssh restart') | |
def add_nopass_sudo(): | |
config_file = 'sechiro-nopass' | |
api.sudo('echo "sechiro ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/' + config_file) | |
api.sudo('chmod 440 /etc/sudoers.d/' + config_file) | |
api.sudo('ls -l /etc/sudoers.d/') | |
api.sudo('cat /etc/sudoers.d/' + config_file) | |
def install_gcc(): | |
api.sudo('apt-get -y install gcc') | |
def update(): | |
api.sudo('apt-get -y update') | |
def restart(): | |
api.sudo('shutdown -ry now') | |
def command_test(): | |
api.put('testfile', '/tmp') | |
api.sudo('echo test > /tmp/testfile2') | |
api.run('ls -l /tmp') | |
def set_vim(): | |
api.sudo('update-alternatives --set editor /usr/bin/vim.basic') | |
def initial_setting(): | |
set_vim() | |
add_nopass_sudo() | |
install_gcc() | |
update() | |
#restart() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment