Ask Your Question
0

New to puppet: Can not distribute files across multiple agents

asked 2015-06-18 07:54:47 -0500

Red010 gravatar image
 - Hi there,

   I am new to puppet and i am trying to distribute my /etc/hello file across
   multiple systems. I have 2 systems:

   192.168.33.47    laptop-vm2.example.com  puppet
   192.168.33.46    laptop-vm1.example.com

   When i run puppet cert list -all, I see both the systems.

   I made the following site.pp:

   [root@laptop-vm2 manifests]# pwd
   /home/jeroen/puppet/manifests
   [root@laptop-vm2 manifests]# ls -rtl
   total 4
   -rw-r--r--. 1 root root 75 Jun 18 14:23 site.pp 
   [root@laptop-vm~/manifests]# cat site.pp 
   node default {  } 
   file { '/tmp/hello':     
   content => "Hello, world\n",
        } 

   [root@laptop-vm2 manifests]# puppet
   apply site.pp Notice: Compiled
   catalog for laptop-vm2.example.com in
   environment production in 0.19
   seconds Notice: Finished catalog run
   in 0.32 seconds [root@laptop-vm2
   manifests]# 

   It doesnt distribute to
   laptop-vm1.example.com. I also tried
   adding laptop-vm1.example.com to
   site.pp, but it doesnt distribute.

   I also tried this:

   node 'laptop-vm1.example.com' {  
   } 
   file { '/tmp/hello':     content =>
   "Hello, world\n",
        }

   But then i get the following error:

   [root@laptop-vm2 manifests]# puppet
   apply site.pp Error: Could not find
   default node or by name with
   'laptop-vm2.example.com,
   laptop-vm2.example, laptop-vm2' on
   node laptop-vm2.example.com Error:
   Could not find default node or by
   name with 'laptop-vm2.example.com,
   laptop-vm2.example, laptop-vm2' on
   node laptop-vm2.example.com
   [root@laptop-vm2 manifests]# 


   Any help is appreciated.

   Red
edit retag flag offensive close merge delete

Comments

Please check your entries in /etc/hosts. There seems to be issue with resolving the names.

far4d gravatar imagefar4d ( 2015-06-19 05:43:11 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-06-19 18:01:58 -0500

GregLarkin gravatar image

There are a couple of issues here - first, your file resource is outside of the context of your node definitions, from what you've posted. Node definitions should look like this:

node 'laptop-vm1.example.com' {
  file { '/tmp/hello':
    content => "Hello, world\n",
  }
}

node 'laptop-vm2.example.com' {
  file { '/tmp/hello':
    content => "Hello, world\n",
  }
}

node default {
  file { '/tmp/hello':
    content => "Hello, world\n",
  }
}

The next problem is that you are running puppet apply on the site.pp file. Puppet apply only enforces the catalog on the machine that you run it on, not on other machines. site.pp is usually loaded by the Puppet master when you running puppet agent on a machine, and then the master compares the node name to the list of node definitions to build the catalog.

It doesn't usually make sense to run puppet apply site.pp. You'll typically have another file in your module's tests/ or examples/ subdirectory that has a number of include and/or resource statements in it, and you'll puppet apply that file.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-06-18 07:45:02 -0500

Seen: 54 times

Last updated: Jun 19 '15