Issue #14797 has been updated by Kelsey Hightower.

Status changed from Unreviewed to Accepted

There are quite a few tickets around the behavior around this. I think we are 
at the point where we need to clearly define/verify the behavior when any 
resource requires an Exec resource. 
----------------------------------------
Bug #14797: "require => Exec" ignored when using template as content
https://projects.puppetlabs.com/issues/14797#change-64631

Author: Gaetan Allart
Status: Accepted
Priority: High
Assignee: 
Category: templates
Target version: 
Affected Puppet version: 2.7.11
Keywords: puppet template exec file
Branch: 


Hi,

I've developped a function that might replace file based on template according 
to exec result :

# Functions
        define configtemplate ($template,$file,$condition) {
                exec { "check_${file}_${condition}":
                        command => '/bin/true',
                        unless       =>  "/bin/grep -qF '${condition}' 
'${file}'";
                }
                file { "$file":
                        path => $file,
                        content => template($template),
                        require => Exec["check_${file}_${condition}"],
                }
        }

# Named : template if ip of server not present
        configtemplate { "/etc/bind/named.conf":
                template => "named/named.conf.erb",
                file => "/tmp/named.conf",
                condition => "$ipaddress",
        }


The problem is that the function is not testing the result of exec. Therefore, 
file is pushed at every call.



debug: 
/Stage[other]/Other/Other::Configtemplate[/etc/bind/named.conf]/File[/tmp/named.conf]/content:
 Executing 'diff -u /tmp/named.conf /tmp/puppet-file20120604-21313-xoww0p-0'
notice: 
/Stage[other]/Other/Other::Configtemplate[/etc/bind/named.conf]/File[/tmp/named.conf]/content:
 
--- /tmp/named.conf     2012-06-04 15:48:08.912408219 +0200
+++ /tmp/puppet-file20120604-21313-xoww0p-0     2012-06-04 15:50:33.415293057 
+0200
@@ -170,11 +170,3 @@
 //     allow-notify { <MASTER>; };
 //     notify no;
 //};
-
-zone "ataos-reprise.com" IN {
-        type master;
-        file "pri/ataos-reprise.com.zone";
-        allow-update { none; };
-        notify yes;
-        also-notify { 88.190.22.99; };
-};

debug: Finishing transaction 70329434276740
info: FileBucket got a duplicate file {md5}e46556933c2ac503aac5c66f315c40ee
info: 
/Stage[other]/Other/Other::Configtemplate[/etc/bind/named.conf]/File[/tmp/named.conf]:
 Filebucketed /tmp/named.conf to puppet with sum 
e46556933c2ac503aac5c66f315c40ee
notice: 
/Stage[other]/Other/Other::Configtemplate[/etc/bind/named.conf]/File[/tmp/named.conf]/content:
 content changed '{md5}e46556933c2ac503aac5c66f315c40ee' to 
'{md5}0fbccf011bd90c028f703f15a40a96e2'
debug: 
/Stage[other]/Other/Other::Configtemplate[/etc/bind/named.conf]/File[/tmp/named.conf]:
 The container Other::Configtemplate[/etc/bind/named.conf] will propagate my 
refresh event



-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to