Using a makefile to automate a puppet installation

The first make will back up some files. It is important to run it only once.

The second run, "make" alone, will go through the needed steps for installation: if rsync is not installed, it will install rsync; if the needed files are not present in the /puppet hierarchy, it will download the files using rsync; if puppet is not installed, it will install it; then, it will run puppetd with a bootstrap configuration file and… fail!

Yes, fail. Because you need to sign the host certificate, don't you? Once you signed it on the master node, then you'll run make config. If everything is properly configured, this will set up your host according to the manifests.

The last command, make test will just run a puppetd --test to ensure that everything is properly set up.

And that's all. Installing one host this way takes about 5 minutes, downloads included. And using cssh I could even install puppet on several machines in parallel.

Am I missing something? Oh, yes, the real Makefile 🙂

PUPPETMASTER=i.am.your.master.com
SYNCSERVER=$(PUPPETMASTER)

all: install config

install: /usr/bin/puppetd

config:
        puppetd --config /puppet/common/files/bootstrap/client.conf --server $(PUPPETMASTER) --test

test:
        puppetd --test

clean:
        -rm -rf /puppet
        -apt-get remove puppet facter
        -apt-get autoremove

backups:
        cp /etc/apt/sources.list{,.dist}

/usr/bin/rsync:
        apt-get install rsync

/puppet/usa/files/sources.list: sync-puppet-conf

/puppet/volatile/keys/apt: sync-puppet-conf

update: /puppet/usa/files/sources.list /puppet/volatile/keys/apt
        cp /puppet/usa/files/sources.list /etc/apt/sources.list
        apt-key add /puppet/volatile/keys/apt 
        apt-get update
        apt-key update

sync-puppet-conf: /usr/bin/rsync
        rsync -zav $(SYNCSERVER)::PuppetConf /puppet

/usr/bin/puppetd: update
        apt-get install puppet

Advertisement

2 thoughts on “Using a makefile to automate a puppet installation

  1. Thanks for the pointer :)The rsync stuff actually happens on purpose, but I can't say more here. But I'll be happy to share one of these days in the canteen. Today? Friday beer? :)–bronto

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.