mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -07:00
43 lines
1.7 KiB
Python
43 lines
1.7 KiB
Python
# This file is part of Ansible
|
|
#
|
|
# Ansible is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# Ansible is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
|
|
from optparse import OptionParser
|
|
import sys
|
|
import constants as C
|
|
|
|
def base_ans_parser():
|
|
parser = OptionParser()
|
|
parser.add_option("-l", "--host-list", dest="host_list",
|
|
help="path to hosts list", default=C.DEFAULT_HOST_LIST)
|
|
parser.add_option("-m", "--module-path", 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", "--pattern", dest="pattern",
|
|
help="hostname pattern", default=C.DEFAULT_PATTERN)
|
|
parser.add_option("-k", "--askpass", default=False, action="store_true",
|
|
help="ask the user to input the ssh password for connecting")
|
|
parser.add_option('-f','--forks', dest='forks', default=C.DEFAULT_FORKS, type='int',
|
|
help='set the number of forks to start up')
|
|
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 error_print(msg):
|
|
print >> sys.stderr, msg
|
|
|