summaryrefslogtreecommitdiffstats
path: root/ansible/setup.yml
diff options
context:
space:
mode:
Diffstat (limited to 'ansible/setup.yml')
-rw-r--r--ansible/setup.yml26
1 files changed, 26 insertions, 0 deletions
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