Ensure that ssh keys and configs are exist Fixes #250 (#254)

pull/262/head
Jack Ivanov 7 years ago committed by GitHub
parent 9d3a65b555
commit 1cca3b1093

@ -308,6 +308,13 @@ Enter the public IP address of your server: (IMPORTANT! This IP is used to verif
ROLES="local vpn"
EXTRA_VARS="server_ip=$server_ip server_user=$server_user IP_subject_alt_name=$IP_subject"
SKIP_TAGS+=" cloud update-alternatives"
read -p "
Was this server deployed by Algo previously?
[y/N]: " -r Deployed_By_Algo
Deployed_By_Algo=${Deployed_By_Algo:-n}
if [[ "$Deployed_By_Algo" =~ ^(y|Y)$ ]]; then EXTRA_VARS+=" Deployed_By_Algo=Y"; fi
}
algo_provisioning () {

@ -9,6 +9,12 @@
include: playbooks/local.yml
tags: [ 'always' ]
- name: Local pre-tasks
include: playbooks/local_ssh.yml
become: false
when: Deployed_By_Algo is defined and Deployed_By_Algo == "Y"
tags: [ 'local' ]
roles:
- { role: cloud-digitalocean, tags: ['digitalocean'] }
- { role: cloud-ec2, tags: ['ec2'] }
@ -17,24 +23,10 @@
- { role: local, tags: ['local'] }
post_tasks:
- name: Wait until SSH becomes ready...
local_action:
module: wait_for
port: 22
host: "{{ cloud_instance_ip }}"
search_regex: "OpenSSH"
delay: 10
timeout: 320
state: present
- name: Local pre-tasks
include: playbooks/post.yml
become: false
tags:
- cloud
- name: A short pause, in order to be sure the instance is ready
pause:
seconds: 10
tags:
- cloud
tags: [ 'cloud' ]
- name: Configure the server and install required software
hosts: vpn-host

@ -0,0 +1,23 @@
---
- name: Ensure the local ssh directory is exist
local_action:
module: file
path: "~/.ssh/"
state: directory
- name: Copy the algo ssh key to the local ssh directory
local_action:
module: copy
src: configs/algo.pem
dest: ~/.ssh/algo.pem
mode: '0600'
- name: Configure the local ssh config
blockinfile:
dest: "~/.ssh/config"
marker: "# {mark} ALGO MANAGED BLOCK {{ cloud_instance_ip|default(server_ip) }}"
insertbefore: BOF
block: |
Host {{ cloud_instance_ip|default(server_ip) }}
IdentityFile ~/.ssh/algo.pem

@ -0,0 +1,17 @@
---
- name: Wait until SSH becomes ready...
local_action:
module: wait_for
port: 22
host: "{{ cloud_instance_ip }}"
search_regex: "OpenSSH"
delay: 10
timeout: 320
state: present
- name: A short pause, in order to be sure the instance is ready
pause:
seconds: 10
- include: local_ssh.yml
Loading…
Cancel
Save