CORD-1401 Don't overwrite existing keypair, CiaB PCU setup roles
Change-Id: Ia0fe60315ed09ba39634ed5c25e50e7bfd51d1ab
diff --git a/roles/maas-user-privkey/defaults/main.yml b/roles/maas-user-privkey/defaults/main.yml
new file mode 100644
index 0000000..a87005c
--- /dev/null
+++ b/roles/maas-user-privkey/defaults/main.yml
@@ -0,0 +1,5 @@
+---
+# roles/maas-user-privkey/defaults/main.yml
+
+maas_homedir: "/var/lib/maas"
+pub_ssh_key_file_location: "{{ pub_ssh_key_location | default ('/etc/maas/.ssh') }}"
diff --git a/roles/maas-user-privkey/tasks/main.yml b/roles/maas-user-privkey/tasks/main.yml
new file mode 100644
index 0000000..775c820
--- /dev/null
+++ b/roles/maas-user-privkey/tasks/main.yml
@@ -0,0 +1,20 @@
+---
+# roles/maas-user-privkey/tasks/main.yml
+
+- name: Create maas .ssh dir
+ become: yes
+ file:
+ path: "{{ maas_homedir }}/.ssh"
+ state: directory
+ owner: maas
+ group: maas
+ mode: 0700
+
+- name: Copy generated private key to maas user
+ become: yes
+ copy:
+ src: "{{ pub_ssh_key_file_location }}/cord_rsa"
+ dest: "{{ maas_homedir }}/.ssh/id_rsa"
+ owner: maas
+ group: maas
+ mode: 0600
\ No newline at end of file