From c368a8d7fe8bb200b33574f85c3d904b0d436e1a Mon Sep 17 00:00:00 2001 From: Daniel Mellado Date: Mon, 27 May 2019 12:07:59 +0200 Subject: [PATCH 1/2] Add nsrx 18 --- defaults/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index cfa45fc..79110d8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,10 +1,10 @@ --- install_prereqs: False output_directory: output -enable_ssh_key_authentication: False +enable_ssh_key_authentication: True disable_firewall: False -create_qemu_script: False -create_inventory: False +create_qemu_script: True +create_inventory: True authentication_type: password wrap_images: False wrapper_image_name: ansible-network.img From 3ab18f087b7c9cf3ca37cfcbffbb19ba4bd2fadc Mon Sep 17 00:00:00 2001 From: Daniel Mellado Date: Tue, 14 Jan 2020 11:23:57 +0100 Subject: [PATCH 2/2] Add vqfx 18.1R3 support. This commit adds support for vqfx 18.1R3 images. --- defaults/main.yml | 4 ++++ tasks/vqfx/18.1R3/bootstrap.yaml | 6 ++++++ tasks/vqfx/18.1R3/configure.yaml | 8 ++++++++ templates/vqfx/18.1R3/config.j2 | 16 ++++++++++++++++ templates/vqfx/18.1R3/inventory.j2 | 10 ++++++++++ templates/vqfx/18.1R3/qemu.j2 | 3 +++ vars/vqfx/18.1R3/vars.yml | 20 ++++++++++++++++++++ 7 files changed, 67 insertions(+) create mode 100644 tasks/vqfx/18.1R3/bootstrap.yaml create mode 100644 tasks/vqfx/18.1R3/configure.yaml create mode 100644 templates/vqfx/18.1R3/config.j2 create mode 100644 templates/vqfx/18.1R3/inventory.j2 create mode 100644 templates/vqfx/18.1R3/qemu.j2 create mode 100644 vars/vqfx/18.1R3/vars.yml diff --git a/defaults/main.yml b/defaults/main.yml index 79110d8..3b1c4af 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -39,6 +39,10 @@ checksum_to_platform_version: platform: vqfx build_version: 17.4R1 src_image_format: qcow2 + cce6abf16e8d4fdcc178b0f6c8e7350929b1001a: + platform: vqfx + build_version: 18.1R3 + src_image_format: qcow2 734f3400b6fb38ad0cea88eed2379729cf7b081c: platform: vsrx build_version: 18.1R1 diff --git a/tasks/vqfx/18.1R3/bootstrap.yaml b/tasks/vqfx/18.1R3/bootstrap.yaml new file mode 100644 index 0000000..f70954a --- /dev/null +++ b/tasks/vqfx/18.1R3/bootstrap.yaml @@ -0,0 +1,6 @@ +--- +- name: Bootstrap VM + expect: + command: telnet localhost 8888 + responses: "{{ expect_responses }}" + timeout: "{{ bootstrap_timeout }}" diff --git a/tasks/vqfx/18.1R3/configure.yaml b/tasks/vqfx/18.1R3/configure.yaml new file mode 100644 index 0000000..8ed2c36 --- /dev/null +++ b/tasks/vqfx/18.1R3/configure.yaml @@ -0,0 +1,8 @@ +--- +- junos_config: + src: "{{ image_config_path | default (platform + '/' + build_version + '/config.j2') }}" + vars: + ansible_user: root + ansible_ssh_pass: root123 + ansible_port: 8022 + ansible_network_os: junos diff --git a/templates/vqfx/18.1R3/config.j2 b/templates/vqfx/18.1R3/config.j2 new file mode 100644 index 0000000..7e58e0d --- /dev/null +++ b/templates/vqfx/18.1R3/config.j2 @@ -0,0 +1,16 @@ +set system host-name {{ hostname }} +set system domain-name {{ domain_name }} + +set system services ssh root-login deny +{% if authentication_type == 'pubkey' %} +{% for key in admin_user_ssh_keys %} +set system login user {{ admin_user }} class super-user authentication ssh-rsa "ssh-rsa {{ key }}" +{% endfor %} +{% for key in regular_user_ssh_keys %} +set system login user {{ regular_user }} class operator authentication ssh-rsa "ssh-rsa {{ key }}" +{% endfor %} +{% else %} +set system login user {{ admin_user }} class super-user authentication encrypted-password {{ admin_user_password | password_hash('sha512') }} +set system login user {{ regular_user }} class operator authentication encrypted-password {{ regular_user_password | password_hash('sha512') }} +{% endif %} +set interfaces em0 unit 0 family inet dhcp force-discover diff --git a/templates/vqfx/18.1R3/inventory.j2 b/templates/vqfx/18.1R3/inventory.j2 new file mode 100644 index 0000000..8a80498 --- /dev/null +++ b/templates/vqfx/18.1R3/inventory.j2 @@ -0,0 +1,10 @@ +[junos] +{{ hostname }}.{{ domain_name }} + +[junos:vars] +ansible_network_os=junos +ansible_connection=local +ansible_host=localhost +ansible_port=8022 +ansible_user={{ admin_user }} +ansible_ssh_pass={{ admin_user_password }} diff --git a/templates/vqfx/18.1R3/qemu.j2 b/templates/vqfx/18.1R3/qemu.j2 new file mode 100644 index 0000000..e9ba6eb --- /dev/null +++ b/templates/vqfx/18.1R3/qemu.j2 @@ -0,0 +1,3 @@ +#!/bin/bash + +/usr/bin/qemu-system-x86_64 -nographic -m 6144 -smp 2 -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 -drive file={{ image_name }}.qcow2,if=ide & diff --git a/vars/vqfx/18.1R3/vars.yml b/vars/vqfx/18.1R3/vars.yml new file mode 100644 index 0000000..3443e0b --- /dev/null +++ b/vars/vqfx/18.1R3/vars.yml @@ -0,0 +1,20 @@ +--- +expect_responses: + 'login: ': root + 'root@:RE:0% ': cli + 'root> ': + - config + - request dhcp client renew all + - "\x1d" + 'root# ': + - set system root-authentication plain-text-password + - set system services ssh root-login allow + - set system services netconf ssh + - set interfaces em0 unit 0 family inet dhcp + - commit + - exit + 'New password': root123 + 'Retype new password': root123 + 'telnet>': quit + +qemu_command: "/usr/bin/qemu-system-x86_64 -nographic -m 2048 -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 -drive file=cloned_image,if=ide"