Add configure-jumphost role

Change-Id: I3958b550c5ce8e44d1eb8a2df5bc5de7bd3df926
diff --git a/playbooks/configure-targethosts.yml b/playbooks/configure-targethosts.yml
index 1b61556..d5d94c7 100644
--- a/playbooks/configure-targethosts.yml
+++ b/playbooks/configure-targethosts.yml
@@ -17,6 +17,13 @@
 # SPDX-License-Identifier: Apache-2.0
 # ============LICENSE_END=========================================================
 
+- hosts: jumphost
+  gather_facts: true
+  become: true
+
+  roles:
+    - role: configure-jumphost
+
 - hosts: baremetal
   gather_facts: false
   become: false
diff --git a/playbooks/roles/configure-jumphost/tasks/main.yaml b/playbooks/roles/configure-jumphost/tasks/main.yaml
new file mode 100644
index 0000000..0b99112
--- /dev/null
+++ b/playbooks/roles/configure-jumphost/tasks/main.yaml
@@ -0,0 +1,47 @@
+---
+# ============LICENSE_START=======================================================
+#  Copyright (C) 2019 The Nordix Foundation. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+
+# NOTE (fdegir): if the same machine/jumphost used for online and offline
+# deployments, the leftover pip config folder from offline deployments
+# cause issues for online ones so we remove it here
+- name: Delete outdated pip config directory
+  file:
+    path: "{{ ansible_env.HOME }}/.pip/"
+    state: absent
+  with_items:
+    - absent
+  when: execution_mode == "online-deployment"
+
+# NOTE (fdegir): this block is taken out from provision-engine-services
+# in order to make it agnostic to provisioner
+- block:
+  - name: Get IP of the jumphost from PDF
+    set_fact:
+      jumphost_ip: "{{ jumphost.interfaces[idf.net_config[engine.public_network | default('public')].interface].address }}"
+    delegate_to: localhost
+
+  - name: Update /etc/hosts with server FQDN
+    blockinfile:
+      path: /etc/hosts
+      block: |
+        {{ jumphost_ip }} {{ server_fqdn }}
+      marker: "# {mark} Ansible managed {{ server_fqdn }}"
+  when: execution_mode == "offline-deployment"
+
+# vim: set ts=2 sw=2 expandtab:
diff --git a/playbooks/roles/configure-targethosts/tasks/main.yaml b/playbooks/roles/configure-targethosts/tasks/main.yaml
index d4e7568..235e0c8 100644
--- a/playbooks/roles/configure-targethosts/tasks/main.yaml
+++ b/playbooks/roles/configure-targethosts/tasks/main.yaml
@@ -25,6 +25,8 @@
 - name: Log jumphost IP to console
   debug:
     msg: "Jumphost IP is {{ jumphost_ip }}"
+  delegate_to: localhost
+  run_once: true
 
 - name: Update /etc/hosts with server FQDN
   blockinfile: