Created
December 8, 2012 08:48
-
-
Save keitheis/4239346 to your computer and use it in GitHub Desktop.
install_server_utils_packages.py
This file contains hidden or 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
| import cuisine | |
| from fabric.api import roles, sudo | |
| apt_updated = None | |
| def apt_update(force=False): | |
| global apt_updated | |
| if force or not apt_updated: | |
| state = sudo('apt-get update -q') | |
| apt_updated = True | |
| return state | |
| return None | |
| def packages_ensure(package_names): | |
| for package_name in package_names: | |
| cuisine.package_ensure(package_name) | |
| @roles(['stage', 'test', 'web']) | |
| def install_server_utils_packages(): | |
| package_names = config['servers']['utils_packages'] | |
| apt_update() | |
| packages_ensure(package_names) | |
| logger.notify('Done setup server utils') | |
| # config example: config['servers']['utils_packages'] = [ htop, screen, tmux] | |
| # run: fab install_server_utils -R web | |
| # ^role |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
oh, and config of roles...
roledefs:
stage:
[]
test:
[1.1.1.1]
web:
[2.2.2.2]
db:
[]