Updates to inventory generation and instance configuration
This change makes few updates to inventory generation mechanism,
where generated inventory.ini files are placed, and how they are
used during the deployment.
- move inventory generation out of create-stack role and place it
in newly created role, generate-inventory, for provisioner Heat.
This will help us when we work on generating generic inventory
by provisioners since both provisioners now use separate roles
to generate inventory.
- move tasks in configure-instances located in provisioner to
installer configure-targethosts playbook
- place generated inventory.ini under config_path to have it in
same place as before.
- symlink config_path/inventory.ini as engine/inventory/inventory.ini
instead of copying it so we have single source of inventory.
Change-Id: I53cd4b1e1c1f641afbb992cf08818bdfa4ab767e
diff --git a/playbooks/configure-targethosts.yml b/playbooks/configure-targethosts.yml
index de2f202..bda9326 100644
--- a/playbooks/configure-targethosts.yml
+++ b/playbooks/configure-targethosts.yml
@@ -17,6 +17,39 @@
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=========================================================
+- hosts: jumphost
+ gather_facts: false
+ become: false
+
+ tasks:
+ - name: Do initial configuration jumphost
+ block:
+ - name: Install python and python-dev
+ script: files/install-python.sh
+
+ - name: Copy SSH keys to jumphost for target node access
+ copy:
+ src: "{{ item }}"
+ dest: "/root/.ssh/"
+ owner: "root"
+ group: "root"
+ mode: 0600
+ with_items:
+ - "/home/{{ local_user }}/.ssh/id_rsa"
+ - "/home/{{ local_user }}/.ssh/id_rsa.pub"
+ when: provisioner_type == 'heat'
+
+- hosts: baremetal
+ gather_facts: false
+ become: false
+
+ tasks:
+ - name: Do initial configuration on target hosts
+ block:
+ - name: Install python and python-dev
+ script: files/install-python.sh
+ when: provisioner_type == 'heat'
+
- hosts: baremetal
gather_facts: true
diff --git a/playbooks/files/install-python.sh b/playbooks/files/install-python.sh
new file mode 100755
index 0000000..f0b5337
--- /dev/null
+++ b/playbooks/files/install-python.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+# ============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=========================================================
+
+set -o errexit
+set -o pipefail
+
+# NOTE: due to stack creation issues on public cloud, installation of python
+# and python-dev has been moved out of heat templates. The reason for this is
+# that during initial boot of the instances, Ansible prerequisites python and
+# python-dev are installed using boot script. Due to the reasons we can not
+# explain and perhaps because of network issues on public cloud, apt fails,
+# complaining about corruption - checksum mismatch. In turn, problematic
+# instance(s) can not send completion signal at the end of boot phase, resulting
+# in timeouts in stack creation thus complete failure of deployments.
+
+source /etc/os-release || source /usr/lib/os-release
+case ${ID,,} in
+ ubuntu|debian)
+ export DEBIAN_FRONTEND=noninteractive
+ sudo -H -E apt update -q=3
+ sudo -H -E apt install -y -q=3 python python-dev
+ ;;
+ rhel|fedora|centos)
+ sudo yum install -y python python-devel
+ ;;
+ *)
+ echo "ERROR: Supported package manager not found. Supported: apt, dnf, yum, zypper"
+ exit 1
+ ;;
+esac
+
+# vim: set ts=2 sw=2 expandtab: