summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Belanger <pabelanger@redhat.com>2019-01-26 18:41:28 -0500
committerPaul Belanger <pabelanger@redhat.com>2019-01-26 18:41:28 -0500
commit1e1255a1fa24efd48c353b517d99e49f08b63b0c (patch)
treeb73f50eb2760d3f2c9cf093a2b99eea00307c529
parentc7f8d4154e0939da837745b8b370f2006ef5cb77 (diff)
Add authorized_keys supportHEADmaster
It is possible people also want to setup the .ssh/authorized_keys file. Change-Id: I039f5b866192bb5309bff23f4811cdf83ba859af Signed-off-by: Paul Belanger <pabelanger@redhat.com>
Notes
Notes (review): Code-Review+2: Paul Belanger <pabelanger@redhat.com> Workflow+1: Paul Belanger <pabelanger@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 28 Jan 2019 17:08:54 +0000 Reviewed-on: https://review.openstack.org/633370 Project: openstack/ansible-role-ssh Branch: refs/heads/master
-rw-r--r--defaults/main.yaml4
-rw-r--r--tasks/config.yaml10
-rw-r--r--templates/authorized_keys.j24
3 files changed, 18 insertions, 0 deletions
diff --git a/defaults/main.yaml b/defaults/main.yaml
index bf129a3..4222854 100644
--- a/defaults/main.yaml
+++ b/defaults/main.yaml
@@ -21,6 +21,10 @@ ssh_user_name:
21ssh_user_home: "/home/{{ ssh_user_name }}" 21ssh_user_home: "/home/{{ ssh_user_name }}"
22ssh_user_group: "{{ ssh_user_name }}" 22ssh_user_group: "{{ ssh_user_name }}"
23 23
24ssh_authorized_keys_content:
25ssh_authorized_keys_dest: "{{ ssh_user_home }}/.ssh/authorized_keys"
26ssh_authorized_keys_src: authorized_keys.j2
27
24ssh_key_private_content: 28ssh_key_private_content:
25ssh_key_private_dest: "{{ ssh_user_home }}/.ssh/id_rsa" 29ssh_key_private_dest: "{{ ssh_user_home }}/.ssh/id_rsa"
26ssh_key_private_src: id_rsa.j2 30ssh_key_private_src: id_rsa.j2
diff --git a/tasks/config.yaml b/tasks/config.yaml
index c3af9c7..1ca6b04 100644
--- a/tasks/config.yaml
+++ b/tasks/config.yaml
@@ -21,6 +21,16 @@
21 owner: "{{ ssh_user_name }}" 21 owner: "{{ ssh_user_name }}"
22 state: directory 22 state: directory
23 23
24- name: Create ssh authorized_keys file
25 become: yes
26 template:
27 dest: "{{ ssh_authorized_keys_dest }}"
28 group: "{{ ssh_user_group }}"
29 mode: 0600
30 owner: "{{ ssh_user_name }}"
31 src: "{{ ssh_authorized_keys_src }}"
32 when: ssh_authorized_keys_content | default(False)
33
24- name: Create ssh known_hosts file 34- name: Create ssh known_hosts file
25 become: yes 35 become: yes
26 template: 36 template:
diff --git a/templates/authorized_keys.j2 b/templates/authorized_keys.j2
new file mode 100644
index 0000000..0409ecc
--- /dev/null
+++ b/templates/authorized_keys.j2
@@ -0,0 +1,4 @@
1# This file is generated by Ansible
2# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
3#
4{{ ssh_authorized_keys_content }}