infra-ansible

ansible script to ship alpine/ssh/wireguard

git clone https://9o.is/git/infra-ansible.git

commit 2d9b6ec6a57d21b59a5219daac6096997455685d
parent 524a33df52829afec92bf60dd975bb78042c1560
Author: Jul <jul@9o.is>
Date:   Mon, 13 May 2024 16:52:16 +0800

set local ssh config

Diffstat:
Mhost/roles/openssh/tasks/main.yml | 29+++++++++++++++++++++++++++++
1 file changed, 29 insertions(+), 0 deletions(-)

diff --git a/host/roles/openssh/tasks/main.yml b/host/roles/openssh/tasks/main.yml @@ -66,3 +66,32 @@ validate: sshd -t -f %s notify: restart sshd +- name: Get hostname + shell: cat /etc/hostname + register: hostname + +- name: Create ssh config locally + delegate_to: localhost + become: false + file: + path: ~user/.ssh/config + owner: user + group: user + mode: '0644' + state: touch + +- name: Configure ssh locally + delegate_to: localhost + delegate_facts: true + become: false + blockinfile: + path: ~user/.ssh/config + marker: "### {mark} ansible managed {{ hostname.stdout }}" + append_newline: true + prepend_newline: true + block: | + Host {{ hostname.stdout }} + HostName {{ hostname.stdout }} + User user + Port {{ openssh_port }} +