How to use puppet to install and configure custom app? - puppet

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

Related

I am using coverity to analyse node-ts template for a service. What should I use to build it?

Steps:
Installed coverity
Configured compiler
cov-configure --javascript
cov-configure --cs
I am stuck at the build step of cov-build. Yarn is used to run and configure the service. But I am not sure what coverity wants here.
I tried a couple of npm run commands, every time end up getting this:
[WARNING] No files were emitted. This may be due to a problem with your configuration
or because no files were actually compiled by your build command.
Please make sure you have configured the compilers actually used in the compilation.
I also tried different compilers, but no luck.
What should be done in this case?
You need to do a file system capture for Javascript files. You can accomplish this by running cov-build with the --no-command flag.
cov-build --dir CoverityIntermedediateDir --no-command --fs-capture-list list.txt
Lets break down these commands:
--dir: intermediate directory to store the emitted results (used for cov-analyze later).
--no-command: Do not run a build command and to look for certain file types
--fs-capture-list: Use the file that is provided to specify which files to look at and possibly emit to the intermediate directory.
A recommended way to generate the list.txt file is to grab it from your source control. If using git run:
git ls-files > list.txt
I want to also point out that if you don't have a convenient way to get a file listing in order to use the --fs-capture-list command you can use --fs-capture-search command and pair that with a filter to exclude the node_modules directory.
The coverity forums have some useful questions and answers:
Node.js File system capture
Really, the best place to look is at the documentation. There are several examples of what you want to do in their guides.

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

installing a 3rd party module on a puppet agent

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.

Is there a way to access a Puppet manifest from a remote http host?

If I have a manifest at http://mysite.com/somemanifest.pp, can I apply it from a remote server? I'm trying:
puppet apply http://mysite.com/somemanifest.pp
but getting
Could not run: Could not find file http://mysite.com/somemanifest.pp
I'd like to do this without running a puppet master.
Why don't you want to run a puppetmaster? It's created for exactly this situation.
If you absolutely cannot run a puppetmaster, then you would have to wrap your puppet calls in another script that first downloads the file (with curl or wget) and apply them after a successful download. Given that the puppetmaster is a fairly simple application to run, I don't see how not using it would be any better.

Resources