-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_keys.yml
33 lines (30 loc) · 948 Bytes
/
load_keys.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
---
- name: 'Add keys to all owned ssh caches'
hosts: 'localhost'
connection: 'local'
run_once: yes
vars:
wisp_full_path: '/dev/shm/wisp.bash'
vars_files:
- 'vaults/keys.yml'
gather_facts: no
tasks:
# Get the keys into all correctly owned ssh agents
- name: 'Find all agents owned by this user'
register: 'sshAuthSock'
become: no
find:
file_type: 'any'
paths: '/tmp'
patterns: 'agent.*'
recurse: yes
# TO DO: if no results, run ssh-agent and use that value in nest 0
# Default to user 'nobody' as this will find no agents and default
# to no-op, rather than silently run with '' and do who knows what
- name: 'Load keys into agents'
no_log: yes
with_nested:
- '{{ sshAuthSock.files | selectattr("pw_name", "eq", lookup("env", "USER") | default("nobody")) }}'
- '{{ keys }}'
include_tasks: 'block_load_keys.yml'
...