From 604bf9f58a33e8c8bf1e04b1fb17edd11dece93e Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 26 Oct 2012 14:49:56 -0400 Subject: [PATCH] Added config option to control default of asking or not for sudo password Signed-off-by: Brian Coca --- bin/ansible | 1 + bin/ansible-playbook | 1 + lib/ansible/constants.py | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/ansible b/bin/ansible index 0b0b536679..dbcca4bedf 100755 --- a/bin/ansible +++ b/bin/ansible @@ -77,6 +77,7 @@ class Cli(object): sudopass = None if options.ask_pass: sshpass = getpass.getpass(prompt="SSH password: ") + options.ask_sudo_pass= options.ask_sudo_pass or C.DEFAULT_ASK_SUDO_PASS if options.ask_sudo_pass: sudopass = getpass.getpass(prompt="sudo password: ") options.sudo = True diff --git a/bin/ansible-playbook b/bin/ansible-playbook index 3587fa4662..d18291def6 100755 --- a/bin/ansible-playbook +++ b/bin/ansible-playbook @@ -72,6 +72,7 @@ def main(args): if not options.listhosts: if options.ask_pass: sshpass = getpass.getpass(prompt="SSH password: ") + options.ask_sudo_pass = options.ask_sudo_pass or C.DEFAULT_ASK_SUDO_PASS if options.ask_sudo_pass: sudopass = getpass.getpass(prompt="sudo password: ") options.sudo = True diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py index a978c49668..dfe88a5e3d 100644 --- a/lib/ansible/constants.py +++ b/lib/ansible/constants.py @@ -78,6 +78,7 @@ DEFAULT_POLL_INTERVAL = get_config(p, DEFAULTS, 'poll_interval', 'ANSIBLE DEFAULT_REMOTE_USER = get_config(p, DEFAULTS, 'remote_user', 'ANSIBLE_REMOTE_USER', active_user) DEFAULT_PRIVATE_KEY_FILE = shell_expand_path(get_config(p, DEFAULTS, 'private_key_file', 'ANSIBLE_PRIVATE_KEY_FILE', None)) DEFAULT_SUDO_USER = get_config(p, DEFAULTS, 'sudo_user', 'ANSIBLE_SUDO_USER', 'root') +DEFAULT_ASK_SUDO_PASS = get_config(p, DEFAULTS, 'ask_sudo_pass', 'ANSIBLE_ASK_SUDO_PASS', False) DEFAULT_REMOTE_PORT = int(get_config(p, DEFAULTS, 'remote_port', 'ANSIBLE_REMOTE_PORT', 22)) DEFAULT_TRANSPORT = get_config(p, DEFAULTS, 'transport', 'ANSIBLE_TRANSPORT', 'paramiko') DEFAULT_MANAGED_STR = get_config(p, DEFAULTS, 'ansible_managed', None, 'Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}') @@ -89,8 +90,8 @@ DEFAULT_LOOKUP_PLUGIN_PATH = shell_expand_path(get_config(p, DEFAULTS, 'look DEFAULT_VARS_PLUGIN_PATH = shell_expand_path(get_config(p, DEFAULTS, 'vars_plugins', None, '/usr/share/ansible_plugins/vars_plugins')) # non-configurable things -DEFAULT_REMOTE_PASS = None DEFAULT_SUDO_PASS = None +DEFAULT_REMOTE_PASS = None DEFAULT_SUBSET = None ANSIBLE_SSH_ARGS = get_config(p, 'ssh_connection', 'ssh_args', 'ANSIBLE_SSH_ARGS', None)