From 811843b1a0190d8f93a1b26d2d266c19c24d6f8f Mon Sep 17 00:00:00 2001 From: Sagi Shnaidman Date: Wed, 13 Feb 2019 19:27:00 +0200 Subject: [PATCH] Use private IP for supplemental node When connecting to supplemental node use private IP as it's only available in this step. Change-Id: I1e57b9fe823263caa15522e84bf9482b5c47491b --- config/general_config/featureset039.yml | 6 ++++ .../files/remove_extra_node.py | 30 +++++++++++++++++++ roles/tripleo-inventory/tasks/inventory.yml | 15 +++++----- .../tripleo-inventory/templates/ssh_config.j2 | 6 ++-- 4 files changed, 47 insertions(+), 10 deletions(-) create mode 100644 roles/tripleo-inventory/files/remove_extra_node.py diff --git a/config/general_config/featureset039.yml b/config/general_config/featureset039.yml index eba0d210e..b46b46cbe 100644 --- a/config/general_config/featureset039.yml +++ b/config/general_config/featureset039.yml @@ -164,9 +164,15 @@ undercloud_container_cli: >- enable_tls_everywhere: true novajoin_connect_timeout: 60 novajoin_read_timeout: 60 +external_network_cidr: 10.0.0.0/24 + freeipa_admin_password: fce95318204114530f31f885c9df588f # Set node hostnames. +freeipa_internal_ip: "{{ external_network_cidr|nthhost(250) }}" +supplemental_node_ip: "{{ freeipa_internal_ip }}" +undercloud_undercloud_nameservers: ["{{ freeipa_internal_ip }}"] +overcloud_dns_servers: ["{{ freeipa_internal_ip }}", "8.8.8.8"] tripleo_domain: ooo.test undercloud_cloud_domain: "{{ tripleo_domain }}" freeipa_server_hostname: "ipa.{{ tripleo_domain }}" diff --git a/roles/tripleo-inventory/files/remove_extra_node.py b/roles/tripleo-inventory/files/remove_extra_node.py new file mode 100644 index 000000000..72be81866 --- /dev/null +++ b/roles/tripleo-inventory/files/remove_extra_node.py @@ -0,0 +1,30 @@ +#!/usr/bin/python +# Copyright 2019 Red Hat Inc. +# +# 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. + +import json +import sys + +with open(sys.argv[1] + "/instackenv.json") as f: + j = json.load(f) +with open(sys.argv[1] + "/instackenv.original.json", "w") as f: + json.dump(j, f, sort_keys=True, indent=4, separators=(',', ': ')) +for k in list(j): + for el in list(j[k]): + if 'extra' in el: + j[k].pop(el) + elif (isinstance(el, dict) and 'extra' in el.get('name')): + j[k].remove(el) +with open(sys.argv[1] + "/instackenv.json", "w") as f: + json.dump(j, f, sort_keys=True, indent=4, separators=(',', ': ')) diff --git a/roles/tripleo-inventory/tasks/inventory.yml b/roles/tripleo-inventory/tasks/inventory.yml index 27eccadf0..e9cd86bd1 100644 --- a/roles/tripleo-inventory/tasks/inventory.yml +++ b/roles/tripleo-inventory/tasks/inventory.yml @@ -75,16 +75,12 @@ executable: python3 register: node_ip - - name: set_fact for supplemental ip + - name: Set fact for private supplemental ip set_fact: - supplemental_node_ip: "{{ node_ip.stdout|replace('\n', '')|replace('\r', '')|trim }}" + supplemental_node_ip_private: "{{ node_ip.stdout|replace('\n', '')|replace('\r', '')|trim }}" cacheable: true when: node_ip.stdout - - name: Show the supplemental ip - debug: msg="Supplemental node IP = {{ supplemental_node_ip }}" - when: supplemental_node_ip is defined - - name: Add supplemental node vm to inventory add_host: name: supplemental @@ -95,7 +91,12 @@ ansible_private_key_file: '{{ extra_node_key }}' ansible_ssh_extra_args: '-F "{{ local_working_dir }}/ssh.config.ansible"' supplemental_node_ip: "{{ supplemental_node_ip }}" - when: supplemental_node_ip is defined + when: supplemental_node_ip_private is defined + + - name: Remove extra node + script: remove_extra_node.py {{ working_dir }} + args: + executable: python3 # readd the undercloud to reset the ansible_ssh parameters set in quickstart - name: Add undercloud vm to inventory diff --git a/roles/tripleo-inventory/templates/ssh_config.j2 b/roles/tripleo-inventory/templates/ssh_config.j2 index a76eae9b2..c2d226a33 100644 --- a/roles/tripleo-inventory/templates/ssh_config.j2 +++ b/roles/tripleo-inventory/templates/ssh_config.j2 @@ -43,10 +43,10 @@ Host undercloud StrictHostKeyChecking no UserKnownHostsFile=/dev/null -{% if deploy_supplemental_node|bool and supplemental_node_ip is defined %} +{% if deploy_supplemental_node|bool and supplemental_node_ip_private is defined %} Host supplemental - Hostname {{ supplemental_node_ip }} -{% if inventory == 'extra_node' %} + Hostname {{ supplemental_node_ip_private }} +{% if undercloud_type == 'ovb' %} IdentityFile {{ extra_node_key }} {% else %} ProxyCommand {{ supplemental_ssh_proxy_command }}