First commit
This commit is contained in:
commit
9417f24a25
4 changed files with 61 additions and 0 deletions
21
README.md
Normal file
21
README.md
Normal file
|
@ -0,0 +1,21 @@
|
|||
SSH-Agentd Ansible role
|
||||
-----------------------
|
||||
|
||||
This role create service and environment for managing ssh-agent service with
|
||||
systemd.
|
||||
|
||||
Note that for exporting SSH_AUTH_SOCK in your session, you need to parse
|
||||
fnvironment file in `XDG_CONFIG_DIR`. Here is an example for zsh, i put this
|
||||
little snippet in my `.zprofile`:
|
||||
|
||||
```zsh
|
||||
for file in ~/.config/environment.d/*.conf
|
||||
do
|
||||
while read -r line
|
||||
do
|
||||
varname=${line%=*}
|
||||
value=${${(e)line#*=}//\"}
|
||||
export $varname="${value}"
|
||||
done < $file
|
||||
done
|
||||
```
|
1
files/ssh-agentd.conf
Normal file
1
files/ssh-agentd.conf
Normal file
|
@ -0,0 +1 @@
|
|||
SSH_AUTH_SOCK="${XDG_RUNTIME_DIR}/ssh-agent.socket"
|
10
files/ssh-agentd.service
Normal file
10
files/ssh-agentd.service
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=SSH key agent
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
EnvironmentFile=%h/.config/environment.d/ssh-agentd.conf
|
||||
ExecStart=/usr/bin/ssh-agent -D -a $SSH_AUTH_SOCK
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
29
tasks/main.yml
Normal file
29
tasks/main.yml
Normal file
|
@ -0,0 +1,29 @@
|
|||
---
|
||||
- name: Create config dirs
|
||||
ansible.builtin.file:
|
||||
path: '{{ ansible_user_dir }}/.config/systemd/user'
|
||||
state: directory
|
||||
mode: 0750
|
||||
|
||||
- name: Copy systemd service file
|
||||
ansible.builtin.copy:
|
||||
src: 'ssh-agentd.service'
|
||||
dest: '{{ ansible_user_dir }}/.config/systemd/user/'
|
||||
mode: 0640
|
||||
|
||||
- name: Copy ssh-agent env file
|
||||
ansible.builtin.copy:
|
||||
src: 'ssh-agentd.conf'
|
||||
dest: '{{ ansible_user_dir }}/.config/environment.d/'
|
||||
mode: 0640
|
||||
|
||||
- name: Activate service
|
||||
ansible.builtin.systemd:
|
||||
name: 'ssh-agentd'
|
||||
scope: user
|
||||
daemon-reload: true
|
||||
state: stopped
|
||||
enabled: true
|
||||
environment:
|
||||
XDG_RUNTIME_DIR: "/run/user/{{ ansible_user_uid }}"
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue