Skip to content

Commit

Permalink
Fix: Generate a single instance of Vagrant provisioning script (#1643)
Browse files Browse the repository at this point in the history
Several devices (frr, cumulus_nvue) need a custom Vagrant provisioning
script. That script resides in device-specific template and was
included with every device instance. This fix makes sure the script
appears in Vagrantfile only once.

Fixes #1597
  • Loading branch information
ipspace authored Dec 12, 2024
1 parent 1afe688 commit b071208
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions netsim/templates/provider/libvirt/Vagrantfile.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
VAGRANT_COMMAND = ARGV[0]

{% set _vagrant_scripts = namespace() %}
Vagrant.configure("2") do |config|
config.vm.provider :libvirt do |libvirt|
{% if addressing.mgmt._network|default(False) %}
Expand Down
4 changes: 4 additions & 0 deletions netsim/templates/provider/libvirt/cumulus_nvue-domain.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% if _vagrant_scripts.cumulus_nvue is not defined %}
{% set _vagrant_scripts.cumulus_nvue = True %}

$cumulus_script = <<-SCRIPT

function set_cumulus_password(){
Expand All @@ -24,6 +27,7 @@ fi

SCRIPT

{% endif %}
{{ name }}.ssh.insert_key = false
if VAGRANT_COMMAND == "ssh" or VAGRANT_COMMAND == "scp"
{{ name }}.ssh.username = 'cumulus'
Expand Down
7 changes: 7 additions & 0 deletions netsim/templates/provider/libvirt/frr-domain.j2
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
{% if _vagrant_scripts.frr is not defined %}
{% set _vagrant_scripts.frr = True %}

$frr_script = <<-SCRIPT
echo "Setting password for user Vagrant"
echo vagrant:{{ n.ansible_ssh_pass }} | chpasswd

echo "Enabling SSH password authentication"
sed -i -e "s#PasswordAuthentication no#PasswordAuthentication yes#" /etc/ssh/sshd_config
service sshd restart
SCRIPT

{% endif %}
{{ name }}.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true

{{ name }}.vm.provider :libvirt do |domain|
Expand Down

0 comments on commit b071208

Please sign in to comment.