{"id":15478467,"url":"https://github.com/edin-m/node-vagrant","last_synced_at":"2025-04-22T14:48:18.702Z","repository":{"id":27639128,"uuid":"31123790","full_name":"edin-m/node-vagrant","owner":"edin-m","description":"Node js wrapper for vagrant CLI - command line tool.","archived":false,"fork":false,"pushed_at":"2021-06-12T14:27:37.000Z","size":218,"stargazers_count":27,"open_issues_count":2,"forks_count":15,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-18T07:51:51.494Z","etag":null,"topics":["nodejs-wrapper","vagrant"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/edin-m.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-21T11:41:21.000Z","updated_at":"2024-01-11T23:42:17.000Z","dependencies_parsed_at":"2022-09-03T16:50:43.679Z","dependency_job_id":null,"html_url":"https://github.com/edin-m/node-vagrant","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edin-m%2Fnode-vagrant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edin-m%2Fnode-vagrant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edin-m%2Fnode-vagrant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edin-m%2Fnode-vagrant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edin-m","download_url":"https://codeload.github.com/edin-m/node-vagrant/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250262966,"owners_count":21401774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nodejs-wrapper","vagrant"],"created_at":"2024-10-02T04:04:34.115Z","updated_at":"2025-04-22T14:48:18.673Z","avatar_url":"https://github.com/edin-m.png","language":"JavaScript","readme":"# node-vagrant\nNode js wrapper for vagrant CLI - command line tool.\n\nThis is light wrapper around vagrant CLI.\nIt uses spawn process, and every command requiring user input\nsuch as init and destroy is created with switch --force or -f.\n\n[![npm version](https://badge.fury.io/js/node-vagrant.svg)](https://badge.fury.io/js/node-vagrant)\n[![Build Status](https://travis-ci.org/edin-m/node-vagrant.svg?branch=master)](https://travis-ci.org/edin-m/node-vagrant)\n\nInstallation\n===\n\n```\n$ npm install node-vagrant --save\n```\n\nUsage\n===\n\nAll callbacks are node style:\n```js\nfunction(err, out)\n```\nwhere err is stderr if exit code != 0 and out is stdout if exit code == 0\n___\nOther commands\n```js\n// import vagrant\nvar vagrant = require('node-vagrant');\n\n// view version\nvagrant.version(function(err, out) {});\n// or --version ; out = { status: '2.0.3', major: 2, minor: 0, patch: 3 }\nvagrant.versionStatus(function(err, out) {});\n\n// view global status\n// you can specify '--prune' as additional argument. By default global-status is based on a cache,\n// prune removes invalid entries from the list.\n// Note that this is much more time consuming than simply listing the entries.\nvagrant.globalStatus(function(err, out) {});\nvagrant.globalStatus('--prune', function(err, out) {});\n\n// vagrant machine\n\n// create machine - does not run command or init machine\n// you can specify directory where Vagrantfile will be located\n// and machine instanced\nvar machine = vagrant.create({ cwd: \u003cString\u003e, env: \u003cObject\u003e }) // cwd and env default to process' values\n\n// init machine\n// you can specify additional arguments by using array (applicable to other functions)\nmachine.init('ubuntu/trusty64', function(err, out) {});\nmachine.init(['ubuntu/trusty64'], function(err, out) {});\n// -f is set by default\nmachine.init(['ubuntu/trusty64', '-f'], function(err, out) {});\n\n// up\nmachine.up(function(err, out) {})\n\n// status\nmachine.status(function(err, out) {});\n\n// get ssh config - useful to retrieve private and connect to machine with ssh2\n// out is an array of objects [{}] with properties: port, hostname, user, private_key\nmachine.sshConfig(function(err, out) {});\n\n// execute an ssh command on the machine\nmachine.on('ssh-out', console.log);\nmachine.on('ssh-err', console.error);\nmachine.sshCommand('echo \"a bash command\"');\n\n// provision\nmachine.provision(function(err, out) {});\n\n// suspend\nmachine.suspend(function(err, out) {});\n\n// resume\nmachine.resume(function(err, out) {});\n\n// reload\nmachine.reload(function(err, out) {});\n\n// halt\nmachine.halt(function(err, out) {});\n\n// destroy\n// uses -f by default\nmachine.destroy(function(err, out) {});\n\n// snapshots\n// push, pop, save, delete, restore, list and a snapshot() function.\n// example:\nmachine.snapshots().push(cb);\n\n// box repackage\n// must be specific to a vagrant environment hence location in machine\nmachine.boxRepackage(name, provider, version, function(err, out) {})\n\n// plugins\n// expunge, install, uninstall, repair, update, list and a plugin() function.\n// example:\nmachine.plugin().expunge(args, cb);\n\n// DEPRECATED! For backward compatibility only\nmachine.pluginUpdate(function(err, out) {});\nmachine.pluginRepair(function(err, out) {});\n\n// boxes\n\n// box add\n// uses -f by default\n// depending on type of box provided (name,address,file,json) missing information may be prompted.\n// please ensure that your add metheod is specific.\nvagrant.boxAdd(box, args, function(err, out) {})\n    .on('progress', function(out) {});\n\n// box list\n// out is an array of objects [{}] with properties: name, provider, version\nvagrant.boxList(args, function(err, out) {});\n\n// box outdated\n// --global is used by default\n// out is an array of objects [{}] with properties: name, status, currentVersion, latestVersion\n// status can be 'up to date' 'out of date' 'unknown'\n// if status is unknown currentVersion and latestVersion will be null\nvagrant.boxOutdated(args, function(err, out) {});\n\n// box prune\n// uses -f by defaultprune\nvagrant.boxPrune(args, function(err, out) {});\n\n// box remove\n// uses -f by default\nvagrant.boxRemove(name, args, function(err, out) {});\n\n// box repackage\n// avalible in machine\n\n// box update\n// uses the --box and --provider flags by default\n// provider can be null and in that case no --provider arg is added\nvagrant.boxUpdate(box, provider, function(err, out) {});\n    .on('progress', function(out) {});\n\n\n// args\n// should be array of args or a string for single flag see --prune abov\n// ie\nvagrant.boxAdd('ubuntu/trusty64', ['--clean', '--provider', 'virtualbox'], function(err, out) {})\n//or simply\nvagrant.boxAdd('ubuntu/trusty64', '--clean', function(err, out) {})\n```\n\nEvents\n===\n```js\n.on('up-progress', function(out) {}); // receive stdout progress from up of vagrant\n\n.on('progress', function(out) {}); // receive stdout box download progress\n```\n\nReceive any stdout/stderr output from a child subprocess. These work only on a Machine instance:\n\n```\nmachine.on('stdout', function(data) {}); // data is a Buffer\nmachine.on('stderr', function(data) {}); // data is a Buffer\n```\n\nExample\n===\n\nExample script of a usage is in example/example.js\n\n```\n$ npm run example\n```\n\nFlags \u0026 env vars\n===\n\nDebug the commands sent to vagrant:\n```js\n$ NODE_DEBUG=1 node example.js\nnode-vagrant command: [ 'global-status' ]\nnode-vagrant command: [ 'version' ]\n```\n\nDisable the debug:\n```js\n$ NODE_DEBUG=1 NODE_VAGRANT_DISABLE_DEBUG=1 node example.js\n```\n\nCustom vagrant location:\n```js\n$ VAGRANT_DIR=/custom/path node example.js\n```\n\nPromises\n===\n\n```js\nvar vagrant = require('../index');\nvagrant.promisify();\n\nvagrant.init('ubuntu/trusty64').then(successCb, errorCb);\n```\n\nTODO\n===\n- [ ] multi-machine\n- [ ] more detail vagrant file settings\n    - [ ] firewall\n    - [ ] networking\n- [x] boxing\n- [x] provisoning\n- [x] providers\n- [x] (native) promises (if available)\n- [ ] use ES6 (after which will become version 2.x.x)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedin-m%2Fnode-vagrant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedin-m%2Fnode-vagrant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedin-m%2Fnode-vagrant/lists"}