Added ssh agent for all shells

This commit is contained in:
2025-04-02 19:25:22 +02:00
parent cf823c0061
commit b1d8e21772
5 changed files with 89 additions and 19 deletions

View File

@@ -26,4 +26,5 @@ galaxy_info:
documentation: https://s.veen.world/cymais
dependencies:
- client-git
- client-git
- shell

View File

@@ -35,21 +35,11 @@
daemon_reload: true
become: false
- name: Set SSH_AUTH_SOCK in bash_profile or profile
block:
- name: Choose profile file
set_fact:
profile_file: "$HOME/.bash_profile"
when: ansible_facts.env.HOME is defined and lookup('file', ansible_env.HOME + '/.bash_profile', errors='ignore') is defined
- name: Fallback to .profile if .bash_profile not found
set_fact:
profile_file: "$HOME/.profile"
when: profile_file is not defined
- name: Ensure SSH_AUTH_SOCK is set in profile
lineinfile:
path: "{{ profile_file }}"
line: 'export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"'
insertafter: EOF
state: present
- name: Ensure ~/.profile exists with common environment
lineinfile:
path: "{{ ansible_env.HOME }}/.profile"
line: 'export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"'
insertafter: EOF
state: present
create: yes
mode: "0644"