Switch to templating for ssh files

Change-Id: Ic86877e26d982e3ba978aec772ade5bee5890a12
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
Paul Belanger 2016-03-29 15:25:32 -04:00
parent b3cd64e6fe
commit 59557b7f57
5 changed files with 27 additions and 12 deletions

View File

@ -17,10 +17,13 @@ ssh_user_home: "/home/{{ ssh_user_name }}"
ssh_user_group: "{{ ssh_user_name }}"
ssh_key_private_content:
ssh_key_private_filename: id_rsa
ssh_key_private_dest: "{{ ssh_user_home }}/.ssh/id_rsa"
ssh_key_private_src: id_rsa.j2
ssh_key_public_content:
ssh_key_public_filename: id_rsa.pub
ssh_key_public_dest: "{{ ssh_user_home }}/.ssh/id_rsa.pub"
ssh_key_public_src: id_rsa.pub.j2
ssh_known_hosts_content:
ssh_known_hosts_filename: known_hosts
ssh_known_hosts_dest: "{{ ssh_user_home }}/.ssh/known_hosts"
ssh_known_hosts_src: known_hosts.j2

View File

@ -21,28 +21,28 @@
state: directory
- name: Create ssh known_hosts file.
copy:
content: "{{ ssh_known_hosts_content }}"
dest: "{{ ssh_user_home }}/.ssh/{{ ssh_known_hosts_filename }}"
template:
dest: "{{ ssh_known_hosts_dest }}"
group: "{{ ssh_user_group }}"
mode: 0644
owner: "{{ ssh_user_name }}"
src: "{{ ssh_known_hosts_src }}"
when: ssh_known_hosts_content
- name: Create ssh private key.
copy:
content: "{{ ssh_key_private_content }}"
dest: "{{ ssh_user_home }}/.ssh/{{ ssh_key_private_filename }}"
template:
dest: "{{ ssh_key_private_dest }}"
group: "{{ ssh_user_group }}"
mode: 0600
owner: "{{ ssh_user_name }}"
src: "{{ ssh_key_private_src }}"
when: ssh_key_private_content
- name: Create ssh public key.
copy:
content: "{{ ssh_key_public_content }}"
dest: "{{ ssh_user_home }}/.ssh/{{ ssh_key_public_filename }}"
template:
dest: "{{ ssh_key_public_dest }}"
group: "{{ ssh_user_group }}"
mode: 0644
owner: "{{ ssh_user_name }}"
src: "{{ ssh_key_public_src }}"
when: ssh_key_public_content

4
templates/id_rsa.j2 Normal file
View File

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

4
templates/id_rsa.pub.j2 Normal file
View File

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

4
templates/known_hosts.j2 Normal file
View File

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