Running a puppet in MacOS - macos

I new in puppet, i'm trying to run a simple puppet like this:
node 'mymac.local' {
package { 'nginx':
ensure => installed,
}
}
But it shows this error:
Error: Mac OS X PKG DMG's must specify a package source.
Error: /Stage[main]/Main/Node[mymac.local]/Package[nginx]/ensure: change from absent to present failed: Mac OS X PKG DMG's must specify a package source.
I can't find the solution

You need to specify a provider (probably brew):
package { "nginx":
ensure => latest,
provider => 'brew'
}
I'd suggest looking at the boxen project's nginx module. Gary Larizza has a great post on setting up boxen on OSX

Related

Ensure node is running at least a certain kernel version?

I'm trying to create a development environment using Vagrant which depends on certain applications running inside of Docker containers.
The required environment is Ubuntu 12.04 LTS, which maps out to be the precise64 box in Vagrant. The problem is ensuring the following:
The Saucy LTS kernel is installed.
The Saucy LTS kernel is running.
I'm trying to provision the box using Puppet and I can't figure out a way to ensure that the following commands are executed:
apt-get install linux-image-generic-lts-saucy linux-headers-generic-lts-saucy
reboot
I'll obviously need to reboot the box for it to load and run the new kernel.
Is there a way I can define these items as dependencies in Puppet?
I'm looking to do something like this:
package { "lxc-docker":
/* ... */
requires => Package["lts-kernel-saucy"]
}
Any ideas on how I can accomplish this?
If apt-get is the package manager puppet is using, then you can try the following :
# Create an array of package names that need to be installed
$mypack = [ "linux-image-generic-lts-saucy", "linux-header-generic-lts-saucy", "lts-kernel-saucy" ]
# Install all the packages
package { $mypack :
ensure => installed,
}
# Install other package that depends on the packages above :
package { "lxc-docker" :
ensure => installed,
requires => Package[$mypack],
}
# Create an `exec` that will reboot the machine if a new package is installed
# `refreshonly` sits there waiting for something new to happen
exec { "reboot_machine" :
command => "shutdown -r now",
path => "/bin:/usr/sbin:/sbin:/usr/local/sbin",
subscribe => Package ["lxc-docker"],
refreshonly => true,
}
The best and easiest solution here is to use a Vagrant box which supports Docker by running the right kernel.

How do I uninstall DMG's with puppet?

So I have a local DMG that I'm installing with puppet (VirtualBox-4.2.18-88780-OSX.dmg), and I run it with
sudo puppet resource package virtualbox ensure=present provider=pkgdmg source=puppet:///virtualbox/VirtualBox-4.2.18-88780-OSX.dmg,
and everything works fine. But when I try to remove it with sudo puppet resource package virtualbox ensure=absent, I get an error
Error: Could not set 'absent' on ensure: undefined method 'uninstall' for #<Puppet::Type::Package::ProviderPkgdmg:0x107cb8218>
I have a vague idea of why this is happening, it doesn't look like puppet is recognizing the virtualbox uninstall tool. How do I fix this?
millmouse is correct OS X packages can't be uninstalled, at least by this method. Puppet doesn't support 'absent' on appdmg or apppkg providers.
You can however trick Puppet to reinstall a package by removing the 'cookie' like file it creates to track the package was installed. Puppet creates a file in /var/db with a pattern like .puppet_<provider>_installed_<package_name>-<version> on OS X; for example you'll have a file like /var/db/.puppet_pkgdmg_installed_VirtualBox-4.2.18-88780
You could do something like the following, but it won't actually uninstall the app only trick Puppet into allowing it to be installed again:
exec {'rm -f .puppet_pkgdmg_installed_VirtualBox-4.2.18-88780':
cwd => /var/db/',
user => 'root',
onlyif => 'test -f /var/db/.puppet_pkgdmg_installed_VirtualBox-4.2.18-88780',
}
or
file {'/var/db/.puppet_pkgdmg_installed_VirtualBox-4.2.18-88780':
ensure => 'absent',
force => true,
}
Otherwise the version number or name of the package needs to change in order to install again.
I would use an exec resource to do the uninstall rather than the package resource.
exec { "uninstall_mypkg" :
command => "uninstall mypkg",
onlyif => "check if the package is installed",
path => "/path/to/command/",
}

Error in installing a modified package from local modifed zip file

I found a small bug in a R package. I communicated with the package author to update the code. While waiting for the author action to fix the bug, I am trying to fix the bug on my local version of the package.
I changed the R code, and also updated the MD5 of the associated file. The package is re-zipped, and I use this command to install it:
install.packages("path/to/the/file/modified_package.zip", repos = NULL)
it seems the installation is going well:
Installing package(s) into ‘C:/Users/Me/Documents/R/win-library/2.15’
(as ‘lib’ is unspecified)
package ‘x’ successfully unpacked and MD5 sums checked
However, when I try to load the package, there is an error:
> library(x)
Error in library(x) : ‘x’ is not a valid installed package
Any thoughts?
You can't just zip up the directories; you need to rebuild the package.
There are loads of guides around on how to build R packages. The easiest way (imho) is to use the devtools package.
library(devtools)
build("path/to/the/package")
install.packages("path/to/built/package.tar.gz", repos = NULL, type = "source")
Or
build("path/to/the/package", binary = TRUE)
install.packages("path/to/built/package.zip", repos = NULL, type = "win.binary")
You'll also need Rtools if you are running Windows. Install it with the installr package.
library(installr)
install.Rtools()

OS X 10.8.2 python 3 import sqlite error

Both brew installed python3 and manually compiled python3 with -–enable-loadable-sqlite-extensions fails when import sqlite from python3 shell. Please help!
The module is named sqlite3, not sqlite:
import sqlite3
http://docs.python.org/3/library/sqlite3.html
Update: Now that we've cleared up the module name, the problem being reported:
ImportError: No module named '_sqlite3'
means that your Python instance cannot find the C extension module, _sqlite3.so, that is part of the sqlite3 module in the standard library. Since the file path of the dbapi2.py in the traceback looks reasonable, the issue is probably not a path issue (sys.path). Most likely the _sqlite3 extension module failed to build or link. Check the output from your Python build for errors. OS X 10.8 includes a version of sqlite3 but for security reasons it does not include the optional loadable extensions feature. Your Python build likely included this message:
Failed to build these modules:
_sqlite3
and, earlier, this:
*** WARNING: renaming "_sqlite3" since importing it failed: dlopen(build/lib.macosx-10.8-x86_64-3.3-pydebug/_sqlite3.so, 2): Symbol not found: _sqlite3_enable_load_extension
Referenced from: build/lib.macosx-10.8-x86_64-3.3-pydebug/_sqlite3.so
Expected in: flat namespace
in build/lib.macosx-10.8-x86_64-3.3-pydebug/_sqlite3.so
The solution is to build and install a separate copy of sqlite3 that is built with the loadable extensions feature. If you are using Homebrew, its sqlite recipe with the with-functions option should do that. Then rebuild Python.
Homebrew provides python3 with sqlite3 support and loadable modules.
brew install python3 will do the right thing (and brew sqlite, too).
There was a bug, that probably struck you, but it has been fixed

Agave dependency error

I am trying to install Agave under Fedora, but I got this error:
configure: error: gnome-doc-utils >= 0.3.2 not found
I tried to compile and install the gnome-doc-utils from this page, but i still got this error,and when i try the
yum list installed gnome-doc-utils*
command, I can't find the package. Do I have to register the package after installing? I don't think I have a error for the make install, because I don't see any the text error in the process, or I could be wrong.
In general, package managers (tools like yum) don't know that something has been installed on your machine unless it was installed as a package. If an agave package for Fedora exists, I would suggest using that instead of compiling from source.

Resources