Skip to content

Commit

Permalink
Per-user custom ssh config
Browse files Browse the repository at this point in the history
  • Loading branch information
hellais committed Jul 9, 2024
1 parent 105fd54 commit 430594a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions ansible/roles/ansible_controller/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,29 @@
UserKnownHostsFile ~/.ssh/known_hosts /srv/devops/ansible/known_hosts /srv/devops/ansible/known_hosts_legacy
IdentitiesOnly yes
with_items: "{{ non_admin_usernames | union(admin_usernames) }}"

- name: Create config.d directory for each user
ansible.builtin.file:
path: "/home/{{ item }}/.ssh/config.d/"
state: directory
owner: "{{ item }}"
group: "{{ item }}"
mode: "700"

- name: Create config.d custom file for each user
ansible.builtin.file:
path: "/home/{{ item }}/.ssh/config.d/custom"
state: file
owner: "{{ item }}"
group: "{{ item }}"
mode: "600"

- name: Include per-user custom config
ansible.builtin.copy:
dest: "/home/{{ item }}/.ssh/config"
content: |
# Do not edit! ansible managed via ooni/devops
UserKnownHostsFile ~/.ssh/known_hosts /srv/devops/ansible/known_hosts /srv/devops/ansible/known_hosts_legacy
IdentitiesOnly yes
Include config.d/*
with_items: "{{ non_admin_usernames | union(admin_usernames) }}"

0 comments on commit 430594a

Please sign in to comment.