Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
fb531a8d
Commit
fb531a8d
authored
Feb 28, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor option string relabelling, move one option from common into helper script
parent
c6eb3f10
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
13 deletions
+12
-13
bin/ans-command
+10
-5
lib/ansible/scripts.py
+2
-8
No files found.
bin/ans-command
View file @
fb531a8d
...
...
@@ -29,17 +29,23 @@ from ansible.scripts import base_ans_parser, error_print
def
main
(
args
):
parser
=
base_ans_parser
(
output_path
=
False
)
parser
.
usage
=
"ans-command [options] command-to-run"
parser
.
add_option
(
'-c'
,
'--return-codes'
,
dest
=
'return_codes'
,
action
=
'store_true'
,
help
=
"prefix each line with the commands return
code"
)
help
=
"prefix each line with the command's return
code"
)
parser
.
add_option
(
'-1'
,
'--one-line'
,
dest
=
'one_line'
,
action
=
'store_true'
,
help
=
"output all things as one line - to make grepping easier,
will
\
not remove
\\
n's from output of commands, though
"
)
help
=
"output results on one line to make grepping easier, however
will
\
not remove newlines from command output
"
)
parser
.
add_option
(
'-o'
,
'--output-dir'
,
dest
=
'output_dest'
,
default
=
None
,
help
=
"output each host's results to a file in a dir named for the host"
)
help
=
"output each host's results to a file in a dir named for the host"
)
parser
.
add_option
(
'--output-path'
,
default
=
'/tmp/ansible'
,
dest
=
"output_path"
,
help
=
"basepath to store results/errors output."
)
options
,
args
=
parser
.
parse_args
(
args
)
# TODO: move into lib/ansible/scripts.py
sshpass
=
None
if
options
.
askpass
:
sshpass
=
getpass
.
getpass
(
prompt
=
"SSH password: "
)
...
...
@@ -79,7 +85,6 @@ def main(args):
verbose
=
True
,
)
print
mycmd
results
=
runner
.
run
()
for
hn
in
sorted
(
results
[
'contacted'
]):
...
...
lib/ansible/scripts.py
View file @
fb531a8d
...
...
@@ -18,11 +18,8 @@ from optparse import OptionParser
import
sys
import
constants
as
C
def
base_ans_parser
(
opthosts
=
True
,
output_path
=
True
,
forkdef
=
C
.
DEFAULT_FORKS
):
def
base_ans_parser
():
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"
,
...
...
@@ -31,11 +28,8 @@ def base_ans_parser(opthosts=True, output_path=True, forkdef=C.DEFAULT_FORKS):
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'
,
dest
=
'forks'
,
default
=
forkdef
,
type
=
'int'
,
parser
.
add_option
(
'-f'
,
'--forks'
,
dest
=
'forks'
,
default
=
C
.
DEFAULT_FORKS
,
type
=
'int'
,
help
=
'set the number of forks to start up'
)
if
output_path
:
parser
.
add_option
(
'--output-path'
,
default
=
'/tmp/ansible'
,
dest
=
"output_path"
,
help
=
"basepath to store results/errors output."
)
return
parser
# other functions as needed for nicely handling output from json back
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment