BIG-IP in a Vagrant Virtualbox Box
Tools
- a VE image in the OVA format
- a copy of packer from www.packer.io
- a copy of vagrant from www.vagrantup.com
The Template
{ "builders": [ { ... } ], "provisioners": [ { ... } ], "post-processors": [ { ... } ] }
The Builder
We're interested specifically in the Virtualbox builder. This builder accepts a type called "virtualbox-ovf" that takes an OVA as its input. Here's the builder that I used.
"builders": [ { "type": "virtualbox-ovf", "source_path": "BIGIP-11.6.0.0.0.401.LTM_1SLOT-ide.ova", "ssh_username": "root", "ssh_password": "default", "ssh_wait_timeout": "30000s", "headless": "false", "shutdown_command": "shutdown -h now", "import_flags": ["--eula", "accept"], "guest_additions_mode": "disable", "vm_name": "BIGIP-11.6.0.0.0.401.LTM_1SLOT-ide", "vboxmanage": [ ["modifyvm","{{.Name}}","--memory","4096"], ["modifyvm","{{.Name}}","--cpus","2"], ["modifyvm","{{.Name}}","--nic1","NAT"] ] } ]
There are several things to note in this builder.
ssh_wait_timeout
. BIG-IP takes longer to boot than the standard Vagrant SSH wait timeout, so I override it here to account for that.TCP connection to SSH ip/port failed: dial tcp 127.0.0.1:3819: getsockopt: connection refused
The Provisioner
- Install sudo
- Create the "vagrant" user
- Add the insecure vagrant key to that vagrant user's authorized_keys file
"provisioners": [ { "type": "shell", "inline": [ "mount -o remount,rw /dev/mapper/vg--db--hda-set.1._usr /usr", "curl -o /tmp/sudo-1.8.16-1.el5.x86_64.rpm http://repo.centos.org/sudo-1.8.16-1.el5.x86_64.rpm", "rpm -Uvh /tmp/sudo-1.8.16-1.el5.x86_64.rpm", "tmsh create auth user vagrant password vagrant partition-access add { all-partitions { role admin } } shell bash", "echo 'vagrant ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/vagrant", "mkdir -p /home/vagrant/.ssh", "chmod 0700 /home/vagrant/.ssh", "curl --insecure -L -o /home/vagrant/.ssh/authorized_keys https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub", "chmod 0600 /home/vagrant/.ssh/authorized_keys", "chown -R vagrant /home/vagrant/.ssh", "tmsh save sys config" ] } ]
The Post-processor
We are specifically interested in creating a Vagrant box, so we run the output through the vagrant post-processor to give us one.
"post-processors": [ { "type": "vagrant", "compression_level": 1, "output": "BIGIP-11.6.0.0.0.401.LTM_1SLOT-ide.box" } ],
PACKER_LOG=1 packer build template.json
References
- Kevin_Davies_40NacreousSeveral kinds if awesome right here. Thank you for all the info.
- Bart_Van_BosEmployee
Is this method still working/supported on BIGIP-15.1.0-0.0.31.LTM_1SLOT?
After changing the password back to default (by doing an intermediate step to another password, as the first login requires a mandatory password change), packer seems to fail to connect with Big-IP over ssh. I can login with the credentials in the VirtualBox UI console though.
2020/01/20 05:24:53 packer-builder-virtualbox-ovf plugin: [DEBUG] reconnecting to TCP connection for SSH 2020/01/20 05:24:53 packer-builder-virtualbox-ovf plugin: [DEBUG] handshaking with SSH 2020/01/20 05:24:53 packer-builder-virtualbox-ovf plugin: [DEBUG] SSH handshake err: ssh: handshake failed: read tcp 127.0.0.1:59384->127.0.0.1:4169: read: connection reset by peer 2020/01/20 05:25:00 packer-builder-virtualbox-ovf plugin: [INFO] Attempting SSH connection to 127.0.0.1:4169... 2020/01/20 05:25:00 packer-builder-virtualbox-ovf plugin: [DEBUG] reconnecting to TCP connection for SSH 2020/01/20 05:25:00 packer-builder-virtualbox-ovf plugin: [DEBUG] handshaking with SSH
If I look into the Virtualbox UI, I see that mcpd and devmgmtd are in a crashloop.
logger[22111] Re-starting mcpd logger[22818] Re-starting devmgmtd logger[22332] Re-starting mcpd ...
The output of dmesg shows the tmm interface flapping.
IPv6: ADDRCONF(NETDEV_CHANGE): tmm: link becomes ready IPv6: ADDRCONF(NETDEV_UP: tmm: link is not ready traps: mcpd[17749] trap divide error ip:56c01093 sp:ffe15:0 in libmcpdcommon.so[5678f000+67c000] IPv6: ADDRCONF(NETDEV_CHANGE): tmm: link becomes ready IPv6: ADDRCONF(NETDEV_UP: tmm: link is not ready traps: mcpd[18214] trap divide error ip:56c01093 sp:ffe15:0 in libmcpdcommon.so[5678f000+67c000] ...