I'm on puppet 3.6.2, I have the source for our puppet repo. I want to do this:
irb> require 'rubygems'
irb> require 'puppet'
irb> Puppet[:confdir] = "/home/wwalker/git/puppet"
irb> node=Puppet::Node.new('localhost')
irb> compiler=Puppet::Parser::Compiler.new(node)
irb> scope=Puppet::Parser::Scope.new(compiler)
irb> scope.function_generate_mysql_url(...)
However, I can't get past the compiler:
irb(main):010:0> compiler=Puppet::Parser::Compiler.new(node) Puppet::Context::UndefinedBindingError:
no 'environments' in
{:current_environment=><Puppet::Node::Environment:17836720 #name="*root*" #manifest="no_manifest" #modulepath="" >,
:root_environment=><Puppet::Node::Environment:17836720 #name="*root*" #manifest="no_manifest" #modulepath="" >}
at top of [[0, nil, nil]]
I assume I need to set the "environment", or I've set confdir wrong.
Anyone else done any testing of puppet modules in irb?
I do not have direct access to the puppet server. I've tried this on my workstation (puppet-server 4.1 installed) and on a client (puppet 3.6.2 installed).
This seems so simple, but I'm clearly missing something.
Anyone know what step(s) I'm missing?
I am not really sure what you are trying to accomplish but there is a puppet debugger repl for the puppet language which is very similar to pry/irb but specific to puppet.
https://github.com/nwops/puppet-debugger
You can use the debugger to run any function currently available in your module path among many other features.
You can also set a breakpoint in your puppet code and have it load the debugger using the 'debug::break()' function.
Ruby Version: 2.0.0
Puppet Version: 4.9.4
Puppet Debugger Version: 0.6.0
Created by: NWOps
Type "exit", "functions", "vars", "krt", "whereami", "facts", "resources", "classes",
"play", "classification", "types", "datatypes", "reset", or "help" for more information.
1:>> md5('sdafsd')
=> "569ebc3d91672e7d3dce25de1684d0c9"
2:>>
This is going to be one of those times where someone points you to another tool. If you want to do Ruby debugging, you should really think about using pry (http://pryrepl.org/) instead.
It's what I use during Puppet / modules / Ruby development and it's super simple to use.
In your Gemfile:
gem 'pry'
gem 'pry-stack_explorer'
if RUBY_VERSION =~ /^2/
gem 'pry-byebug'
else
gem 'pry-debugger'
end
Bonus: it works on Windows as well as everywhere else (DevKit may need to be installed).
Related
I'm trying to use the librarian-puppet to fetch forge modules from an Artifactory repository.
In my Puppetfile I have something like:
forge "https://<artifactory_host>/artifactory/api/puppet/<repo_key>" #From artifactory docs
# PuppetLabs Modules
mod 'puppetlabs/stdlib', '4.24.0'
The command that I'm using is /usr/local/bin/pdk bundle -- exec librarian-puppet install --no-use-v1-api --verbose
The error that I get is:
[Librarian] Resolving puppetlabs-stdlib (= 4.24.0) <https://<artifactory_host>/artifactory/api/puppet/<repo_key>>
[Librarian] Checking manifests Unable to find module 'puppetlabs-stdlib' on https://<artifactory_host>/artifactory/api/puppet/<repo_key>
/tmp/tmp.BXyhBoNRiR/.pdk/cache/ruby/2.1.0/gems/librarian-puppet-3.0.0/lib/librarian/puppet/source/forge/repo_v3.rb:44:in `rescue in get_module'
/tmp/tmp.BXyhBoNRiR/.pdk/cache/ruby/2.1.0/gems/librarian-puppet-3.0.0/lib/librarian/puppet/source/forge/repo_v3.rb:41:in `get_module'
Versions:
puppet 3.8.7
pdk 1.5.0
ruby 2.1.9
According to the documentation at https://www.jfrog.com/confluence/display/RTF/Puppet+Repositories#PuppetRepositories-Usinglibrarian-puppet, it seems I'm trying to get the modules correctly using the librarian-puppet, but something most be missing.
Thanks for any help.
I think Artifacotry does not support Puppet 3.8.7 its documented in Wiki.
Puppet version support
Puppet does not support a context path up to version 4.9.1, we recommend using Artifactory with Puppet version 4.9.2 and above. Please see below if you are using Puppet 4.9.1 and below.
The official Artifactory documentation (not a wiki) recommends using Puppet 4.9.2 or later with Artifactory:
Puppet version support
Puppet does not support a context path up to version 4.9.1, we
recommend using Artifactory with Puppet version 4.9.2 and above.
Please see below if you are using Puppet 4.9.1 and below.
(Emphasis in the original.)
As that comment indicates, however, the docs do also suggest a workaround for use with earlier Puppet:
If you need to use Puppet 4.9.1 and below you can use a workaround
which uses NGINX or Apache to rewrite all requests from /v3/* to
/artifactory/api/puppet/<repo-name>/v3/*.
The docs go on to present some example configurations, which I will not repeat here.
I have a Haskell desktop application that uses Snap. This application has been building for years now and is an everyday part of our fielded solution. I upgraded to a new development machine some months ago, running Windows 10 with version 7.10.3 of the GHC and 1.22.3.0 of the cabal library with 1.22.4.0 of cabal-install. I have installed version 0.9.8.0 of snap-core and version 0.9.5.1 of snap-server.
When I try and build my application in this environment, it get the following error:
Could not find module `Snap.Internal.Http.Server.Exception'
Perhaps you meant
Snap.Internal.Http.Server.Backend
Snap.Internal.Http.Server.Config
Snap.Internal.Http.Server.Date
I cannot find this module in Hackage. Did something change in Snap since I last built this code? Please, any advice will be appreciated.
Dave
P.S. Here are links to the output of the ghc-pkg list command and to the cabal file for this project.
http://zelda.designacourse.com/dave/ghc-pkg_list.txt
http://zelda.designacourse.com/dave/PreviewWrapper.cabal
With the help of, and gratitude to, epsilonhalbe we found a solution to this problem. I still do not know why the import of Snap.Internal.Http.Server.Exception started to throw an error from the compiler. However, removing that import and adding a type declaration to the variable now allows the code to build without error. i.e. catch ((_ :: IOException) -> return True).
I'm trying to incorporate JSDoc into my Grunt deployment process. When I run it, I get the following error (expectedly):
>> JAVA_HOME is not set. Jsdoc requires Java to run.
Fatal error: Bad argument
I know that JSDoc is java-based, but I'm hoping to remove Java from the equation wholly. Is there a way to do this with the existing grunt plugin, or another that runs the process in Node only?
I don't want to add Java just for one task. Is this a fool's errand?
There's no way to do this from the current grunt jsdoc plugin. The issue is with the underlying jsdoc utility of course. You can track their progress toward supporting node.js instead of Rhino here:
https://github.com/jsdoc3/jsdoc/issues/93
However, a couple notes about that error you're seeing.
At least on Linux, as long as java is in the path, you can safely ignore that error and it will still generate.
see this question for some other discussion about JAVA_HOME and grunt-jsdoc-plugin
The JSDoc dependency on Java, required by Mozilla Rhino, has been removed in JSDoc 3.3.0. The JSDoc GitHub page states:
Native support for Node.js is available in JSDoc 3.3.0 and later. JSDoc supports Node.js 0.10 and later.
JSDoc v3.3.0 is still in alpha release status (3.3.0-alpha4 was released on Jan 26, 2014), so to install the latest alpha version use:
npm install jsdoc#"<=3.3.0"
I came across the same problem, and built a little Grunt plugin wrapping JSDoc 3.3 (no need for Java, all running in Node):
https://github.com/usrz/javascript-grunt-jsdoc-ng
I've seen the following issue mentioned in another thread a few days ago amongst other problems, but the solution for this issue (to me) didn't seem to be addressed.
I recently ran a test on my Ruby 1.9.2-p290 environment and was presented with the following error when I ran a test script:
You are using an old or stdlib version of json gem
Please upgrade to the recent version by adding this to your Gemfile:
gem 'json', '~> 1.7.7'
This issue continued when I created a completely fresh Ruby 1.9.3-p392 environment, running on Windows XP (don't ask). What confuses me is that even when I have json 1.7.7 or 1.8.0 installed (gem list is pasted below), I still get this message when I run my test. It's not really affecting my test results, but the warning is just rather annoying to see each time.
Which Gemfile do I need to add this version into, and where would it be located?
gem list:
bigdecimal (1.1.0)
childprocess (0.3.9)
commonwatir (4.0.0)
ffi (1.8.1 x86-mingw32)
io-console (0.4.2, 0.3)
json (1.8.0, 1.7.7, 1.5.5)
mini_portile (0.5.0)
minitest (5.0.0, 2.5.1)
multi_json (1.7.3)
rake (10.1.0.beta.3, 10.0.4, 0.9.2.2)
rdoc (4.0.1, 3.9.5)
rubygems-update (2.0.3)
rubyzip (0.9.9)
selenium-webdriver (2.32.1)
watir-webdriver (0.6.4)
websocket (1.0.7)
win32-api (1.4.8 x86-mingw32)
win32-process (0.7.2)
windows-api (0.4.2)
windows-pr (1.2.2)
The message is coming from the multi_json gem, and it seems like it could be a bug. I suggest keeping an eye on this GitHub ticket.
If the message is too distressing, you can downgrade multi_json to version 1.6.1 to get rid of it. (At least this works for me.)
UPDATE:
It looks to me like the root of the problem is that while multi_json wants to limit its use of the json and json_pure gems to specific versions, the author of multi_json isn't using the gem method in his code to activate these versions. (It sounds like he thinks Bundler is the only way to specify versions of gems; it isn't.)
Since multi_json will try the oj and yajl-ruby gems before it tries json, using one of those may be the best workaround of all. So you can just install the latest multi_json and then install either oj or yajl-ruby along with it.
Try this:
gem update --system
gem update
Go to your Ruby installation path, for example,
C:\Ruby192\lib\ruby\1.9.1\json
Open version.rb file and update the version detail as shown bellow:
VERSION = '1.7.7'
Try running your tests with the bundle exec command. This will force your environment to use the gems in Gemfile.lock.
I'm a newbie in Puppet, so maybe you'll find my question a bit stupid...
So, I'm looking for puppet recipe that will install and run Mongodb 2.2 on my machine. By googling I found this module http://forge.puppetlabs.com/puppetlabs/mongodb But I didn't understand clear what should I do?
It said I have to install module on puppet node first. What does exactly it means?
Let's say, I have a set of machines those must be configured via puppet.
What do I have to add to puppet recipe to reach this aim?
In case someone might be interest on installing the last version of MongoDB this worked very well for me. At the moment of writing the latest stable version is MongoDB 3.0.3.
First of all update your OS repositories via the puppet apt module (in case you're using a Debian or Ubuntu distribution). Change the data below according to your distribution and version. Check here to get the MongoDB official repositories information: http://docs.mongodb.org/manual/administration/install-on-linux/#recommended
# $::lsbdistcodename should contain what you usually get
# with the `lsb_release -sc` command
$server_lsbdistcodename = downcase($::lsbdistcodename)
apt::source { 'mongodb-org-3.0':
location => 'http://repo.mongodb.org/apt/debian',
release => "${server_lsbdistcodename}/mongodb-org/3.0",
repos => 'main',
key => '7F0CEB10',
key_server => 'keyserver.ubuntu.com',
include_src => false
}
And then set the mongodb::globals class properly to make sure you get MongoDB 3. The MongoDB puppet module I'm using is this one.
class { 'mongodb::globals':
manage_package_repo => false, # disable the 10gen repository
server_package_name => 'mongodb-org',
service_name => 'mongod',
version => '3.0.3',
}->
class { '::mongodb::server': }
Getting mongodb installed with puppet isn't as easy as it seems. It's somewhat difficult to get official Puppet Labs module v0.8.0 to install mongodb 2.6.3. You end up getting an apt error about mongodb-10gen=2.6.3 not being found. There's an issue and a patch already but it hasn't been published yet.
So here's what you need to do:
git clone https://github.com/puppetlabs/puppetlabs-mongodb.git
Then use the following puppet config:
class { '::mongodb::globals':
manage_package_repo => true,
server_package_name => 'mongodb-org',
version => '2.6.3'
}->
class { '::mongodb::server': }
This Worked for me.
If you are running puppet standalone, you will have already installed the puppet gem and have the puppet executable. To intall the module, you run puppet module install puppetlabs/mongodb. After the module installation, you can simply include the mongodb module in your node definition
node 'myhost' {
include mongodb
}
If you want to run a number of nodes that need access to the module, you'll have to setup a puppetmaster and install the node. See [Basic Agent/Master setup][1] for more info. Make sure that pluginsync=true is enabled in puppet.conf so the module can make it's way to the remote agents.
The puppetmaster will then need a file, normally site.pp defined with the nodes it should configure. Finally, include the mongodb module on each node you want to run mongodb and you should be up and running.