Automation

How-To: Automatically pulling manifest updates

By Elevate posted 08-07-2015 23:46

  

Overview

How to set up a Junos OS device to update automatically.

 

Resolution

 

How are manifest updates automatically pulled by Junos OS devices?

 

The answer is "it depends".  Each organization can decide how the puppet agent is "kicked" to run.  There are a number of options here, and I would encourage you to read through the postings on the Puppet Labs support website as well.

 

The way I run my puppet agent is: "puppet agent -t --no-daemonize".  This makes the puppet agent run once.  I've been told that most folks do not run the puppet agent in daemon mode.

 

So how do you get a "repeat performance"?  Some people use cron to do this.  If you want to do this as well, here is what you can do in your manifest node definition: add a 'cron' resource definition.  The following kicks the puppet agent to run every 10 minutes.

 

1
	cron { puppetrun:
2
	      environment => "PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/sbin:/opt/bin:/opt/sdk/juniper/bin",
3
	      command => "puppet agent --onetime --no-daemonize > /tmp/puppetrun.txt 2>&1",
4
	      user => puppet,
5
	      minute => '*/10',
6
	   }

If you log in to the box as user=puppet, you can verify that the cron was installed using:

 

01
	% crontab -l
02
	# HEADER: This file was autogenerated at Wed Feb 20 03:57:57 -0800 2013 by puppet.
03
	# HEADER: While it can still be managed manually, it is definitely not recommended.
04
	# HEADER: Note particularly that the comments starting with 'Puppet Name' should
05
	# HEADER: not be deleted, as doing so could cause duplicate cron jobs.
06
	# Puppet Name: puppetrun
07
	PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/sbin:/opt/bin:/opt/sdk/juniper/bin
08
	*/10 * * * * puppet agent --onetime --no-daemonize > /tmp/puppetrun.txt 2>&1
09
	% crontab -l
10
	# HEADER: This file was autogenerated at Wed Feb 20 03:57:57 -0800 2013 by puppet.
11
	# HEADER: While it can still be managed manually, it is definitely not recommended.
12
	# HEADER: Note particularly that the comments starting with 'Puppet Name' should
13
	# HEADER: not be deleted, as doing so could cause duplicate cron jobs.
14
	# Puppet Name: puppetrun
15
	PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/sbin:/opt/bin:/opt/sdk/juniper/bin
16
	*/10 * * * * puppet agent --onetime --no-daemonize > /tmp/puppetrun.txt 2>&1

For more details on the common Puppet resource types, check here:

http://docs.puppetlabs.com/references/latest/type.<wbr/>html

 

Please note that Puppet for Junos OS does not support all of the standard resource types.  I have tested the cron resource type, and it's been shown to work.

 

Source

 

J-Net Forum answer 02-20-2013 by jschulman.


#JunosOS
#How-To
#puppet
0 comments
0 views

Permalink