Browse Source

Add authorized_keys support

It is possible people also want to setup the .ssh/authorized_keys file.

Change-Id: I039f5b866192bb5309bff23f4811cdf83ba859af
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
changes/70/633370/1
Paul Belanger 3 years ago
parent
commit
1e1255a1fa
  1. 4
      defaults/main.yaml
  2. 10
      tasks/config.yaml
  3. 4
      templates/authorized_keys.j2

4
defaults/main.yaml

@ -21,6 +21,10 @@ ssh_user_name:
ssh_user_home: "/home/{{ ssh_user_name }}"
ssh_user_group: "{{ ssh_user_name }}"
ssh_authorized_keys_content:
ssh_authorized_keys_dest: "{{ ssh_user_home }}/.ssh/authorized_keys"
ssh_authorized_keys_src: authorized_keys.j2
ssh_key_private_content:
ssh_key_private_dest: "{{ ssh_user_home }}/.ssh/id_rsa"
ssh_key_private_src: id_rsa.j2

10
tasks/config.yaml

@ -21,6 +21,16 @@
owner: "{{ ssh_user_name }}"
state: directory
- name: Create ssh authorized_keys file
become: yes
template:
dest: "{{ ssh_authorized_keys_dest }}"
group: "{{ ssh_user_group }}"
mode: 0600
owner: "{{ ssh_user_name }}"
src: "{{ ssh_authorized_keys_src }}"
when: ssh_authorized_keys_content | default(False)
- name: Create ssh known_hosts file
become: yes
template:

4
templates/authorized_keys.j2

@ -0,0 +1,4 @@
# This file is generated by Ansible
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
#
{{ ssh_authorized_keys_content }}
Loading…
Cancel
Save