Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # coding: utf-8 | 2 # coding: utf-8 |
3 | 3 |
4 import sys | 4 import sys |
5 import getopt | 5 import getopt |
6 from run import resolveHostList, runCommand, createArgumentParser | 6 from run import resolveHostList, runCommand, createArgumentParser |
7 | 7 |
8 def parseOptions(args): | 8 def parseOptions(args): |
9 description = 'Run provisioning on the given hosts or groups of hosts' | 9 description = 'Run provisioning on the given hosts or groups of hosts' |
10 parser = createArgumentParser(description=description) | 10 parser = createArgumentParser(description=description) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 ]) | 46 ]) |
47 runCommand(user, 'puppetmaster.adblockplus.org', remoteCommand) | 47 runCommand(user, 'puppetmaster.adblockplus.org', remoteCommand) |
48 | 48 |
49 def updateClient(user, host, mode): | 49 def updateClient(user, host, mode): |
50 print 'Provisioning %s...' % host | 50 print 'Provisioning %s...' % host |
51 remoteCommand = 'sudo puppet agent%s' % mode | 51 remoteCommand = 'sudo puppet agent%s' % mode |
52 | 52 |
53 # Have to ignore errors here, Puppet will return non-zero for successful runs | 53 # Have to ignore errors here, Puppet will return non-zero for successful runs |
54 runCommand(user, host, remoteCommand, ignore_errors=True) | 54 runCommand(user, host, remoteCommand, ignore_errors=True) |
55 | 55 |
56 if __name__ == "__main__": | 56 if __name__ == '__main__': |
Wladimir Palant
2015/04/07 15:50:25
Nit: We should use single quotes here as well if y
mathias
2015/04/07 15:56:22
Done.
| |
57 options = parseOptions(sys.argv[1:]) | 57 options = parseOptions(sys.argv[1:]) |
58 needKicking = resolveHostList(options.hosts) | 58 needKicking = resolveHostList(options.hosts) |
59 if len(needKicking) == 0: | 59 if len(needKicking) == 0: |
60 print >>sys.stderr, 'No valid hosts or groups specified, nothing to do' | 60 print >>sys.stderr, 'No valid hosts or groups specified, nothing to do' |
61 sys.exit(0) | 61 sys.exit(0) |
62 updateMaster(options.user) | 62 updateMaster(options.user) |
63 for host in needKicking: | 63 for host in needKicking: |
64 updateClient(options.user, host, options.mode) | 64 updateClient(options.user, host, options.mode) |
LEFT | RIGHT |