I am trying to install a puppet module in master and the agent node. The installation on the master is successful, the new module is visible in module list. Then I changed the site.pp file and included the new module. After that I ran the puppet agent -t command on the agent and expected the module to be installed in the agent. The command is running without any issues but the module is not getting installed.
Following is the sequence of steps which were executed on master:
puppet module install puppetlabs-ntp --version 6.2.0
puppet agent -t
puppet module list
Output:
/etc/puppetlabs/code/environments/production/modules
├── puppetlabs-ntp (v6.2.0)
└── puppetlabs-stdlib (v4.17.1)
Updated site.pp file as follows:
Content:
node default {
include ntp
}
And the following is the steps executed on agent:
puppet agent -t
puppet module list
Output:
/etc/puppetlabs/code/environments/production/modules
└── puppetlabs-stdlib (v4.17.1)
Have even compared the output of puppet agent -t --debug from both master and agent but did not see any specific errors which might be causing this issue.
What am I missing here ?
You are misunderstanding how Puppet works. If everything is set up correctly, the result you should expect when you run puppet agent -t on the agent is for Puppet on that node to configure the ntp service for you. It will not transfer the ntp module to the agent. The Puppet code itself is supposed to remain on the master.
Related
I use puppet to install apache with the following code in the manifest.
class{ 'apache':
docroot => '/var/www', # ubu default, ignored
default_vhost => false,
default_ssl_vhost => false,
service_enable => false, # Do not start at boot
service_ensure => stopped, # Apache should be stopped if puppet runs
}
In my puppet.conf I have mentioned like below.
mod "apache",
:git => 'ssh://git.*.*.com:7999/xyz/jira-apache-puppet-module.git',
:ref => 'master'
when i checked apache is getting installed with latest version as in my ubuntu repo.So is puppet using ubuntu repo for installing the package or the module as defined in puppet.conf
So is puppet using ubuntu repo for installing the package or the module as defined in puppet.conf[?]
Both.
The declaration in your manifest simply tells Puppet to include a class named 'apache' in the target node's manifest, with the specified parameter values. Puppet itself knows nothing about such a class, or any associated other classes, defined types, files, templates, data, etc. that belong to its module and support it. That's where your puppetfile entry comes in: tells Puppet which module you mean, and where to find it.
The Puppet module contains instructions for how to install and configure Apache, but it will not contain Apache itself. The approach to installation is sure to be to obtain the software from a package repository appropriate for the target system, as determined by the target system and its configuration. Puppet will use the same command-line interface for that purpose that you could use manually.
All the modules in Puppetfile will get installed during r10k run.
r10k deploy environment -pv
I have a problem while configuring Puppet 4 master to work with HTTP requests so I can use CouchDB for hiera.
These are the steps I did so far:
created new CouchDB with test database
created new document called common
gem install hiera-http-1.0.0
put the http_backend.rb file in /opt/puppetlabs/code/environments/production/mpdules/hiera_http and /opt/puppetlabs/puppet/lib/ruby/gems/2.1.0/gems/hiera-http
When I run gem list I can see:
Hiera (3.2.0)
Hiera-http (1.0.0)
Now, when I try running hiera common or anything else I get ERROR :
'require' : cannot load such file -- lookup_http (LoadError)
My hiera.yaml looks like :
:backends:
- http
And, of course, all the required settings (host,port..)
When i run puppet agent -t on the agent I get
cannot load backend http: no such file to load -- hiera/backend/http_backend at site.pp
Your steps 3 and 4:
gem install hiera-http-1.0.0
put the http_backend.rb file in /opt/puppetlabs/code/environments/production/mpdules/hiera_http and /opt/puppetlabs/puppet/lib/ruby/gems/2.1.0/gems/hiera-http
need to be replaced by:
/opt/puppetlabs/puppet/bin/gem install hiera-http
That will ensure the hiera-http hiera backend gem is automatically properly installed and configured for the ruby that puppet uses.
If you want to use the system ruby for puppet so that it recognizes the hiera-http installed from the system gem, then you need to install puppet, facter, and hiera with gem and not your OS package manager.
By default site.pp is the main manifest, and I noticed that whatever I type in this file gets recognized by puppet.
However, when I try to create something in either the manifests or modules directory, puppet seems to ignore it.
Since the main manifest is site.pp, does that mean that it ignores whatever is in those directories? Do I have to write something in site.pp in order for it to recognize other modules or manifests?
From what I understand as long as your puppet.conf file is configured with a "basemodulepath" value then anything you put in a directory defined by that basemodulepath should be autoloaded.
From there all that you need to do is define your node inside of site.pp with the module that you have created, using an include.
I'm using Puppet Enterprise in a paid lab, so YMMV, but I just did this in a lab exercise and had no issues. My basemodulepath is:
basemodulepath = /etc/puppetlabs/puppet/modules:/opt/puppet/share/puppet/modules
I defined a motd module under the path: /etc/puppetlabs/puppet/modules/motd/, so my module is autoloaded (it's a subdirectory of /etc/puppetlabs/puppet/modules which is part of the configured basemodulepath).
Now that that was done, all that I need to do inside of site.pp was define the node I wanted to apply the module to, and include the motd module:
node 'mynode_certname'{
include motd
}
I hope this helps you out.
I apply an incremental change to my postgresql install using puppet.
sudo puppet apply --modulepath=/vagrant/puppet/modules -e "include iwd-postgresql"
This result in the following error:
Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class postgresql::globals at /vagrant/puppet/modules/iwd-postgresql/manifests/init.pp:6 on node target.intware.com
Wrapped exception:
Could not find declared class postgresql::globals
I have installed the puppetlabs/postgresql module.
If I do a puppet list I see the following:
[vagrant#target ~]$ puppet module list
/home/vagrant/.puppet/modules
├── puppetlabs-apt (v2.2.0)
├── puppetlabs-concat (v1.2.4)
├── puppetlabs-postgresql (v4.6.0)
└── puppetlabs-stdlib (v4.9.0)
/usr/share/puppet/modules (no modules installed)
Any ideas? I am running the appply command on a vagrant virtual machine in vagrant's home folder.
#ChrisPitman's comments pointed me in the right direction. I needed to set up the correct modulepath to include both our custom modules along with pre-built ones.
The following worked for me:
sudo puppet apply --modulepath=/vagrant/puppet/modules:/etc/puppet/modules -e "include iwd-postgresql"
When you used the command puppet apply you was using this path /home/vagrant/puppet/modules, but your module is installed under /home/vagrant/.puppet/modules, anyway If you are using vagrant, I think is better if you the Vagrantfile for use puppet and customize your vm
Primary goal is to add all puppet modules automatically, so that all dev-env's and prod-env could be started with one command. How can I install puppet modules through puppet manifest?
We've been happily using librarian-puppet to sync all 3rd party modules, it supports setting the modules' locations and versions. So production and dev run the exact same code.
The usage is one liner
librarian-puppet install
In other cases we have a shell script that runs puppet two times, one time a minimal module that is only responsible for fetching the required modules, and then the full blown puppet flow when all modules are available.
The "Puppet module" type and provider does exactly that:
module { 'author/mymodule':
ensure => present,
}
module { 'puppetlabs/stdlib':
ensure => '2.6.0',
}
module { 'puppetlabs/stdlib':
ensure => present,
modulepath => '/etc/puppet/modules',
}
Recent versions of Puppet also have a puppet module command that allows you to install arbitrary Puppet modules from the Puppet forge, example:
$ puppet module install rcoleman/puppet_module
Notice: Preparing to install into /home/anarcat/.puppet/modules ...
Notice: Created target directory /home/anarcat/.puppet/modules
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/home/anarcat/.puppet/modules
└── rcoleman-puppet_module (v0.0.3)
Other alternatives include:
librarian
r10k (cited as a replacement for librarian), supports dynamic environments and much more
r10k is now part of Puppet Entreprise 2015.03, so it can certainly be considered best practice.
Here is an example of mine:
$module_stdlib = 'puppetlabs-stdlib'
exec { 'puppet_module_stdlib':
command => "puppet module install ${module_stdlib}",
unless => "puppet module list | grep ${module_stdlib}",
path => ['/bin', '/opt/puppetlabs/bin']
}
Where $module_stdlib is a module I whant to install.
The /bin path is a path where the grep comes from.
And the /opt/puppetlabs/bin is a path where for the puppet binary exists in my installation.
Seems that writing module for installing puppet modules is possible - it'll be just wrapper for puppet module tool. However, I didn't hear about such module yet.
I suppose this mechanism of installation is not popular because often you need to modify installed module, do some customizations. Practical tool for management of such modifications is version control system. For example, in our team we keep /etc/puppetlabs/puppet directory in git repostitory. After installation of any module from Puppet Forge we add its files to version control and push it to remote git server. Our internally developed modules are also kept in this repository. This way, several puppet masters (dev and prod environments) are synchronized with this central repository and always have up-to-date versions of all modules.
I did this and it seemed to work
exec { 'puppet-fstab':
path => '/bin:/usr/bin',
command => 'puppet module install -i /usr/share/puppet/modules/AlexCline-fstab >>/tmp/err.log',
}