From b5fb58c4f1b71f49f45548f6932c631d51e85396 Mon Sep 17 00:00:00 2001 From: NilashishC Date: Wed, 24 Feb 2021 21:14:51 +0530 Subject: [PATCH 1/2] Add support for NX-OS 9.3.6 Signed-off-by: NilashishC --- defaults/main.yml | 5 +++++ tasks/nxos/9.3.6/bootstrap.yaml | 6 ++++++ tasks/nxos/9.3.6/configure.yaml | 10 ++++++++++ templates/nxos/9.3.6/config.j2 | 21 +++++++++++++++++++++ templates/nxos/9.3.6/inventory.j2 | 10 ++++++++++ templates/nxos/9.3.6/qemu.j2 | 3 +++ vars/nxos/9.3.6/vars.yml | 19 +++++++++++++++++++ 7 files changed, 74 insertions(+) create mode 100644 tasks/nxos/9.3.6/bootstrap.yaml create mode 100644 tasks/nxos/9.3.6/configure.yaml create mode 100644 templates/nxos/9.3.6/config.j2 create mode 100644 templates/nxos/9.3.6/inventory.j2 create mode 100644 templates/nxos/9.3.6/qemu.j2 create mode 100644 vars/nxos/9.3.6/vars.yml diff --git a/defaults/main.yml b/defaults/main.yml index 6567ca5..b91dc54 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -55,3 +55,8 @@ checksum_to_platform_version: platform: csr build_version: 16.03.05 src_image_format: qcow2 + f325cb1cfe8c29b673e76cc148ac290613e7cfd4: + platform: nxos + build_version: 9.3.6 + src_image_format: qcow2 + diff --git a/tasks/nxos/9.3.6/bootstrap.yaml b/tasks/nxos/9.3.6/bootstrap.yaml new file mode 100644 index 0000000..f70954a --- /dev/null +++ b/tasks/nxos/9.3.6/bootstrap.yaml @@ -0,0 +1,6 @@ +--- +- name: Bootstrap VM + expect: + command: telnet localhost 8888 + responses: "{{ expect_responses }}" + timeout: "{{ bootstrap_timeout }}" diff --git a/tasks/nxos/9.3.6/configure.yaml b/tasks/nxos/9.3.6/configure.yaml new file mode 100644 index 0000000..9bae179 --- /dev/null +++ b/tasks/nxos/9.3.6/configure.yaml @@ -0,0 +1,10 @@ +--- +- nxos_config: + src: "{{ image_config_path | default (platform + '/' + build_version + '/config.j2') }}" + save_when: always + vars: + ansible_user: admin + ansible_ssh_pass: admin + ansible_port: 8022 + ansible_network_os: nxos + ansible_host_key_checking: false diff --git a/templates/nxos/9.3.6/config.j2 b/templates/nxos/9.3.6/config.j2 new file mode 100644 index 0000000..fe9a9f6 --- /dev/null +++ b/templates/nxos/9.3.6/config.j2 @@ -0,0 +1,21 @@ +hostname {{ hostname }} +ip domain-name {{ domain_name }} + +interface mgmt0 + ip address dhcp + +{% if authentication_type == 'pubkey' %} +username admin password {{ admin_user_password }} +username {{ admin_user }} role network-admin +{% for key in admin_user_ssh_keys %} +username {{ admin_user }} sshkey ssh-rsa {{ key }} +{% endfor %} +{% for key in regular_user_ssh_keys %} +username {{ regular_user }} sshkey ssh-rsa {{ key }} +{% endfor %} +{% else %} +username {{ admin_user }} password {{ admin_user_password }} role network-admin +username {{ regular_user }} password {{ regular_user_password }} +{% endif %} + +boot nxos bootflash:nxos.7.0.3.I7.3.bin diff --git a/templates/nxos/9.3.6/inventory.j2 b/templates/nxos/9.3.6/inventory.j2 new file mode 100644 index 0000000..c1d0237 --- /dev/null +++ b/templates/nxos/9.3.6/inventory.j2 @@ -0,0 +1,10 @@ +[nxos] +{{ hostname }}.{{ domain_name }} + +[nxos:vars] +ansible_network_os=nxos +ansible_connection=local +ansible_host=localhost +ansible_port=8022 +ansible_user={{ admin_user }} +ansible_ssh_pass={{ admin_user_password }} diff --git a/templates/nxos/9.3.6/qemu.j2 b/templates/nxos/9.3.6/qemu.j2 new file mode 100644 index 0000000..4cd6926 --- /dev/null +++ b/templates/nxos/9.3.6/qemu.j2 @@ -0,0 +1,3 @@ +#!/bin/bash + +/usr/bin/qemu-system-x86_64 -nographic -m 6144 -enable-kvm -serial telnet:localhost:8888,server,nowait -monitor telnet:localhost:8889,server,nowait -netdev user,id=net0,hostfwd=tcp::8022-:22 -device e1000,netdev=net0 -netdev user,id=net1 -device e1000,netdev=net1 -netdev user,id=net2 -device e1000,netdev=net2 -device ahci,id=ahci0,bus=pci.0 -drive file={{ image_name }}.qcow2,if=none,id=drive-sata-disk0,format=qcow2 -device ide-drive,bus=ahci0.0,drive=drive-sata-disk0,id=drive-sata-disk0,bootindex=0 -bios /usr/share/edk2/ovmf/OVMF_CODE.fd & diff --git a/vars/nxos/9.3.6/vars.yml b/vars/nxos/9.3.6/vars.yml new file mode 100644 index 0000000..f3c416a --- /dev/null +++ b/vars/nxos/9.3.6/vars.yml @@ -0,0 +1,19 @@ +--- +expect_responses: + 'POAP DHCP Discover phase failed': '' + 'Abort Power On Auto Provisioning.*: ': 'skip' + 'login: ': admin + 'Password: ': '' + 'switch# ': + - config t + - "\x1d" + 'switch\(config\)# ': + - username admin password admin role network-admin + - interface mgmt0 + - exit + 'switch\(config-if\)# ': + - ip address dhcp + - exit + 'telnet>': quit + +qemu_command: "/usr/bin/qemu-system-x86_64 -nographic -m 6144 -enable-kvm -serial telnet:localhost:8888,server,nowait -monitor telnet:localhost:8889,server,nowait -netdev user,id=net0,hostfwd=tcp::8022-:22 -device e1000,netdev=net0 -device ahci,id=ahci0,bus=pci.0 -drive file=cloned_image,if=none,id=drive-sata-disk0,format=qcow2 -device ide-drive,bus=ahci0.0,drive=drive-sata-disk0,id=drive-sata-disk0,bootindex=0 -bios /usr/share/edk2/ovmf/OVMF_CODE.fd" From b94955a81fab85b15e57f671bb32996f1574f216 Mon Sep 17 00:00:00 2001 From: NilashishC Date: Wed, 24 Feb 2021 21:21:42 +0530 Subject: [PATCH 2/2] Update config Signed-off-by: NilashishC --- templates/nxos/9.3.6/config.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/nxos/9.3.6/config.j2 b/templates/nxos/9.3.6/config.j2 index fe9a9f6..baa8c14 100644 --- a/templates/nxos/9.3.6/config.j2 +++ b/templates/nxos/9.3.6/config.j2 @@ -18,4 +18,4 @@ username {{ admin_user }} password {{ admin_user_password }} role network-admin username {{ regular_user }} password {{ regular_user_password }} {% endif %} -boot nxos bootflash:nxos.7.0.3.I7.3.bin +boot nxos bootflash:nxos.9.3.6.bin