Re: [Puppet Users] Unable to replace a symlink with regular file

732 views
Skip to first unread message
Message has been deleted

Gary Larizza

unread,
Jan 21, 2013, 1:34:00 PM1/21/13
to puppet...@googlegroups.com
You should be able to add  "force => true" and get this to work for you

On Monday, January 21, 2013 at 9:19 AM, Sean Kelly wrote:

I am running Puppet 2.7.x (x varies from 14 to 20 on different machines).  I am trying to use Puppet to deploy a new Zabbix agent configuration file. On all machines where the file wasn't a symlink, the deployment worked. However, every machine where it is a link, Puppet refuses to replace teh link with a regular file or do anything with it.

I've read the type reference, and I see nothing specific about forcing symlink replacement. I've looked at the source, and it seems like remove_existing should be unlinking teh symlink ahead of my new file. But, it isn't happening. Any suggestions on hwo to do this?

File {
        backup => main,
        owner => "root",
        group => $operatingsystem ? {
                freebsd => "wheel",
                default => "root",
        },
        mode => 644,
        ensure => present,
}

class zabbix {
file {
'/usr/local/etc/zabbix':
ensure => 'directory';
'/usr/local/etc/zabbix/zabbix_agentd.conf':
content => template("zabbix/zabbix_agentd.conf.erb"),
}
...

root@victor:~# ls -ld /usr/local/etc/zabbix/zabbix_agentd.conf
lrwxr-xr-x  1 root  wheel  64 Dec  9  2011 /usr/local/etc/zabbix/zabbix_agentd.conf -> /usr/local/flightaware/monitor-scripts/zabbix/zabbix_agentd.conf

root@victor:~# puppet agent --test --debug --color=no | grep zabbix_agentd.conf 2>&1
debug: /Stage[main]/Zabbix/Service[zabbix_agentd]/subscribe: subscribes to File[/usr/local/etc/zabbix/zabbix_agentd.conf]
debug: /Stage[main]/Zabbix/File[/usr/local/etc/zabbix/zabbix_agentd.conf]: Autorequiring File[/usr/local/etc/zabbix]
debug: /Stage[main]/Zabbix/File[/usr/local/etc/zabbix/zabbix_agentd.conf]/mode: Not managing symlink mode

Thanks!

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/mw3dMbd96TkJ.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Sean Kelly

unread,
Jan 21, 2013, 2:31:15 PM1/21/13
to puppet...@googlegroups.com
I've tried that as well. It doesn't work.

Gary Larizza

unread,
Jan 21, 2013, 5:11:18 PM1/21/13
to puppet...@googlegroups.com
Have you tried explicitly setting the ensure value - a la "ensure => file" - on the files that might exist as symlinks?  I tested this out locally and was able to get Puppet to overwrite a symlink with a file declaration.
To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/uzMEDywYxD8J.

Sean Kelly

unread,
Jan 21, 2013, 5:55:07 PM1/21/13
to puppet...@googlegroups.com
That worked, thanks! I didn't realize "file" was even a valid setting for ensure.

notice: /Stage[main]/Zabbix/File[/usr/local/etc/zabbix/zabbix_agentd.conf]/ensure: defined content as '{md5}6b3491d534f04c4eea426b9cf83e637d'
info: /Stage[main]/Zabbix/File[/usr/local/etc/zabbix/zabbix_agentd.conf]: Scheduling refresh of Service[zabbix_agentd]
notice: /Stage[main]/Zabbix/Service[zabbix_agentd]: Triggered 'refresh' from 1 events
notice: Finished catalog run in 5.32 seconds

Again, thanks!
Reply all
Reply to author
Forward
0 new messages