forked from d0ugal/chef_recipes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
executable file
·42 lines (32 loc) · 1.32 KB
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from fabric.api import env, local, run, sudo
# Taken from Eric Holschers blog.
# Modified slightly.
# Change host details, you may need to change the executable path if your running on a vagrant vm.
env.user = 'vagrant'
env.password = 'vagrant'
env.hosts = ['33.33.33.15']
env.chef_executable = '/var/lib/gems/1.8/bin/chef-solo'
#env.chef_executable = '/usr/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/chef-solo'
def install_chef():
sudo('apt-get update', pty=True)
sudo('apt-get install -y libopenssl-ruby')
sudo('apt-get install -y git-core rubygems ruby ruby-dev', pty=True)
sudo('gem install chef --no-ri --no-rdoc', pty=True)
sudo('mkdir -p /var/chef')
sudo('chown %s /var/chef' % (env.user))
def sync_config():
local('sudo rsync -av . %s@%s:/var/chef' % (env.user, env.hosts[0]))
def update():
sync_config()
sudo('cd /var/chef && %s' % env.chef_executable, pty=True)
def update_all():
sync_config()
import os
for file in [f for f in os.listdir('site_configs') if f[-5:] == '.json']:
sudo('cd /var/chef && %s -j site_configs/%s' % (env.chef_executable, file), pty=True)
def update_site(site):
sync_config()
import os
if site in os.listdir('site_configs'):
sudo('cd /var/chef && %s -j site_configs/%s' % (env.chef_executable, site), pty=True)
print site