installing a 3rd party module on a puppet agent - puppet

We have a puppetmaster and an agent machine I'm configuring from it, via the puppet agent -t command.
On this agent machine (an Ubuntu box) I need the bc (base calculator) command installed when it's built. Right now that's not the case.
There appears to be a module for it on the forge (https://forge.puppetlabs.com/rfletcher/bc/readme) but I'm fairly new to puppet and am not sure how to set things up so that when the Ubuntu box is spun up this module is installed?
I'm going over the agent docs but am still learning about how agents communicate with puppetmasters. I'm hoping for a nudge on what to do to make sure this command is installed on my agent when all is said and done (stick something in a manifest somewhere most likely?)

So you are asking how to use forge modules in puppet. My first suggestion is, read the relative documents as more as possible, all in Puppet Forge
If you need get quick start, here are something you can try.
login puppet master
cd to puppet module folder
puppet module install rfletcher-bc
mv rfletcher-bc bc
then find the node pp file (normally it should be init.pp) to add below line:
include bc
I didn't have your environment, and not sure which pp file will be targeted.

Related

Can one just copy perl modules from one Linux machine to another?

I have a remote CentOS server (Release 6.10) set up by someone else. I have quite a few perl modules installed on the machine.
I have set up a local CentOS server (Release 7.7.1908). I would like to have the EXACT same set of perl modules on my local machine. Installing them one by one via cpan is an option but I can run into issues as some of the perl modules are older (very) versions.
I was wondering, if I can copy modules from the remote server to my local server. Can I do that? Are there other options?
It's not safe to copy modules from one machine to another because things may not be set up identically. It's best to reinstall them.
You can use the autobundle command in the cpan shell to create a dump of all the modules you have installed on the old machine. You can then use that dump to tell the cpan shell on the new machine what modules to install.
Thanks to Polar Bear, here's a link to an article that explains how to reinstall the autobundle.
The solution suggested by Andy Lester is perhaps the best way to do it. I found a documentation here in addition to ones suggested.
In my case however this was not straight forward because the source server environment is very old and there were many dependencies that I will need to manually resolve. In general if you have similar environments and clean installs, the auto bundle approach will make it easy.

Puppet get username from Configuration file using puppet

I need to build a RPM for a set of libraries, but the problem is I can compile and build it in Dev server and need to deploy in all QA, PROD and test servers which has different user names, so I need to build my rpm to contain and pick username for respective servers during installation, can someone help me with this. How to do this using puppet..? Is that possible?
This cannot be done cleanly with stock RPMs.
As a hack, you can have a %post script chown all the files after detecting which username to use, but that's going to cause errors later when you do things like try to verify the RPM installation.
I'd recommend (a) having a new username that you use for the RPM/service across all servers or (b) building separate RPMs for each target environment.

Installing Node in a linux grid server

So some background, I'm installing Node on a host server, but it's a grid server not a server that's solely for my website.
The grid server doesn't have a root user/ administrative powers. So to install node I found this workaround: http://iantearle.com/blog/media-temple-grid-and-nodejs . It's a Linux Grid server, I've never used Linux so if someone could explain to me what the commands mean, especially: ./configure --prefix=~/opt/
Lastly I followed the steps but when I try to run the node command in the server it says node:command not found - which is why I'm trying to understand the steps. Thanks
To explain the process:
Configure
The configure script is responsible for getting ready to build the software on your specific system. It makes sure all of the dependencies for the rest of the build and install process are available, and finds out whatever it needs to know to use those dependencies.
Unix programs are often written in C, so we’ll usually need a C compiler to build them. In these cases the configure script will establish that your system does indeed have a C compiler, and find out what it’s called and where to find it.
Make
Once configure has done its job, we can invoke make to build the software. This runs a series of tasks defined in a Makefile to build the finished program from its source code.
The tarball you download usually doesn’t include a finished Makefile. Instead it comes with a template called Makefile.in and the configure script produces a customised Makefile specific to your system.
3.Make Install
Now that the software is built and ready to run, the files can be copied to their final destinations. The make install command will copy the built program, and its libraries and documentation, to the correct locations.
--prefix=~/opt/ -> will set the build directory to /home/yourhome/opt directory.
Now if you didnt get errors while doing those 3 steps explained above make sure you did the following:
nano ~/.bash_profile
export PATH=~/opt/bin:${PATH}
nano is a text editor and you are opening .bash_profile file with it.
you need to add export PATH=~/opt/bin:${PATH} in that file and save it using ctrl+x
Then restart your terminal.
Specified github repository for nodejs is outdated. use the following link instead.
git clone https://github.com/nodejs/node.git
P.S node:command not found usually happens when the program is not installed correctly or it's executable isnt in your terminal's PATH variable.

puppet install non forge module

I'm fairly new to puppet and I want to install a puppet module not using the puppet forge.
I have a page similar to the puppet forge where I keep my modules. I have 2 instances one is a Linux server so I can ssh into, and one is can work from remotely.
I have used git clone to make a branch, and I have copied the module i want into a folder inside that branch. How do I install the module into my Linux server?
When I ssh into my linux instance I get this message
puppet module list --tree
/opt/puppet/share/puppet/modules (no modules installed)
If you want to write your own modules and then use them on your own servers,
follow the guidelines in https://docs.puppetlabs.com/puppet/latest/reference/modules_fundamentals.html
In particular the puppet module generate is good for getting started with a skeleton. Use the files in the skeleton (Modulefile, manifests etc) to build a tar ball then refer to https://docs.puppetlabs.com/puppet/latest/reference/modules_installing.html#installing-from-a-release-tarball to install the tarball

How to use puppet to install and configure custom app?

My goal is for my users to start with a base Linux machine, install puppet, clone my GitHub repo and run puppet apply myapp.pp, this should then using puppet:
1) configure the system with any pre-requisites etc,
2) git clone another repo that contains my application code
3) compile, install and configure my application.
The specifics of getting Puppet to do 1, 2 and 3 seem fairly straight-forward, but what I cannot understand is if I should write a Puppet Module, or just a Manifest?
I started with a Manifest, but templating did not seem to work, puppet always complained it could not find the .erb files. That work can be seen here: https://github.com/adamretter/exist-puppet.
After making some enquiries, I was told that I needed to refactor my code into a Puppet module, which I have started to do here: https://github.com/adamretter/puppet-exist.
However there seems to be no way to run puppet apply on a module, so how do I achieve what I am looking for? Someone said that I need to call my module from a small .pp file stub, but I cannot see how to do that in the same git repo, as when I try to include it, it says it cannot find my module?
Are there any good examples where this is kinda thing is already done?
I have tried to follow the Puppet documentation, but it seems to make leaps or assume too much: https://docs.puppetlabs.com/guides/module_guides/bgtm.html
First of all, post your errors when you run a command, that will help debug the problem. Here are a few tips you can follow:
To apply a standalone module, you need to have the following structure :
<modulename>/manifests/init.pp
/<subname>.pp
init.pp content may look like this :
class <modulename> {
notify {"New module using Puppet apply":}
include <modulename>::<subname>
}
subname.pp content may look like this :
class <modulename>::<subname> {
# Some manifest
}
All these files need to be physically on the client machine in order for puppet apply to work. And you need to be in the parent directory of <modulename> while running puppet apply command. You can do,
puppet apply -e 'include <modulename>'
As #FelixFrank suggested, you can give the modulepath as an argument.
puppet apply -e 'include <modulename>' --modulepath=/path/to/modules

Resources