From 539ca86edf00318aed36f0a75e3ecf4015dbfebe Mon Sep 17 00:00:00 2001 From: Georg Kunz Date: Thu, 27 Aug 2020 16:53:01 +0200 Subject: Rendering BMRA inventory from IDF and PDF via ansible This patch adds a simple playbook which renders the BMRA inventory from the supplied set of PDF and IDF. Signed-off-by: Georg Kunz Change-Id: I2cd555440ad51594d5a2b482bfad085769d0e4e0 Reviewed-on: https://gerrit.opnfv.org/gerrit/c/kuberef/+/70892 Tested-by: jenkins-ci Reviewed-by: Rihab Banday --- .gitignore | 4 ++-- deploy.env | 2 +- deploy.sh | 6 ++++++ hw_config/ericsson-pod1/idf.yaml | 6 +++--- hw_config/ericsson-pod2/idf.yaml | 14 ++++++-------- playbooks/bmra-config.yaml | 17 +++++++++++++++++ playbooks/roles/bmra-config/tasks/main.yaml | 4 ++++ playbooks/roles/bmra-config/templates/inventory.ini | 20 ++++++++++++++++++++ sw_config/bmra/inventory.ini | 18 ------------------ 9 files changed, 59 insertions(+), 32 deletions(-) create mode 100644 playbooks/bmra-config.yaml create mode 100644 playbooks/roles/bmra-config/tasks/main.yaml create mode 100644 playbooks/roles/bmra-config/templates/inventory.ini delete mode 100644 sw_config/bmra/inventory.ini diff --git a/.gitignore b/.gitignore index 5c469ed..01a8308 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,8 @@ user-data *.swp **/.DS_Store **/._.DS_Store -kuberef/inventory/group_vars/all/idf.yaml -kuberef/inventory/group_vars/all/pdf.yaml +inventory/group_vars/all/idf.yaml +inventory/group_vars/all/pdf.yaml images workspace .tox diff --git a/deploy.env b/deploy.env index 9c4a582..994a41a 100644 --- a/deploy.env +++ b/deploy.env @@ -1,6 +1,6 @@ # Define environment variables -export VENDOR=${VENDOR:-intel} +export VENDOR=${VENDOR:-ericsson-pod2} export INSTALLER=bmra # Name of host bridge to which the VM is connected to (used for PXE) diff --git a/deploy.sh b/deploy.sh index a491158..2b1e3ce 100755 --- a/deploy.sh +++ b/deploy.sh @@ -42,6 +42,12 @@ ansible-playbook -i "$CURRENTPATH"/inventory/localhost.ini \ ansible-playbook -i "$CURRENTPATH"/inventory/localhost.ini \ "$CURRENTPATH"/playbooks/jump-vm.yaml +# --------------------------------------------------------------------- +# Create BMRA config based on IDF and PDF +# --------------------------------------------------------------------- +ansible-playbook -i "$CURRENTPATH"/inventory/localhost.ini \ + "$CURRENTPATH"/playbooks/bmra-config.yaml + # --------------------------------------------------------------------- # Copy files needed by Infra engine & BMRA in the jumphost VM # --------------------------------------------------------------------- diff --git a/hw_config/ericsson-pod1/idf.yaml b/hw_config/ericsson-pod1/idf.yaml index 4f04bdb..e3da857 100644 --- a/hw_config/ericsson-pod1/idf.yaml +++ b/hw_config/ericsson-pod1/idf.yaml @@ -31,15 +31,15 @@ idf: - 8.8.8.8 kubespray: &idf_kubespray nodes_roles: - node1: [k8s-cluster, kube-node, kube-master, etcd, vault] + node1: [k8s-cluster, kube-master, etcd, vault] node2: [k8s-cluster, kube-node] groups: k8s-cluster: - kube-node - kube-master hostnames: - node1: master0 - node2: node0 + node1: master1 + node2: node1 network: # network mapping network_mapping: diff --git a/hw_config/ericsson-pod2/idf.yaml b/hw_config/ericsson-pod2/idf.yaml index a0215f7..9aee186 100644 --- a/hw_config/ericsson-pod2/idf.yaml +++ b/hw_config/ericsson-pod2/idf.yaml @@ -18,7 +18,6 @@ idf: gateway: 10.0.20.1 mask: 24 dns: - - 192.168.1.200 - 8.8.8.8 public: interface: 1 @@ -27,11 +26,10 @@ idf: gateway: 100.64.201.1 mask: 24 dns: - - 192.168.1.200 - 8.8.8.8 kubespray: &idf_kubespray nodes_roles: - node1: [k8s-cluster, kube-node, kube-master, etcd, vault] + node1: [k8s-cluster, kube-master, etcd, vault] node2: [k8s-cluster, kube-node] node3: [k8s-cluster, kube-node] node4: [k8s-cluster, kube-node] @@ -41,11 +39,11 @@ idf: - kube-node - kube-master hostnames: - node1: master0 - node2: node0 - node3: node1 - node4: node2 - node5: node3 + node1: master1 + node2: node1 + node3: node2 + node4: node3 + node5: node4 network: # network mapping network_mapping: diff --git a/playbooks/bmra-config.yaml b/playbooks/bmra-config.yaml new file mode 100644 index 0000000..5b020f1 --- /dev/null +++ b/playbooks/bmra-config.yaml @@ -0,0 +1,17 @@ +--- +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) Ericsson AB and others +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +- hosts: localhost + connection: local + gather_facts: false + become: false + + roles: + - role: bmra-config diff --git a/playbooks/roles/bmra-config/tasks/main.yaml b/playbooks/roles/bmra-config/tasks/main.yaml new file mode 100644 index 0000000..19b011a --- /dev/null +++ b/playbooks/roles/bmra-config/tasks/main.yaml @@ -0,0 +1,4 @@ +- name: write BMRA config + template: + src: "inventory.ini" + dest: "{{ kuberef_root }}/sw_config/bmra/inventory.ini" diff --git a/playbooks/roles/bmra-config/templates/inventory.ini b/playbooks/roles/bmra-config/templates/inventory.ini new file mode 100644 index 0000000..48ca5fd --- /dev/null +++ b/playbooks/roles/bmra-config/templates/inventory.ini @@ -0,0 +1,20 @@ +[all] +{% for node in nodes %} +{{ idf.kubespray.hostnames[node.name] }} ansible_host={{ node.interfaces[idf.net_config[engine.pxe_network].interface].address }} ip={{ node.interfaces[idf.net_config[engine.pxe_network].interface].address }} +{% endfor %} + +{% for role in ['kube-master', 'etcd', 'kube-node'] %} +[{{ role }}] +{% for node in nodes %} +{% if role in idf.kubespray.nodes_roles[node.name] %} +{{ idf.kubespray.hostnames[node.name] }} +{% endif %} +{% endfor %} + +{% endfor %} + +[k8s-cluster:children] +kube-master +kube-node + +[calico-rr] diff --git a/sw_config/bmra/inventory.ini b/sw_config/bmra/inventory.ini deleted file mode 100644 index 9fb9f41..0000000 --- a/sw_config/bmra/inventory.ini +++ /dev/null @@ -1,18 +0,0 @@ -[all] -master1 ansible_host=10.10.190.202 ip=10.10.190.202 -node1 ansible_host=10.10.190.203 ip=10.10.190.203 - -[kube-master] -master1 - -[etcd] -master1 - -[kube-node] -node1 - -[k8s-cluster:children] -kube-master -kube-node - -[calico-rr] -- cgit 1.2.3-korg