From a60b6ea6a2dd7adaebb40caa5fa5693d2a9313fd Mon Sep 17 00:00:00 2001
From: Petr OspalĂ˝
Date: Wed, 19 Dec 2018 14:46:38 +0100
Subject: Add the setup playbook for distributing ssh keys
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Change-Id: I76773122de3d0b85a5bd772353614834df382c54
Issue-ID: OOM-1551
Signed-off-by: Petr OspalĂ˝
---
ansible/setup.yml | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
create mode 100644 ansible/setup.yml
diff --git a/ansible/setup.yml b/ansible/setup.yml
new file mode 100644
index 00000000..ec572973
--- /dev/null
+++ b/ansible/setup.yml
@@ -0,0 +1,26 @@
+---
+- hosts: localhost
+ gather_facts: false
+ tasks:
+ - name: "Check and generate key if needed"
+ block:
+ - stat:
+ path: '{{ private_key }}.pub'
+ register: p
+
+ - command: ssh-keygen -f {{ private_key }} -t rsa -N ''
+ when: not p.stat.exists
+ vars:
+ private_key: /root/.ssh/offline_ssh_key
+
+- hosts: all
+ gather_facts: false
+ tasks:
+ - name: Setup authorized_keys file
+ authorized_key:
+ user: root
+ state: present
+ key: "{{ lookup('file', public_key) }}"
+ become: true
+ vars:
+ public_key: /root/.ssh/offline_ssh_key.pub
--
cgit 1.2.3-korg