From f67835393f48777d6f26f0cd1b6e177a5c0e83d0 Mon Sep 17 00:00:00 2001 From: marcsello Date: Thu, 11 Nov 2021 18:47:19 +0100 Subject: [PATCH] Fixed things --- ansible/inventory.yaml | 10 ---------- ansible/templates/netplan.yaml | 2 +- vm_generator_luna/generate.py | 18 +++++++++++++++++- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/ansible/inventory.yaml b/ansible/inventory.yaml index 44d3a79..fc1a7c0 100644 --- a/ansible/inventory.yaml +++ b/ansible/inventory.yaml @@ -10,11 +10,8 @@ cloud-1: ansible_user: ubuntu hosts: cloud-cluster-1-master-1: - ansible_host: 192.168.110.100 cloud-cluster-1-worker-1: - ansible_host: 192.168.110.101 cloud-cluster-1-worker-2: - ansible_host: 192.168.110.102 edge-1: @@ -28,11 +25,8 @@ edge-1: ansible_user: ubuntu hosts: edge-cluster-1-master-1: - ansible_host: 192.168.111.100 edge-cluster-1-worker-1: - ansible_host: 192.168.111.101 edge-cluster-1-worker-2: - ansible_host: 192.168.111.102 edge-2: become: true @@ -47,11 +41,8 @@ edge-2: ansible_user: ubuntu hosts: edge-cluster-2-master-1: - ansible_host: 192.168.112.100 edge-cluster-2-worker-1: - ansible_host: 192.168.112.101 edge-cluster-2-worker-2: - ansible_host: 192.168.112.102 site-1: vars: @@ -64,7 +55,6 @@ site-1: ansible_user: ubuntu hosts: site-emulator-1: - ansible_host: 192.168.113.100 all: children: diff --git a/ansible/templates/netplan.yaml b/ansible/templates/netplan.yaml index bce4927..05a0908 100644 --- a/ansible/templates/netplan.yaml +++ b/ansible/templates/netplan.yaml @@ -7,7 +7,7 @@ network: dhcp6: false gateway4: {{ ansible_default_ipv4.gateway }} addresses: - - "{{ ansible_host }}/24" + - "{{ ansible_default_ipv4.address }}/24" routes: {% for item in magic_routes %} - to: {{ item }} diff --git a/vm_generator_luna/generate.py b/vm_generator_luna/generate.py index dd42c41..d18b731 100644 --- a/vm_generator_luna/generate.py +++ b/vm_generator_luna/generate.py @@ -259,6 +259,20 @@ def run_xml(outdir:str, hostname:str, ram:int, net:str): ) +def run_ssh(outdir:str, hostname:str, ipaddr:str): + if not ipaddr: + return + + sshout_file = os.path.join(outdir, 'ssh_config') + with open(sshout_file, 'at') as f: + f.write("\n".join([ + f"Host {hostname}", + f"\tHostName {ipaddr}", + f"\tProxyJump luna", + "","" + ])) + + def main(): if len(sys.argv) < 3: @@ -270,7 +284,7 @@ def main(): img_src = sys.argv[3] outdir = sys.argv[4] - if stage not in ['all', 'img', 'iso', 'xml']: + if stage not in ['all', 'img', 'iso', 'xml', 'ssh']: print("Stage should be: all, img, iso or xml") return @@ -296,6 +310,8 @@ def main(): if stage in ['xml', 'all']: run_xml(outdir,hostname, ram, net) + if stage in ['ssh', 'all']: + run_ssh(outdir, hostname, ipaddr) if __name__ == "__main__": main()