From 356bc38a5fd9e9818870bbd7d270a055900ae641 Mon Sep 17 00:00:00 2001 From: Jack Ivanov Date: Tue, 26 Jun 2018 23:32:00 +0300 Subject: [PATCH] Skip a prompt about the SSH user if deploying to localhost --- roles/local/tasks/prompts.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/roles/local/tasks/prompts.yml b/roles/local/tasks/prompts.yml index 55b08d59..e4aaf7ec 100644 --- a/roles/local/tasks/prompts.yml +++ b/roles/local/tasks/prompts.yml @@ -5,16 +5,21 @@ register: _algo_server when: server is undefined +- name: Set the facts + set_fact: + cloud_instance_ip: "{{ server | default(_algo_server.user_input) }}" + - pause: prompt: | What user should we use to login on the server? (note: passwordless login required, or ignore if you're deploying to localhost) [root] register: _algo_ssh_user - when: ssh_user is undefined + when: + - ssh_user is undefined + - cloud_instance_ip != "localhost" - name: Set the facts set_fact: - cloud_instance_ip: "{{ server | default(_algo_server.user_input) }}" ansible_ssh_user: >- {% if ssh_user is defined %}{{ ssh_user }} {%- elif _algo_ssh_user.user_input is defined and _algo_ssh_user.user_input != "" %}{{ _algo_ssh_user.user_input }}