Last active
December 22, 2015 15:48
-
-
Save grenade/6494591 to your computer and use it in GitHub Desktop.
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
# Requires fabric: sudo yum -y install fabric gcc python-devel python-setuptools | |
from fabric.api import env, task, hide, sudo | |
user1 = 'foo' | |
pass1 = 'bar' | |
user2 = 'baz' | |
pass2 = 'qux' | |
passwords = { | |
'host1': [ | |
{'username': user1, 'password': pass1}, | |
{'username': user2, 'password': pass2} | |
], | |
'host2': [ | |
{'username': user1, 'password': pass1}, | |
{'username': user2, 'password': pass2} | |
] | |
} | |
env.hosts = passwords.keys() | |
@task(default=True) | |
def change_remote_passwords(): | |
with hide('running'): | |
for user in passwords[env.host]: | |
sudo(command='echo %s| passwd %s --stdin' % (user['password'],user['username'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment