Ask Your Question
0

hi , I would like to delete the content of file and rewrite it ; Error while evaluating a Resource Statement, Duplicate declaration: File[/etc/snmp/snmpd.conf] is already declared at ...

asked 2018-06-01 06:24:11 -0600

ich-z gravatar image

updated 2018-06-01 07:25:10 -0600

DarylW gravatar image

.

class snmp (
 $myname = 'snmpd.conf',
  $snmpname   = $::snmp::params::snmpname,
) inherits ::snmp::params {

  package { 'snmp':
    name    => $snmpname,
    ensure  => present,
  }

file { '/etc/snmp/snmpd.conf.backup':
ensure => 'present',
mode => '0644',
source => '/etc/snmp/snmpd.conf',
}

file { '/etc/snmp/snmpd.conf':
ensure => 'absent',
}

file { '/etc/snmp/$myname':
ensure => 'present',
mode => '0644',
content => 'ekofkoerfk',
}

}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-06-01 07:27:31 -0600

DarylW gravatar image

Puppet is declaritive, you say 'this is what I want the endstate of a resource to be'. You also cannot declare the same resource mutiple times, or you get the error you have above. It is not a shell script, where you tell puppet each step it should do to reach an objective.

In your example, only having a file resource delcaring the content of the file is sufficient, that will 'wipe out' the existing file and replace it's content with the expected content.

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: 2018-06-01 06:24:11 -0600

Seen: 63 times

Last updated: Jun 01