I have installed puppetmaster in ubuntu 11.04 and i have installed puppet in all my clients. I have joined all my puppet clients with puppet master. Is it possible to copy a file to all these puppet clients from puppet master?
For example:
I have the file named datas.xls in my Desktop (Puppet Master). How do i copy this files to all my puppet clients in the following location ( /home/operator1/Desktop/Backup/) ?
Update:
- Hi still the file is not getting shared.
- How to modify this line
puppet:///modules/module_name/datas.xls
the file to be copied is under this location/etc/puppet/modules/mymodule/manifests/datas.xls
?
Error on Client: (Resolved)
root@testing:~# puppetd --test
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find class sudo at /etc/puppet/manifests/site.pp:2 on node testing.chn.jd.com
warning: Not using cache on failed catalog
err: Could not retrieve catalog; skipping run
Error 2 on Client:
root@tme13:~# puppetd --test
err: Could not run Puppet configuration client: Could not retrieve local facts: bad URI(is not URI?): http://169.254.169.254/2008-02-01/meta-data/<HTML><HEAD><TITLE>HTTP access denied</TITLE></HEAD><BODY><img src/
New Update:
How to apply this module to all nodes? Such that the file will be copied to all nodes.
Puppet is a bit of a monster to get your head around, so learning by example is no bad thing. In the below I'm assuming you're using modules - please say in a comment if you're not or if you need more details about how to put the module together.
Let's say you start a new module called
mymodule
. In the puppet home directory (usually/etc/puppet
) on the puppet master you should create the module manifests and files directory:Then create a file in that directory named
init.pp
and enter:Then put the
datas.xls
file into the module'sfiles
directory - in this example inmodules/mymodule/files/
. (Note there can also be atemplates
directory for templates).In the
manifests/site.pp
file you need to import the module and include the class by doing something like:Make sure that all your nodes inherit from base and that should be all you need to do. As of puppet 0.25 you can use regular expressions in the node name, eg:
Let me know in comments if you require further clarification.
Setting up a client to talk to the puppet master
On the client, you need to do:
Then edit
/etc/default/puppet
and changeSTART=no
toSTART=yes
.Also edit
/etc/puppet/puppet.conf
and add a line to the[main]
section to tell it where to find the puppet master:Then we can do a test run with
sudo puppetd --test
. If you get key errors you may need to go on to the puppet master server and sign the client key. To check the exact name you can dosudo puppetca --list
and thensudo puppetca --sign server1.mydomain.com
(or whatever the server name was from the list command).Now start the puppet service with
sudo service puppet start
and you should be away. The puppet service will run every hour, so if you update your puppet recipes then all your clients will also be updated.Deleting Files
I note in the original question you wanted to know how to delete files. You would edit the
manifests/init.pp
to beOther useful tips
If you are having trouble there are a few things you can do. On any machine with puppet installed you can check your syntax by running
or check the whole lot by taking out the
--ignoreimport
flag, though that can lead to some funny error messages that aren't really errors I've found. You can also run puppet live on a puppet client machine by doing:which shows various useful output, with errors and warnings highlighted in different colours. If you want even more detail you could run:
but that generally generates so much output that it is hard to wade through, so only do that if you've already tried the previous steps and are stuck and need to see everything being done.
Note this is based on puppet 0.25.x which is what I use at work currently, and is also the version in Ubuntu 10.04. The puppet code in the main section will definitely still work, but later versions of puppet have new flags that can help with debugging output.