This is an automated email from the ASF dual-hosted git repository.

lfrolov pushed a commit to branch DLAB-1835
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git


The following commit(s) were added to refs/heads/DLAB-1835 by this push:
     new ac29fd0  [DLAB-1835]: changed hosts resolving for keycloak
ac29fd0 is described below

commit ac29fd04432f0e8183013e63b30a0ae86d86a34c
Author: leonidfrolov <[email protected]>
AuthorDate: Wed May 27 13:21:11 2020 +0300

    [DLAB-1835]: changed hosts resolving for keycloak
---
 .../scripts/deploy_keycloak/deploy_keycloak.py                | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git 
a/infrastructure-provisioning/scripts/deploy_keycloak/deploy_keycloak.py 
b/infrastructure-provisioning/scripts/deploy_keycloak/deploy_keycloak.py
index 8339991..d9cc06a 100644
--- a/infrastructure-provisioning/scripts/deploy_keycloak/deploy_keycloak.py
+++ b/infrastructure-provisioning/scripts/deploy_keycloak/deploy_keycloak.py
@@ -45,10 +45,13 @@ private_ip_address = "127.0.0.1"
 
 def resolving_hosts(os_user):
     if not exists('/home/{}/.hosts_resolved'.format(os_user)):
-        host = sudo('curl 
http://169.254.169.254/latest/meta-data/local-hostname').replace('\n', ' 
').split(' ')[-1:]
-        host_short = host.split('.')[0]
-        private_ip = sudo('curl 
http://169.254.169.254/latest/meta-data/local-ipv4').replace('\n', ' ').split(' 
')[-1:]
-        sudo('echo "{} {} {}" >> /etc/hosts'.format(private_ip, host, 
host_short))
+        host = sudo('curl 
http://169.254.169.254/latest/meta-data/local-hostname')
+        if 'unable to resolve host' in host:
+            host = str(host.replace("\r", " ").replace("\n", " ").split(" 
")[-1:]).strip("['']")
+            host_short = host.split('.')[0]
+            private_ip = str(sudo('curl 
http://169.254.169.254/latest/meta-data/local-ipv4')
+                         .replace("\r", " ").replace("\n", " ").split(" 
")[-1:]).strip("['']")
+            sudo('echo "{} {} {}" >> /etc/hosts'.format(private_ip, host, 
host_short))
         sudo('touch /home/{}/.hosts_resolved'.format(os_user))
 
 def ensure_jre_jdk(os_user):


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to