Giter Club home page Giter Club logo

vagrant-openwrt-box's Introduction

vagrant-openwrt-box

This repository builds OpenWrt Vagrant box from the officially distributed disk images according to following instructions. Image has 3 preconfigured network interfaces:

  • mng set to eth0
  • wan set to eth1
  • lan set to eth2

Building

  • To build all boxes simply run make all. Created Vagrant artifact will be stored in the .output folder.
  • To build a specific OpenWrt version run VERSION=22.03.4 make all
  • To build the Virtualbox box only run: make build-vb
  • To build the Libvirt box only run: make build-lv

Using

Simple use case

Vagrant.configure("2") do |config|
  config.vm.box = "vladimir-babichev/openwrt-22.03"
  config.vm.network "forwarded_port", guest: 80, host: 8080
end

Advanced use case

Vagrant.configure("2") do |config|
  config.vm.box = "vladimir-babichev/openwrt-22.03"
  config.vm.network "forwarded_port", guest: 80, host: 8080

  config.vm.provider "virtualbox" do |v|
    v.customize ["modifyvm", :id, "--nic2", "nat"]
    v.customize ["modifyvm", :id, "--nic3", "bridged", "--bridgeadapter3", "en0"]
  end
end

Provisioned VM will have 3 network adapters:

  • nic1 set to NAT and discovered as eth0 (mng) interface
  • nic2 set to NAT and discovered as eth1 (wan) interface
  • nic3 set to bridge with en0 and discovered as eth2 (lan) interface

More information about Vagrant can be found here.

Synced folders

Since version 2.2.15 Vagrant supports rsync synced folders for OpenWrt. By default, the content of the current folder synced into /root in the guest OS. To disable synchronization add the following snippet to your Vagrantfile:

config.vm.synced_folder ".", "/root", disabled: true

Network configuration

Vagrant does not support automatic network configuration for OpenWrt. As a result, network setup split into two stages:

  1. Attachment of network adapters to a virtual machine. See examples above.
  2. Network interface configuration from guest OS. See this and this.

By default, preconfigured network interfaces set to DHCP mode.

Provisioning

Inline Shell Scripts

Vagrant.configure("2") do |config|
  config.vm.box = "vladimir-babichev/openwrt-22.03"
  config.vm.network "forwarded_port", guest: 80, host: 8080

  config.vm.provision "shell", inline: <<-SHELL
    opkg update
    opkg remove wpad-mini
    opkg install wpad
  SHELL
end

Ansible Provisioner

Complete example of ansible provisioner can be found here.

Notes

Credentials

  • Username: root
  • Password: vagrant

Extra packages

  • rsync
  • sudo

vagrant-openwrt-box's People

Contributors

bjwschaap avatar renovate[bot] avatar vladimir-babichev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vagrant-openwrt-box's Issues

image for 22.03

Hi there, this project is pretty cool - I'm using to run tests for my ansible playbooks for openwrt hosts. thanks for maintaining this (and thanks for building in libvirt/qemu support) !

I can build my own box for 22.03 since there's a version variable in the makefile, but I was wondering if you were willing to publish an image on app.vagrantup.com with that version since it's now the most current openwrt release?

cheers!

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/pre-commit.yaml
  • actions/checkout v3
  • actions/setup-python v4
  • hashicorp-contrib/setup-packer v2
  • pre-commit/action v3.0.0
  • macos 12
.github/workflows/release.yaml
  • actions/checkout v3
  • hashicorp-contrib/setup-packer v2
  • softprops/action-gh-release v1
  • macos 10.15
pre-commit
.pre-commit-config.yaml
  • pre-commit/pre-commit-hooks v4.4.0
  • sirosen/texthooks 0.5.0
  • gruntwork-io/pre-commit v0.1.22
  • igorshubovych/markdownlint-cli v0.35.0

  • Check this box to trigger a request for Renovate to run again on this repository

Guest operating system detection error

When you shutdown with 'vagrant halt', I get the following error while using Vagrant 2.2.9 on Ubuntu gnu/Linux 19.10 machine.

$ vagrant halt
==> default: Attempting graceful shutdown of VM...
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
The guest operating system of the machine could not be detected!
Vagrant requires this knowledge to perform specific tasks such
as mounting shared folders and configuring networks. Please add
the ability to detect this guest operating system to Vagrant
by creating a plugin or reporting a bug.

Sudo is required for Vagrant shell provisioning

Trying to provision using inline shell scripts tend to fail with SSH error:

$ vagrant  provision 
==> default: Running provisioner: shell...
    default: Running: inline script
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

Debugging further I see that this might be due to missing sudo on openwrt ?

DEBUG ssh: == Net-SSH connection debug-level log END ==
 INFO ssh: Execute: chown -R root /tmp/vagrant-shell (sudo=true)
DEBUG ssh: stderr: ash: 
DEBUG ssh: stderr: sudo: not found
DEBUG ssh: stderr: 

Perhaps adding 'opkg install sudo' in packer build should resolve this problem?

Mac OS M1

Hi,

Does this box could be used on Mac OS M1 by vagrant qemu?

thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.