Skip to content

Instantly share code, notes, and snippets.

@javierwilson
Last active July 10, 2017 17:49
Show Gist options
  • Save javierwilson/5387400 to your computer and use it in GitHub Desktop.
Save javierwilson/5387400 to your computer and use it in GitHub Desktop.
yum update with fabric
#
# $ fab set_hosts update
#
from fabric.api import run, env, sudo
from fabric.contrib.console import confirm
env.warn_only = True
def set_hosts():
env.hosts = open('hosts', 'r').readlines()
def update():
print("Executing on %(host)s as %(user)s" % env)
if run("yum check-update").return_code != 0:
if confirm("execute yum update?", default=False) == True:
sudo("yum -y update", pty=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment