Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ask_pass should be forced to false if connection=local #3720

Closed
hura opened this issue Aug 1, 2013 · 5 comments · Fixed by #3781
Closed

ask_pass should be forced to false if connection=local #3720

hura opened this issue Aug 1, 2013 · 5 comments · Fixed by #3781
Labels
feature This issue/PR relates to a feature request.

Comments

@hura
Copy link

hura commented Aug 1, 2013

I've had this problem with ansible-pull which started failing when it picked up a ask_pass=True. It keeps asking for a password.

Looks like:

bin/ansible (line 181)
bin/ansible-playbook (line 95)

will still ask for a password even though a "-c local" is given at the command line.

I don't have a patch, but I imagine it to be two easy if's if that helps.

Cheers

@mpdehaan
Copy link
Contributor

mpdehaan commented Aug 1, 2013

This sounds reasonable actually, I forgot it was passing -c local so should be easy enough to detect.

@sfromm
Copy link
Contributor

sfromm commented Aug 1, 2013

A couple thoughts:

  • I assume you mean ask_pass=true for when you ran into the problem? If so, can you update the problem description?
  • I suspect that the ansible.cfg with ask_pass=true wasn't used until ansible-playbook is invoked - ie. after the git module is run. Can you confirm? ansible-pull will chdir to the source repository after a successful git module run and before ansible-playbook.

Thanks!

@hura
Copy link
Author

hura commented Aug 1, 2013

Yes correct, the very first git pull succeeds but from then on it will ask for a password.

A workaround (for people getting here through google):
Have your cron.d tab look something like this:

{{ schedule }} root ANSIBLE_CONFIG={{ workdir }}/ansible/ansible-pull.cfg ansible-pull -o -d {{ workdir }}/ansible -U {{ repo_url }} -i {{ workdir }}/ansible/hosts {{ playbook }} >>{{ logfile }} 2>&1

similar to
https://github.com/ansible/ansible-examples/blob/master/language_features/ansible_pull.yml

@hura
Copy link
Author

hura commented Aug 2, 2013

This patch fixes it:

diff --git a/bin/ansible b/bin/ansible
index 7e1150a..20560f1 100755
--- a/bin/ansible
+++ b/bin/ansible
@@ -97,6 +97,9 @@ class Cli(object):
         sshpass = None
         sudopass = None
         options.ask_pass = options.ask_pass or C.DEFAULT_ASK_PASS
+        # Never ask for an SSH password when we run with local connection
+        if options.connection == "local":
+          options.ask_pass = False
         options.ask_sudo_pass= options.ask_sudo_pass or C.DEFAULT_ASK_SUDO_PASS
         ( sshpass, sudopass ) = utils.ask_passwords(ask_pass=options.ask_pass, ask_sudo_pass=options.ask_sudo_pass)
         if options.sudo_user or options.ask_sudo_pass:
diff --git a/bin/ansible-playbook b/bin/ansible-playbook
index a3b3329..200e867 100755
--- a/bin/ansible-playbook
+++ b/bin/ansible-playbook
@@ -91,6 +91,9 @@ def main(args):
     sudopass = None
     if not options.listhosts and not options.syntax and not options.listtasks:
         options.ask_pass = options.ask_pass or C.DEFAULT_ASK_PASS
+        # Never ask for an SSH password when we run with local connection
+        if options.connection == "local":
+          options.ask_pass = False
         options.ask_sudo_pass = options.ask_sudo_pass or C.DEFAULT_ASK_SUDO_PASS
         ( sshpass, sudopass ) = utils.ask_passwords(ask_pass=options.ask_pass, ask_sudo_pass=options.ask_sudo_pass)
         options.sudo_user = options.sudo_user or C.DEFAULT_SUDO_USER

@mpdehaan
Copy link
Contributor

mpdehaan commented Aug 6, 2013

Can you please submit a pull request for this?

That is how we like to take patches and can make sure they are attributed to you.

Thanks!

@ansibot ansibot added feature This issue/PR relates to a feature request. and removed feature_idea labels Mar 2, 2018
@ansible ansible locked and limited conversation to collaborators Apr 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature This issue/PR relates to a feature request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants