Can someone tell me why this is not working? This code works just fine on an Ubuntu server, but crashes on CentOS. I am running Puppet version 3.7.2.
node default {
package { 'httpd':
ensure => 'absent'
}
package { 'nginx':
ensure => 'installed',
require => Package['httpd'],
}
}
and I am getting this error:
Error: Execution of '/bin/yum -d 0 -e 0 -y list nginx' returned 1: Error: No matching Packages to list
Error: /Stage[main]/Main/Node[default]/Package[nginx]/ensure: change from absent to present failed: Execution of '/bin/yum -d 0 -e 0 -y list nginx' returned 1: Error: No matching Packages to list
nginx is not in the default CentOS repo; it requires epel. Before you can install the package, you need to require epel-release:
package { 'epel-release':
ensure => 'installed',
}
package { 'nginx':
ensure => 'installed',
require => [Package['httpd'], Package['epel-release']],
}
By the way, does your installation of nginx specifically require httpd being absent before installation? You should be able remove the httpd metaparameter dependency.
Related
This is my manifest,I'm puppet newbie
class vsftpd {
if $::operatingsystem == 'CentOS' {
package { "vsftpd":
ensure => installed
}
}
}
node 'puppet.domain.example' {
include vsftpd
}
node 'centos2.domain.example' {
include vsftpd
}
node 'centos3.domain.example' {
include vsftpd
}
On master
puppet apply manifest.pp
No error.
On node centos2
puppet agent
No error
And even on centos2...
rpm -qa|grep -i vsftp
Not installed :(
On master vsftp is installed.
What's wrong?
edit1: I also tried
puppet agent -t
But no way
Solution found: manifests were in wrong dir. Must be on dir
/etc/puppetlabs/code/environments/production/manifests
Environment:
Running CentOs 7.2 Server in a virtual machine, which has a local proxy set up with CNTLM. I have installed vagrant version 1.8.1. In addition i installed the vagrant-proxyconf plugin.
Goal:
Set up a virtual machine on the CentOs 7.2 Server with vagrant.
Yes: A virtual machine in a virtual machine.
Status quo:
A snippet of the Vagrantfile:
...
config.proxy.http = http://10.0.2.2:3128
config.proxy.https = http://10.0.2.2:3128
config.proxy.no_proxy = localhost, 127.0.0.*, 10.0.2.*
...
# puppet config
config.vm.provision :puppet, :module_path => "../puppet/modules" do |puppet|
puppet.manifests_path = "../puppet/manifests"
puppet.manifest_file = "base.pp"
# In facts are the proxy settings with host and port.
puppet.facter = facts
end
A snippet of my puppet manifest:
class box-configuration {
...
class { 'apt':
always_apt_update => true;
}
# Always a apt-key update before installing packages
exec { 'apt-key_update':
command => "/usr/bin/apt-key update && /usr/bin/apt-get update",
require => Class['apt'],
}
apt::ppa { 'ppa:openjdk-r/ppa': }
package { ["unzip", "curl", "openjdk-8-jdk"]:
ensure => present,
require => [Class['apt'], Exec['apt-key_update']],
}
...
}
Problem:
When i'm running vagrant up in the terminal, i get the following error for the package openjdk-8-jdk:
All other packages could be installed successfully.
After the failure, i connected to the virtual machine with vagrant ssh to install this package manually with sudo apt-get install openjdk-8-jdk and then i got the following prompt:
Install these packages without verification [y/N]?
apt-get install openjdk-8-jdk wants a verification for downloading the package from the recently added repository in base.pp.
What should i do for this? I already add the Exec['apt-key_update'] requirement...
EDIT:
When i connect to the virtual machine with vagrant ssh to make manually the update apt-key update && apt-get update i get the following output:
You dont have dependencies on the apt::ppa { 'ppa:openjdk-r/ppa': } when you install the java package, so you can make a dep
apt::ppa { 'ppa:openjdk-r/ppa': }
exec { 'apt-key_update':
command => "/usr/bin/apt-key update && /usr/bin/apt-get update",
require => [Class['apt'], Apt::ppa['ppa:openjdk-r/ppa']],
}
package { ["unzip", "curl", "openjdk-8-jdk"]:
ensure => present,
require => [Class['apt'], Exec['apt-key_update']],
}
EDIT : I tested on ubuntu/trusty64 box and I used the apt module (you need to make sure it is installed) and the following puppet file
class box-configuration {
class { 'apt':
update => {
frequency => 'always',
},
}
# Always a apt-key update before installing packages
exec { 'apt-key_update':
command => "/usr/bin/apt-key update && /usr/bin/apt-get update",
require => [Class['apt'], Apt::Ppa['ppa:openjdk-r/ppa']]
}
apt::ppa { 'ppa:openjdk-r/ppa': }
package { ["unzip", "curl", "openjdk-8-jdk"]:
ensure => present,
require => [Class['apt'], Exec['apt-key_update']],
}
}
include box-configuration
everything goes fine and java8 is installed - you can see a gist of all the installation process
The problem here was CNTLM with the version 0.92.3.. They have some problems in this version with the proxy tunneling. They recommend to install the 0.93beta5 version, and this solved my problem... But you can't get the beta version from SourceForge.. I download the beta version from this repository.
Otherwise check the answer of #Frédéric Henri, this could solve your problem, when everything with CNTLM is ok.
I'm trying to set up a VM to use python-nvd3 and using puppet to provision the machine. I've got node.js/npm to go in ok but then I get an error trying to install packages using bower:
package { 'bower':
provider => npm
}
exec { 'install d3':
command => '/usr/local/bin/bower install d3#3.3.8',
require => Package["bower"]
}
exec { 'install nvd3':
command => '/usr/local/bin/bower install nvd3#1.1.12-beta',
require => Package["bower"]
}
err: /Stage[main]/Infinite_interns::Box::Tm351d001r/Exec[install d3]/returns: change from notrun to 0 failed: /usr/local/bin/bower install d3#3.3.8 returned 1 instead of one of [0] at /vagrant/modules/infinite_interns/manifests/box/tm351d001r.pp:39
If I ssh in to the VM, and try to run a bower command I get a y/n prompt to ask if I want to allow error logging. In this case I don't want to and I don't want my provisioner to fall over because it can't answer the question (if this is the problem that's causing the above puppet error).
You have to set the CI environment variable to true or use the config.interactive=false bower flag to avoid interactive operations. Example:
exec { 'install d3':
command => '/usr/local/bin/bower install d3#3.3.8 --config.interactive=false',
require => Package["bower"]
}
Reference:
https://github.com/bower/bower#running-on-a-continuous-integration-server
i am using the example of iptraf on github
I do a git clone, and then sudo puppet apply init.pp
but i dont see iptraf installed on the ubuntu 11.04 host
now this puppet is a client ONLY instance, and NO Master.
from another example i see i can install apache2 as:
class basic_services {
##Get Apache
package { 'apache2':
ensure => 'installed',
}
##Edit the Apache Conf
file { "/etc/apache2/sites-available/default":
require => Package["apache2"],
owner => "root",
group => "root",
content => "$some_variables::apache_config",
}
##Make sure Apache is running, and restarts on changes to conf
service {'apache2':
require => Package["apache2"],
ensure => running,
subscribe => File["/etc/apache2/sites-available/default"],
}
}
so for iptraf:
init.pp
class iptraf {
include iptraf::base
}
base.pp
class iptraf::base {
package{'iptraf': ensure => installed }
}
I will use this example as a base to develop a manifest for Testing Tools
So what am i missing here , as after i run :
sudo puppet apply init.pp , and try to access iptraf, i get the message:
iptraf
The program 'iptraf' is currently not installed. You can install it by typing:
sudo apt-get install iptraf
in the directory:
/etc/puppet/modules/iptraf
- create a file:
iptraf.pp
- with contents:
package { "iptraf":
ensure => "installed"
}
- issue the command:
puppet apply iptraf.pp
/Stage[main]//Package[iptraf]/ensure: ensure changed 'purged' to 'present'
Finished catalog run in 2.71 seconds
run iptraf on command line , the UI POPS UP.
Done!
move the iptraf directory to the modules. Your directory structure should be this :
/etc/puppet/modules/iptraf/manifests/{init.pp,base.pp}
then do,
sudo puppet apply -e 'include iptraf'
that should install iptraf.
sudo iptraf should open a nice screen in your terminal :)
I'm trying to getting support for augeas on my Vagrant machine.
I tried to install some package with these directives:
package { "augeas-tools": ensure => installed }
package { "libaugeas-dev": ensure => installed }
package { "libaugeas-ruby": ensure => installed }
When i try to use augeas on my manifests, after the vm boot i receive this error:
err: Could not find a suitable provider for augeas
I'm using the precise32 official box with Vagrant 1.0.3.
Vagrant 1.0.3 has ruby 1.8.7 and puppet 2.7.14
$ ruby -v
$ ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]
$ puppet help
$ Puppet v2.7.14
This is my little manifest with php class, included after apache class, mysql and other classes tested separately.
All things works correctly excepting for the augeas command.
class php {
exec { "apt-update":
command => "/usr/bin/apt-get update",
refreshonly => true;
}
package { "augeas-tools": ensure => installed }
package { "libaugeas-dev": ensure => installed }
package { "libaugeas-ruby": ensure => installed }
package { "php5": ensure => installed }
package { "php5-cli": ensure => installed }
package { "php5-xdebug": ensure => installed }
package { "php5-curl": ensure => installed }
package { "php5-intl": ensure => installed }
package { "php5-imap": ensure => installed }
package { "php5-mcrypt": ensure => installed }
package { "php5-imagick": ensure => installed }
package { "php5-sqlite": ensure => installed }
package { "php5-gd": ensure => installed }
package { "php-apc": ensure => installed }
package {
"libapache2-mod-php5" :
ensure => installed,
require => Package["php5"]
}
augeas { "php-cli":
require => [
Package["php5"],
Package["augeas-tools"],
Package["libaugeas-dev"],
Package["libaugeas-ruby"],
],
context => "/etc/php5/cli/php.ini",
changes => [
"set date.timezone Europe/Rome",
"set short_open_tag Off",
];
}
augeas { "php-apache":
require => [
Package["php5"],
Package["augeas-tools"],
Package["libaugeas-dev"],
Package["libaugeas-ruby"],
],
context => "/etc/php5/apache2/php.ini",
changes => [
"set date.timezone Europe/Rome",
"set short_open_tag Off",
];
}
}
After installation of packages, logging in the vagrant machine with "vagrant ssh", i launch:
vagrant#precise32:~$ ruby -raugeas -e "puts Augeas.open"
#<Augeas:0xb77a3598>
Thanks in advance!
I added the following to my Vagrantfile and it augeas started working.
Before declaring puppet provisioner add the following line, if on ubuntu:
config.vm.provision :shell, :inline => "sudo apt-get update && sudo apt-get install puppet -y"
This will update your apt packages and then update puppet client whose latest version already has a fix.
It turns out that this wasn't fixed in bug #6907 that I referenced in my other answer. That fix only worked for Puppet providers that depended on commands that were then supplied during the run.
For the Augeas provider, it uses an internal Puppet called "features" to check if the ruby-augeas library is available or not. Features are only being checked once and the results cached, so even after installing the library, this meant the feature still evaluated to false.
I filed this upstream as bug #14822 and have sent a pull request with a fix. Testing with the patch, I now get this successful run:
notice: /Stage[main]//Package[ruby-augeas]/ensure: created
notice: /Stage[main]//Augeas[test]/returns: executed successfully
I'm not familiar with Vagrant, but I think you'll need to find a workaround to install the libaugeas-ruby package before the Puppet run in the meantime.
On Puppet 2.7.14, this should work as the dependencies for providers will only be evaluated when they're needed - i.e. when Puppet needs to run those Augeas resources.
Without the full Puppet log file to confirm, I suspect that it's because you're missing explicit dependencies between the Augeas package(s) and the Augeas resources that need them. Remember, listing the resources in the manifest in that order doesn't mean Puppet executes it that way.
You could either add requires parameters to every Augeas resource:
augeas { "php-cli":
require => [ Package["php5"], Package["libaugeas-ruby"] ],
# ...
}
Or use the chaining syntax to automatically make every Augeas resource depend on a package. Add this on a line inside the class, but not inside any resource:
Package["libaugeas-ruby"] -> Augeas <| |>
After reading answer from #m0dlx I inspect /home/vagrant/postinstall.sh file and found that Vagrant uses own copy of Ruby:
# The base path to the Ruby used for the Chef and Puppet gems ruby_home="/opt/vagrant_ruby"
After that I find file augeas.rb at /opt/vagrant_ruby/lib/ruby/gems/1.8/gems/puppet-2.7.19/lib/puppet/provider/augeas/augeas.rb and edit it, by changing line
confine :true => Puppet.features.augeas?
to
confine :true => :augeas
(Shortly speaking I partially apply patch from #m0dlx.)
After that this error is gone.