Giter Club home page Giter Club logo

vagrant-notify's Introduction

⚠️ UNMAINTAINED ⚠️

This project has been archived. Thanks a lot to everyone that contributed with it and used it over the years ❤️‍🔥

If anyone else wants to resurrect it please reach out on Twitter or by other means listed in @fgrehm's website!

vagrant-notify

Build Status Gem Version

A Vagrant plugin that forwards notify-send from guest to host machine and notifies provisioning status. See it in action

Installation

Make sure you have Vagrant 1.4+ around and run:

$ vagrant plugin install vagrant-notify

Usage

notify-send from guest VMs

Whenever you run vagrant up, a Ruby TCPServer will fire up on a port within the usable port range and a Ruby script will be copied over to the guest machine to replace the original notify-send command.

Provisioning notification

Apart from redirecting notify-send from the guest VM to the host, whenever a Vagrant 1.4+ provisioner starts or completes running you'll also receive notifications like:

provisioning

provisioned

Linux

Since Linux distributions have notify-send pre-installed, everything should work out of the box.

OS X

Check out our OS X notify-send compatible scripts.

Windows

Check out our Windows notify-send compatible scripts.

Configuration

Notification server is enabled by default on all guests. You can individually disable the plugin by adding a false boolean to the notify.enable option in your Vagrantfile configuration block

Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/trusty64"
  config.notify.enable = false
end

Please note that as of v0.5.1, the notification server will automatically be disabled for any of the following cloud providers.

By default, the notification server is binded to local interfaces. For networking different than your provider's default network configuration, you can use the notify.bind_ip configuration option to bind the notification server onto a different local ip address.

Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/trusty64"
  config.notify.bind_ip = "192.68.56.20"
end

WARNING! Do NOT bind the notification server to an IP accessible over a network! The notification server does not have any authentication and doing so will leave your system vulnerable to remote command execution.

By default the local notification server uses the notify_send command in your host PATH for displaying notifications, there is a possibility to use different app without wrapper scripts:

  • notify.sender_app configuration option is used for specifing application name (default: notify-send)
  • notify.sender_params_str defines how params for applications will be passed (default: [--app-name {app_name}] [--urgency {urgency}] [--expire-time {expire_time}] [--icon {icon}] [--category {category}] [--hint {hint}] {message}). You can use these variables (escaped by { and } characters) here:
    • urgency - urgency level for notification
    • expire_time - when notification will expire?
    • app_name - application name
    • icon - icon for the notification (can be multiple, devided by comma)
    • category - category for the notification (can be multiple, devided by comma)
    • hint - icon for the notification (need to use this format: TYPE:NAME:VALUE)
    • message - message to send
  • notify.sender_params_escape - should params will be escaped when passed to script (default: true)

This is example how to to run notifications with build-in MacOS X notifications support:

Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/trusty64"
  config.notify.sender_params_str = '-e \'display notification {message} sound name \"default\"\''
  config.notify.sender_app = 'osascript'
  config.notify.sender_params_escape = true
end

Providers and Guests

vagrant-notify supports the following providers:

vagrant-notify has been tested and known to work with Linux, Solaris 11, FreeBSD, OpenBSD, and NetBSD guests. (notify-send icon forwarding feature is not supported on BSD guests)

Demo

Demo Demo OS X Demo Windows

Known issues

  • On rare occasions the notification server may stop receiving notifications if the host is suspended/hibernates. The notification server may need to be manually restarted if that's the case. vagrant notify --restart

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

vagrant-notify's People

Contributors

alpha01 avatar bitdeli-chef avatar dependabot[bot] avatar fgrehm avatar jronallo avatar mekdrop 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vagrant-notify's Issues

Notification when provisioning fails

This is a great plugin! Any obstacle to adding a handler for provisioner failures? Seems to just notify on start and successful completion atm.

Call for Maintainers

Hey guys!

Life, as it tends to do, has progressed for me in such a way that I am no longer able to devote time to maintaining this plugin, especially as I no longer use it on a daily basis.

As such, this project has been neglected and I apologize for that. I am hoping there is someone who would be willing to step up and take over maintaining this project so it gets the attention it deserves. If you would like to do so, please respond with a comment explaining a bit about what you would like to do as a maintainer of this project. I'll then add one or more of those users as collaborators.

Cheers!

notify-send cannot use custom notifier

I wrote my own notification center app that has more going on under the hood than the terminal-notifier script.

How can I get notify-send from the guest VM to send the message back to my own app?

notify-send "message" -> my-app --message "message"

Doesn't listen on all addresses?

Hi, this plugin is a really great idea! One issue I had was that it looks like by default the server listens on 127.0.0.1, but if my guests are connected on a different interface (eg. with address 10.0.3.1 for lxc), they can't connect and get "Connection refused" when trying to connect. I tried fiddling with iptables and then finally just set the listen address to 0.0.0.0 and that worked, but I assume if this plugin works for other people I might be doing something wrong?

My guest is a vagrant-lxc guest, so I wonder if that has something to do with it.

Any help is appreciated. Thanks!

Some *nix like boxes has restrictions for modifying system files and vagrant-notify fails in such scenarios

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mv /tmp/notify-send /usr/bin/notify-send && chmod +x /usr/bin/notify-send

Stdout from the command:



Stderr from the command:

mv: rename /tmp/notify-send to /usr/bin/notify-send: Operation not permitted

This is how such error message looks.

These are steps to reproduce such scenario (this one works only with VirtualBox provider!):

  1. vagrant init http://files.dryga.com/boxes/osx-sierra-0.3.1.box
  2. vagrant up

I think if command fails in such scenarios, error at least must be more user friendly or in best case scenario no such error should be shown.

Error File Not Found

Any ideas?

08:22:37] gulp-notify: [Error in notifier] Error in plugin 'gulp-notify'
Command failed: /usr/lib/ruby/1.9.1/fileutils.rb:1371:in `initialize': No such file or directory - /tmp/vagrant-notify/-home-vagrant-Development-mowermatcher-node_modules-gulp-notify-assets-gulp.png

"sh: notify-send: command not found" in homestead on MacOS X

Strange thing that this happens after I did sudo DEBIAN_FRONTEND=noninteractive apt-get install -q -y ruby-full and everything should work. However this for me works if I run on windows host.

I'm unsure if this is some plugin issue or virtualbox or vagrant... do you have any ideas?

add more details to the built-in notifications

This line is nice:

https://github.com/fgrehm/vagrant-notify/blob/master/lib/vagrant-notify/action/notify_provisioning_status.rb#L10

But it results in messages like this:
"Provisioning with shell..."
and
"Finished provisioning with shell."

Which is cool, however, it would be even better if we had a bit more of an idea of what each shell provisioner is doing. For Vagrantfiles with many inline shell provisioners, you get lots of notifications, but no detail, which isn't very useful. I know, stop using inline shell provisioners... Perhaps, someday. But, a little more detail for these notifications would be handy for many people, I think?

add support for alternate providers

right now it looks like virtualbox is assumed (baked right into plugin.rb) - i use the parallels provider and would love to see support for other providers.

i'm happy to fork and try to take a stab at this but would love to hear your thoughts first though - i haven't developed any vagrant plugins before and i'd love to hear your thoughts before i jump it (for example, would this even be possible lol!)

one thing to note actually is that port forwarding isn't yet implemented in the parallels provider. not sure that's even relevant since this seems to work the opposite way around (creating a server on the host and sending data from the guest) but i figured it's worth mentioning.

Project status?

@alpha01 hey there! how's it going? Long time no chat 🍻

Are you still using this plugin and is willing to maintain it moving forward? I'm going through some old projects I own and making sure they are still healthy when it comes to interest and maintainers.

I am considering archiving this one unless I know for sure that ppl are using and it has a maintainer with some level of commitment 😃 🤘

Doesn't work when guest missing ruby

If the guest is missing ruby like for instance on a laravel/homestead box the plugin does't attempt to install ruby or warn about it and instead it just fails to work.

Is this intended?

Port Collision

Failed shared folder error gets triggered during a host network port collision.

vagrant notify stops homestead from working

After installing vagrant notify and running vagrant, I get the following error message when running vagrant up.

An error occurred in the underlying SSH library that Vagrant uses.
The error message is shown below. In many cases, errors from this
library are caused by ssh-agent issues. Try disabling your SSH
agent or removing some keys and try again.

If the problem persists, please report a bug to the net-ssh project.

timeout during server version negotiating

I can still access it with ssh, but the file mapping is not occurring, so it's not much use to me.
Uninstalling the plugin solves the issue, but I would rather use it of course!

Homestead : 0.4.2 and 0.4.4 don't work
Vagrant : 1.8.1
Virtualbox : 5.0.18_Ubuntu r106667
OS: Ubuntu 16.04
Vagrant-Notify: 0.4.0

Unable to start notification server using

  • OS X: 10.12.5
  • Vagrant: 1.9.5
  • Virtualbox: 5.1.22
  • Homestead: v5.4.0
vagrant resume

==> homestead-7: Resuming suspended VM...
==> homestead-7: Booting VM...
==> homestead-7: Waiting for machine to boot. This may take a few minutes...
    homestead-7: SSH address: 127.0.0.1:2222
    homestead-7: SSH username: vagrant
    homestead-7: SSH auth method: private key
==> homestead-7: Machine booted and ready!
==> homestead-7: Unable to start notification server using
/Users/john/.vagrant.d/gems/2.2.5/gems/vagrant-notify-0.5.5/lib/vagrant-notify/data.rb:11:in `unlink': No such file or directory @ dir_s_rmdir - /Users/john/Homestead/.vagrant/machines/homestead-7/virtualbox/vagrant-notify/bind_ip (Errno::ENOENT)
    from /Users/john/.vagrant.d/gems/2.2.5/gems/vagrant-notify-0.5.5/lib/vagrant-notify/data.rb:11:in `delete'
    from /Users/john/.vagrant.d/gems/2.2.5/gems/vagrant-notify-0.5.5/lib/vagrant-notify/data.rb:11:in `[]='
    from /Users/john/.vagrant.d/gems/2.2.5/gems/vagrant-notify-0.5.5/lib/vagrant-notify/action.rb:35:in `block (4 levels) in action_start_server'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/builtin/call.rb:47:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/builtin/call.rb:47:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/john/.vagrant.d/gems/2.2.5/gems/vagrant-notify-0.5.5/lib/vagrant-notify/action/prepare_data.rb:19:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/john/.vagrant.d/gems/2.2.5/gems/vagrant-notify-0.5.5/lib/vagrant-notify/action/start_server.rb:35:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/runner.rb:66:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/runner.rb:66:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/builtin/call.rb:53:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/john/.vagrant.d/gems/2.2.5/gems/vagrant-notify-0.5.5/lib/vagrant-notify/action/prepare_data.rb:19:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/runner.rb:66:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/runner.rb:66:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/builtin/call.rb:53:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/builtin/wait_for_communicator.rb:71:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/builtin/provision.rb:80:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/providers/virtualbox/action/resume.rb:20:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:49:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb:30:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/builtin/env_set.rb:19:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/providers/virtualbox/action/check_accessible.rb:18:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/runner.rb:66:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/runner.rb:66:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/builtin/call.rb:53:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/runner.rb:66:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/runner.rb:66:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/machine.rb:225:in `action_raw'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/machine.rb:200:in `block in action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/environment.rb:567:in `lock'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/machine.rb:186:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/machine.rb:186:in `action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/commands/resume/command.rb:35:in `block in execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/v2/command.rb:235:in `block in with_target_vms'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/v2/command.rb:229:in `each'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/v2/command.rb:229:in `with_target_vms'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/commands/resume/command.rb:34:in `execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/cli.rb:42:in `execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/environment.rb:308:in `cli'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/bin/vagrant:138:in `<main>'

terminal-notifier is not part of the bundle. Add it to Gemfile. (Gem::LoadError)

I'm getting the following error whilst trying to get this workflow set up.

/Applications/Vagrant/embedded/gems/gems/bundler-1.5.3/lib/bundler/rubygems_integration.rb:240:in `block in replace_gem': terminal-notifier is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
from /usr/bin/terminal-notifier:22:in `<main>'

All I've done is install the plugin vagrant plugin install vagrant-notify, created the following script at /usr/local/bin/notify-send (on OSX) and run vagrant up.

#!/bin/bash
terminal-notifier -title "Vagrant Machine" -message "$*"

The machine provisions without issue and then the error appears whenever notify-send is called on the virtual machine. In this case it's a 32bit Ubuntu 13.10 machine.

I can't get get my head around what the error is telling me; it seems like the host vagrant installation doesn't have access to a 'terminal-notifier' command. But I wouldn't know how to fix or get round that.

Any thoughts?

Error obtaining client ip address

Hi,

I'm getting an error while obtaining the client IP address from the environment variable SSH_CLIENT. The error is:

Error: Command failed: /usr/bin/notify-send:43: private method `split' called for nil:NilClass (NoMethodError)

Any clue on what is causing this?

Thank you.

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.