Couple of things to check: - Can you run the git command with 'sudo: false'? See here for why: https://help.github.com/articles/error-permission-denied-publickey#sudo-or-sudont - If you need to run git with sudo, and that's why you have specified key_file=..., I think you want to use your private key (mykey), rather than your public key (mykey.pub).
Hope it helps. On Sunday, July 20, 2014 6:55:14 PM UTC+8, [email protected] wrote: > > I want to pull code from Bitbucket.org > > - copy: src=path/to/mykey.pub dest=/home/{{ username }}/.ssh/mykey.pub > sudo: false > > - copy: src=path/to/mykey dest=/home/{{ username }}/.ssh/mykey mode=0600 > sudo: false > > - copy: src=path/to/known_hosts dest=/home/{{ username }}/.ssh/known_hosts > sudo: false > > - authorized_key: user={{ username }} key="{{ lookup('file', > '/home/{{username}}/.ssh/mykey.pub') }}" > > - git: repo={{ project_repo }} dest={{ project_code }} version={{ branch > }} accept_hostkey=true key_file="{{ lookup('file', '/home/{{ username > }}/.ssh/mykey.pub') }}" > > After running this playbook I get: > > ... > "cmd": "/usr/bin/git ls-remote [email protected]:/myusername/mypro.git -h > refs/heads/develop", "failed": true > ... > stderr: Permission denied (publickey). > fatal: Could not read from remote repository. > > Please make sure you have the correct access rights > and the repository exists. > > NOTICE: While using bash, I can execute the "cmd" command without errors > (even without sudo). My user logs in and connect to the repo. I do not > understand why ansible is not able to repeat it. > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/73aaf32a-b312-46b5-af9a-2d05cc22fca2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
