Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add source to remote_file for urls in plugin.pp #486

Merged
merged 5 commits into from
Jul 22, 2016

Conversation

chrissav
Copy link
Contributor

Getting an error when trying to add a new sensu plugin. I'm defining the plugin as:

$url = 'https://raw.githubusercontent.com/sensu-plugins/sensu-plugins-puppet/master/bin/check-puppet-last-run.rb'

  sensu::plugin { $url:
    type               => 'url',
    nocheckcertificate => true,
  }

And the error in puppet:

Error: Could not set 'present' on ensure: bad URI(is not URI?): at 103: modules/sensu/manifests/plugin.pp
  • Add the source param to remote_file in the url block to fix this.
  • Add rspec tests to check for source

@chrissav chrissav force-pushed the plugin-remote-file-fix branch from 6ce2a13 to b0adf02 Compare March 20, 2016 16:44
@chrissav
Copy link
Contributor Author

bump

@jlambert121
Copy link
Contributor

I'm trying to understand why your URL is having this issue as it does seem to be a valid URI. I had an odd thing once where there was a unicode character in a URL (not sure how it got there) that caused weird errors - can you make sure the file type is ASCII and that there aren't any "invisible" escape/control characters in the URL?

@atrepca
Copy link
Contributor

atrepca commented Apr 8, 2016

The remote_file module needs a source parameter (Forge link):

source: The source location of the file, or where to get it from if it is needed. This should be a URI.

Using the remote_file module directly:

remote_file { 'https://raw.githubusercontent.com/sensu-plugins/sensu-plugins-puppet/master/bin/check-puppet-last-run.rb':
  ensure => present,
  path   => '/tmp/check-puppet-last-run.rb',
}

Generates the same error:

Error: /Stage[main]/Test/Remote_file[https://raw.githubusercontent.com/sensu-plugins/sensu-plugins-puppet/master/bin/check-puppet-last-run.rb]/ensure: change from absent to present failed: Could not set 'present' on ensure: bad URI(is not URI?)

Adding source:

remote_file { 'https://raw.githubusercontent.com/sensu-plugins/sensu-plugins-puppet/master/bin/check-puppet-last-run.rb':
  ensure => present,
  source => 'https://raw.githubusercontent.com/sensu-plugins/sensu-plugins-puppet/master/bin/check-puppet-last-run.rb',
  path   => '/tmp/check-puppet-last-run.rb',
}

Works as intended:

Notice: /Stage[main]/Test/Remote_file[https://raw.githubusercontent.com/sensu-plugins/sensu-plugins-puppet/master/bin/check-puppet-last-run.rb]/ensure: created

The call in package.pp looks right. The call in plugin.pp should probably be:

remote_file { "${install_path}/${filename}":
  ensure   => present,
  source   => $name,
  checksum => $pkg_checksum,
  require  => File[$install_path],
} ->

@atrepca
Copy link
Contributor

atrepca commented Jun 1, 2016

@jlambert121, does the above make sense?

@chrissav
Copy link
Contributor Author

@jlambert121 I've encountered that issue before - with "invisible" characters in the url that sometime cause failures, but that doesn't seem to be the case here. Puppet runs are failing on this resource only when I add a new plugin, so when it has to fetch it. For previously existing ones, it sees it's there and moves on I guess. But I can't get it to work at all without providing the 'source' param to the remote_file module. By setting it to $name only for url types, the way we define a sensu::plugin would remain the same.

@jaxxstorm jaxxstorm merged commit 7a34294 into sensu:master Jul 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants