Skip to content

Instantly share code, notes, and snippets.

@jinoj
Forked from nazarewk/ansible.cfg
Created December 8, 2018 16:34
Show Gist options
  • Select an option

  • Save jinoj/b94bddb0c350befd76b79a329b5d9bdb to your computer and use it in GitHub Desktop.

Select an option

Save jinoj/b94bddb0c350befd76b79a329b5d9bdb to your computer and use it in GitHub Desktop.
Ansible SSH Agent forwarding with Jump (bastion) host
Host jump
HostName <jump_ip>
User nazarewk
ForwardAgent yes
Host secured-*
User nazarewk
ProxyJump jump
ForwardAgent yes
- name: Ensuring we can ForwardAgent
lineinfile:
dest: "~/.profile"
line: '[ -n "$SSH_AUTH_SOCK" ] && setfacl -m u:{{ project_user }}:rw "$SSH_AUTH_SOCK" && setfacl -m u:{{ project_user }}:x "$(dirname $SSH_AUTH_SOCK)" && alias sudo=''/usr/bin/sudo SSH_AUTH_SOCK="$SSH_AUTH_SOCK"'''
insertafter: EOF
- name: Ensure we have ForwardAgent
command: ssh-add -l
become: true
become_user: "{{ project_user }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment