summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMichael DeHaan <michael.dehaan@gmail.com>2012-02-29 01:08:37 +0100
committerMichael DeHaan <michael.dehaan@gmail.com>2012-02-29 01:08:37 +0100
commit5eea593af50da495c1bb5c88bca710f9e32b7490 (patch)
tree61d7811c9af9e694877f5f2a6e1926570d881b70 /lib
parentRelicensing to GPLv3, all previous committers ok'd on mailing list. (diff)
parentMerge pull request #40 from skvidal/master (diff)
downloadansible-5eea593af50da495c1bb5c88bca710f9e32b7490.tar.xz
ansible-5eea593af50da495c1bb5c88bca710f9e32b7490.zip
Merge branch 'master' of github.com:mpdehaan/ansible
Diffstat (limited to 'lib')
-rw-r--r--lib/ansible/scripts.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/ansible/scripts.py b/lib/ansible/scripts.py
new file mode 100644
index 0000000000..740ead6119
--- /dev/null
+++ b/lib/ansible/scripts.py
@@ -0,0 +1,31 @@
+from optparse import OptionParser
+import sys
+import constants as C
+
+def base_ans_parser(opthosts=True, outputpath=True, forkdef=C.DEFAULT_FORKS):
+ parser = OptionParser()
+ if opthosts:
+ parser.add_option('--host', default=[], action='append',
+ help="hosts to act on, defaults to ALL")
+ parser.add_option("-H", "--host-list", dest="host_list",
+ help="path to hosts list", default=C.DEFAULT_HOST_LIST)
+ parser.add_option("-L", "--library", dest="module_path",
+ help="path to module library", default=C.DEFAULT_MODULE_PATH)
+ parser.add_option('-u', '--user', default=C.DEFAULT_REMOTE_USER,
+ dest='remote_user', help='set the default username')
+ parser.add_option("-P", "--askpass", default=False, action="store_true",
+ help="ask the user to input the ssh password for connecting")
+ parser.add_option('-f','--forks', default=forkdef, type='int',
+ help='set the number of forks to start up')
+ if outputpath:
+ parser.add_option('--outputpath', default='/tmp/ansible', dest="outputpath",
+ help="basepath to store results/errors output.")
+ return parser
+
+# other functions as needed for nicely handling output from json back
+# to things people might be more inclined to deal with at a bash prompt
+
+
+def errorprint(msg):
+ print >> sys.stderr, msg
+