puppet module not doing anything

1

I successfully installed the puppetlabs java module using command puppet module install puppetlabs-java.

I created a puppet module using command puppet module generate ...

I have two manifest files init.pp and java.pp. Later i will have more.

init.pp

class mystuff {
  anchor { 'mystuff::begin': }
  -> class { 'mystuff::java': }
  -> anchor { 'mystuff::end': }
}

java.pp

class mystuff::java(){
  class { 'java':
    package => 'java-1.8.0-openjdk-devel'
  }
}

I then build the puppet module using command puppet module build.

I then installed the module using command puppet module install ~/.../pkg/...-0.1.0.tar.gz.

My idea was to test it with a new manifest file so i created a file called test-it.pp.

test-it.pp

class { 'mystuff': }

I then called puppet apply ./test-it.pp. And i get the following logo output:

Warning: /etc/puppetlabs/puppet/hiera.yaml: Use of 'hiera.yaml' version 3 is deprecated. It should be converted to version 5
   (in /etc/puppetlabs/puppet/hiera.yaml)
Notice: Compiled catalog for masternode.mydomain.com in environment production in 0.15 seconds
Notice: /Stage[main]/Java/Package[java]/ensure: created
Notice: /Stage[main]/Java::Config/File_line[java-home-environment]/ensure: created
Notice: Applied catalog in 7.72 seconds

But now when i go to my slave node and i type java it says command not found.

What did i do wrong?

arnonuem

Posted 2019-08-27T08:09:44.570

Reputation: 111

Answers

0

OK i found the solution or understood what i did wrong. First of all i tried to invoke the puppet installation on the master node. By running puppet apply ./test-it.pp. Since this did not work i tried to invoke it on the slave node using sudo /opt/puppetlabs/bin/puppet agent -t instead.

For this to be working i renamed the test-it.pp to site.pp and moved it to /etc/puppetlabs/code/environments/production/manifests/.

It took some seconds and now i can use java on the slave node like expected.

arnonuem

Posted 2019-08-27T08:09:44.570

Reputation: 111

Glad you found a solution and hope you have these cleared out by now. Puppet will perform changes only on the machine that you run the commands to. So running the puppet apply on the master would have applied the manifest to the master. Now the puppet agent -t is running all the modules/manifests that you have specified in the node definition on the puppet master. In your current config, you can have the manifest as you specified it under production/manifests. (Continued) – Jimmy_A – 2019-09-05T16:01:58.203

In general, it should not have mattered the name of the manifest test-it.pp or site.pp as long as you specify it in the node. Later on, when you add modules with their own manifests you can name them whatever you like. E.g production/modules/tomcat/manifests/version_9.pp. In the node definition, you will call it as tomcat::version_9. This is useful if you have multiple manifests/versions/installations. You can have one node call tomcat::version_9 and another node tomcat::version_8 by adding a second manifest in the module production/modules/tomcat/manifests/version_8.pp – Jimmy_A – 2019-09-05T16:05:45.680

Your current config works because by default the node looks in production/manifests/site.pp. By adding modules though you can have separate manifests that do specific jobs, instead of putting them all in one. Furthermore, with a node definition, you can specify different environments and or variables for each machine. – Jimmy_A – 2019-09-05T16:12:29.577

@Jimmy_A Thank you very much for the clarification. Before it was like: It is not working and i have no idea why, oh it is working but i have no idea why :) – arnonuem – 2019-09-06T18:35:51.013