added ssh roles and pass repo cloning

This commit is contained in:
2026-06-22 09:24:13 -05:00
parent f1dd4fb3c0
commit 969f9703e9
7 changed files with 80 additions and 0 deletions
+3
View File
@@ -1,6 +1,9 @@
--- ---
packages_to_install: packages_to_install:
- ansible - ansible
- git
- gnupg
- pass
- ansible-lint - ansible-lint
- azure-cli - azure-cli
- ex-vi-compat - ex-vi-compat
+6
View File
@@ -0,0 +1,6 @@
---
galaxy_info:
author: cjr
description: Clone the pass password store
license: BSD-3-Clause
min_ansible_version: "2.1"
+7
View File
@@ -0,0 +1,7 @@
---
- name: Clone password store
ansible.builtin.git:
repo: cjr@git:/home/cjr/.password-store
dest: "{{ ansible_facts['user_dir'] }}/.password-store"
update: true
version: main
+6
View File
@@ -0,0 +1,6 @@
---
galaxy_info:
author: cjr
description: Deploy SSH keys and config from pass
license: BSD-3-Clause
min_ansible_version: "2.1"
+45
View File
@@ -0,0 +1,45 @@
---
- name: Verify gpg-agent is running
ansible.builtin.command:
cmd: gpg-agent --version
changed_when: false
register: ssh_gpg_agent_check
failed_when: ssh_gpg_agent_check.rc != 0
- name: Ensure .ssh directory exists
ansible.builtin.file:
path: "{{ ansible_facts['user_dir'] }}/.ssh"
state: directory
mode: "0700"
- name: Write ansible SSH private key
ansible.builtin.copy:
content: "{{ lookup('pipe', 'pass show ssh/id_ed25519_ansible') }}\n"
dest: "{{ ansible_facts['user_dir'] }}/.ssh/id_ed25519_ansible"
mode: "0600"
no_log: true
- name: Derive and write ansible SSH public key
ansible.builtin.shell:
cmd: ssh-keygen -y -f {{ ansible_facts['user_dir'] }}/.ssh/id_ed25519_ansible > {{ ansible_facts['user_dir'] }}/.ssh/id_ed25519_ansible.pub
changed_when: false
- name: Deploy SSH config
ansible.builtin.template:
src: config.j2
dest: "{{ ansible_facts['user_dir'] }}/.ssh/config"
mode: "0600"
- name: Fetch Gitea host key
ansible.builtin.command:
cmd: ssh-keyscan -4 -p 2222 gitea.learningunix.net
register: ssh_gitea_host_key
changed_when: false
- name: Add Gitea host key to known_hosts
ansible.builtin.known_hosts:
name: "[gitea.learningunix.net]:2222"
key: "{{ item }}"
path: "{{ ansible_facts['user_dir'] }}/.ssh/known_hosts"
state: present
loop: "{{ ssh_gitea_host_key.stdout_lines }}"
+9
View File
@@ -0,0 +1,9 @@
Host gitea.learningunix.net
User git
Port 2222
IdentityFile ~/.ssh/id_ed25519_ansible
Host learningunix
HostName 91.99.74.227
User cjr
IdentityFile ~/.ssh/id_ed25519
+4
View File
@@ -23,6 +23,10 @@
connection: local connection: local
roles: roles:
- role: ssh
tags: ssh
- role: pass
tags: pass
- role: dotfiles - role: dotfiles
tags: dotfiles tags: dotfiles
- role: scripts - role: scripts