Reorganize project: separate playbooks/ and files/, add shell-setup (fish+nvim+tide+lazyvim)
This commit is contained in:
parent
9bed146909
commit
b5cabaf1fe
10 changed files with 155 additions and 15 deletions
32
playbooks/generate-ssh-config.yml
Normal file
32
playbooks/generate-ssh-config.yml
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
- name: Generate local SSH config from Ansible inventory
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
|
||||
vars:
|
||||
ssh_config_file: "{{ lookup('env', 'HOME') }}/.ssh/config"
|
||||
ssh_identity_file: "~/.ssh/id_ed25519"
|
||||
ssh_host_suffix: "VM"
|
||||
ssh_config_marker: "# {mark} ANSIBLE MANAGED HOME VM HOSTS"
|
||||
|
||||
tasks:
|
||||
- name: Ensure ~/.ssh directory exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ lookup('env', 'HOME') }}/.ssh"
|
||||
state: directory
|
||||
mode: "0700"
|
||||
|
||||
- name: Add Proxmox VM hosts to local SSH config
|
||||
ansible.builtin.blockinfile:
|
||||
path: "{{ ssh_config_file }}"
|
||||
create: true
|
||||
mode: "0600"
|
||||
marker: "{{ ssh_config_marker }}"
|
||||
block: |
|
||||
{% for host in groups["proxmox_vms"] %}
|
||||
Host {{ host }}{{ ssh_host_suffix }}
|
||||
HostName {{ hostvars[host]["ansible_host"] }}
|
||||
User {{ hostvars[host]["ansible_user"] | default("vrubel") }}
|
||||
IdentityFile {{ ssh_identity_file }}
|
||||
|
||||
{% endfor %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue