Created
June 20, 2020 11:24
-
-
Save jpcweb/860c3aa793ee0e483279c96cb38f3490 to your computer and use it in GitHub Desktop.
Easy steps for Ansible, git private repo and ssh agent forwarding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Make sure your key is added to ssh-agent | |
ssh-add ~/.ssh/my_id_rsa | |
# ~/.ssh/config | |
Host my-remote-ansible-host | |
ForwardAgent yes | |
# OR | |
# In your ansible.cfg file | |
[ssh_connection] | |
ssh_args = -o ForwardAgent=yes | |
# In your role | |
# files/env: | |
Defaults env_keep += "SSH_AUTH_SOCK" | |
# tasks/main.yml | |
- name: ensure sudo keeps SSH_AUTH_SOCK in environment | |
copy: src=env | |
dest=/etc/sudoers.d/env | |
mode=0440 | |
owner=root | |
group=root | |
- name: clone repo from github | |
git: repo=ssh://git@github.com/example/example-repo.git | |
dest=/tmp/example-repo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment