Skip to content

Commit

Permalink
Add vagrant output options for nxos and eos
Browse files Browse the repository at this point in the history
Will add a vagrant user with SSH key configured, and create
a .box file for use with vagrant-libvirt
  • Loading branch information
Michael Chapman committed Mar 22, 2018
1 parent edbe3bc commit 04deed8
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
8 changes: 8 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ regular_user: ansible
regular_user_password: omgsosecureregular789
enable_password: omgsosecuresecret789

# Will convert the output qcow2 to a .box that can be imported to vagrant
#build_vagrant_box: false
#
# Adds an admin user called vagrant with the vagrant insecure public key
# configured for ssh access
#add_vagrant_user: false
vagrant_sshkey: "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key"

checksum_to_platform_version:
89e0fc9dd45f5682ed222f36f1ea952b049b1888:
platform: nxos
Expand Down
13 changes: 13 additions & 0 deletions tasks/build_vagrant_box.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Include platform variables
include_vars:
dir: "{{ platform }}/{{ build_version }}"

- name: Get box building script
get_url:
url: https://raw.githubusercontent.com/vagrant-libvirt/vagrant-libvirt/master/tools/create_box.sh
dest: "{{ output_directory }}/create_box.sh"
mode: 0777

- name: Run box building script
shell: "bash {{ output_directory }}/create_box.sh {{output_directory}}/{{ platform }}.qcow2"
3 changes: 3 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@

- import_tasks: build_wrapper_image.yml
when: wrapper_linux_image is defined

- import_tasks: build_vagrant_box.yml
when: build_vagrant_box is defined and build_vagrant_box
5 changes: 5 additions & 0 deletions templates/eos/4.20.1F/config.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ username {{ regular_user }} secret {{ regular_user_password }} privilege 1

enable secret {{ enable_password }}

{% if add_vagrant_user is defined and add_vagrant
username vagrant secret vagrant privilege
user vagrant sshkey {{ vagrant_sshkey }}
{% endif %}

event-handler dhcp-ma1-on-boot
trigger on-boot
action bash /mnt/flash/dhcp-ma1-on-boot.sh
Expand Down
6 changes: 6 additions & 0 deletions templates/nxos/7.0.3.I7.3/config.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ interface mgmt0
username {{ admin_user }} password {{ admin_user_password }} role network-admin
username {{ regular_user }} password {{ regular_user_password }}

{% if add_vagrant_user is defined and add_vagrant_user %}
username vagrant password vagrant role network-admin
username vagrant sshkey {{ vagrant_sshkey }}
username vagrant shell bash
{% endif %}

boot nxos bootflash:nxos.7.0.3.I7.3.bin

0 comments on commit 04deed8

Please sign in to comment.