augeas, ntp.conf and iburst

316 views
Skip to first unread message

Kenton Brede

unread,
Mar 12, 2014, 10:35:09 AM3/12/14
to puppet...@googlegroups.com
I want to add a server on top of the stack in ntp.conf like:

server time.example.com iburst
server 0.rhel.pool.ntp.org iburst
...

I came up with this:

  augeas { 'ntp.conf':
    context => '/files/etc/ntp.conf',
    changes => [
      'ins server before server[1]',
      'set server[1] time.example.com' ,
    ],
    onlyif  => 'match server[. = "time.example.com"] size == 0',
  }

This in fact adds "time.example.com" on top of "0.rhel.pool.ntp.org iburst" but excludes "iburst" at the end of the line.

server time.example.com
server 0.rhel.pool.ntp.org iburst
...

I tried "'set server[1] "time.example.com iburst"' but get error "Could not evaluate: Save failed with return code false."

augtool prints this:
/files/etc/ntp.conf/server[1] = "0.rhel.pool.ntp.org"
/files/etc/ntp.conf/server[1]/iburst

So the iburst line doesn't really have a variable.

How do I append "iburst" at the end of "time.example.com?"

Thanks,

--
Kent




zerozer...@gmail.com

unread,
Mar 13, 2014, 6:04:36 AM3/13/14
to puppet...@googlegroups.com
On Wednesday, March 12, 2014 3:35:09 PM UTC+1, kbrede wrote:
 
How do I append "iburst" at the end of "time.example.com?"

AFAICT in augtool this works:

  set /files/etc/ntp.conf/server[1] "time.example.com iburst"

So, did you actually try the following? Mind the quotes.

  changes => [
      'ins server before server[1]',
      'set server[1] "time.example.com iburst"' ,
  ],


Marco

badmeischter

unread,
May 15, 2018, 5:17:58 PM5/15/18
to Puppet Users
This is an old thread, however I was desperate to find an answer for the same question and would like to share what I found out


Am Donnerstag, 13. März 2014 11:04:36 UTC+1 schrieb zerozer...@gmail.com:
On Wednesday, March 12, 2014 3:35:09 PM UTC+1, kbrede wrote:
 
How do I append "iburst" at the end of "time.example.com?"

AFAICT in augtool this works:

  set /files/etc/ntp.conf/server[1] "time.example.com iburst"

NOPE, this  will not work. Assuming you are in the augtool shell:

augtool> match /files/etc/ntp.conf/server
/files/etc/ntp.conf/server[1] = 3.ch.pool.ntp.org
/files/etc/ntp.conf/server[2] = 0.ch.pool.ntp.org
/files/etc/ntp.conf/server[3] = 2.ch.pool.ntp.org
/files/etc/ntp.conf/server[4] = 1.ch.pool.ntp.org
augtool> match /files/etc/ntp.conf/*[iburst]
/files/etc/ntp.conf/server[1] = 3.ch.pool.ntp.org
/files/etc/ntp.conf/server[2] = 0.ch.pool.ntp.org
/files/etc/ntp.conf/server[3] = 2.ch.pool.ntp.org
augtool> set /files/etc/ntp.conf/server[4]/iburst
augtool> match /files/etc/ntp.conf/*[iburst]
/files/etc/ntp.conf/server[1] = 3.ch.pool.ntp.org
/files/etc/ntp.conf/server[2] = 0.ch.pool.ntp.org
/files/etc/ntp.conf/server[3] = 2.ch.pool.ntp.org
/files/etc/ntp.conf/server[4] = 1.ch.pool.ntp.org


David Lutterkort

unread,
May 16, 2018, 5:24:22 PM5/16/18
to Puppet Users


On Tuesday, May 15, 2018 at 2:17:58 PM UTC-7, badmeischter wrote:
This is an old thread, however I was desperate to find an answer for the same question and would like to share what I found out

Am Donnerstag, 13. März 2014 11:04:36 UTC+1 schrieb zerozer...@gmail.com:
On Wednesday, March 12, 2014 3:35:09 PM UTC+1, kbrede wrote:
 
How do I append "iburst" at the end of "time.example.com?"

AFAICT in augtool this works:

  set /files/etc/ntp.conf/server[1] "time.example.com iburst"

NOPE, this  will not work. Assuming you are in the augtool shell:

augtool> match /files/etc/ntp.conf/server
/files/etc/ntp.conf/server[1] = 3.ch.pool.ntp.org
/files/etc/ntp.conf/server[2] = 0.ch.pool.ntp.org
/files/etc/ntp.conf/server[3] = 2.ch.pool.ntp.org
/files/etc/ntp.conf/server[4] = 1.ch.pool.ntp.org
augtool> match /files/etc/ntp.conf/*[iburst]
/files/etc/ntp.conf/server[1] = 3.ch.pool.ntp.org
/files/etc/ntp.conf/server[2] = 0.ch.pool.ntp.org
/files/etc/ntp.conf/server[3] = 2.ch.pool.ntp.org
augtool> set /files/etc/ntp.conf/server[4]/iburst
augtool> match /files/etc/ntp.conf/*[iburst]
/files/etc/ntp.conf/server[1] = 3.ch.pool.ntp.org
/files/etc/ntp.conf/server[2] = 0.ch.pool.ntp.org
/files/etc/ntp.conf/server[3] = 2.ch.pool.ntp.org
/files/etc/ntp.conf/server[4] = 1.ch.pool.ntp.org

The missing ingredient is that you need to create an `iburst` node underneath your new server; in augtool something like

ins server before server[1]
set server[1] time.example.com
touch server[1]/iburst

save

The 'touch' will create a node with no content/value, which is exactly what the Ntp lens expects to output 'iburst' after the server name. I highly recommend dumping the whole tree structure in cases like this with something like 'print /files/etc/ntp.conf' in augtool (or using the brand new 'augmatch' command line tool, e.g. 'augmatch -a /etc/ntp.conf' ;)

David
Reply all
Reply to author
Forward
0 new messages