Issue #15080 has been updated by James Turnbull.

Status changed from Unreviewed to Requires CLA to be signed
Assignee set to jayendren maduray

Thanks for your patch! Could you please read our contribution guidelines 
(https://github.com/puppetlabs/puppet/blob/master/CONTRIBUTING.md) and sign a 
CLA. It'd be awesome if you could submit this as a pull request.

Thanks again!
----------------------------------------
Bug #15080: puppet provider/exec.rb issue on puppet 2.7.14/2.7.16
https://projects.puppetlabs.com/issues/15080#change-68840

Author: jayendren maduray
Status: Requires CLA to be signed
Priority: Normal
Assignee: jayendren maduray
Category: exec
Target version: 
Affected Puppet version: 
Keywords: 
Branch: 


* Puppet Versions: 2.7.14_1/2.7.16
* Operating System: FreeBSD
* Steps to Reproduce: 
* Using the following definition that is used to add/update entries in 
/etc/rc.conf

<pre>
define shell_config($file, $key, $value, $ensure = 'present')
{
  case $ensure {
    default: { err ( "unknown ensure value ${ensure}" ) }
    present: {
      exec {
        "shell_config_unique_$ensure '$file$key'":
         path => ["/sbin","/bin","/usr/sbin","/usr/bin"],
          unless => "test `grep -cE '^[ \t]*$key=' -- $file` -le 1",
          command => "sed -i '' -e '/$key=\".*\"/d' $file";
        "shell_config_create_$ensure '$file$key'":
         path => ["/sbin","/bin","/usr/sbin","/usr/bin"],
          unless => "grep -qE '^[ \t]*$key=' -- $file",
          command => "echo 'testing!'; printf '%s=\"%s\"\n' '$key' '$value' >> 
'${file}'";
        "shell_config_update_$ensure '$file$key'":
          unless => "grep -qE '^[ \t]*$key=\"$value\"' -- $file",
          command => "sed -i '' -e 's/$key=\".*\"/$key=\"$value\"/' $file";
      }
    }
    absent: {
      exec {  "shell_config_delete_$ensure $file$key":
         path => ["/sbin","/bin","/usr/sbin","/usr/bin"],
          onlyif => "grep -qE '^[ \t]*$key=' -- $file",
          command => "sed -i '' -e '/$key=\".*\"/d' $file";
      }
    }
  }
}

define rc_conf($value)
{
  shell_config { "rc_conf_local_${name}":
    file => "/etc/rc.conf",
    key => $name,
    value => $value;
  }
}
</pre>

* class entry in nodefile:
rc_conf { vmware_guest_vmhgfs_enable: value => "YES" } 

* Expected Results:
* If the entry is not present /etc/rc.conf, puppet should add the entry 
(working on puppet-2.7.10)
*

<pre>
notice: 
/Stage[main]/Virtualguest/Rc_conf[vmware_guest_vmhgfs_enable]/Shell_config[rc_conf_local_vmware_guest_vmhgfs_enable]/Exec[shell_config_update_present
 '/etc/rc.confvmware_guest_vmhgfs_enable']/returns: executed successfully
debug: 
/Stage[main]/Virtualguest/Rc_conf[vmware_guest_vmhgfs_enable]/Shell_config[rc_conf_local_vmware_guest_vmhgfs_enable]/Exec[shell_config_update_present
 '/etc/rc.confvmware_guest_vmhgfs_enable']: The container 
Shell_config[rc_conf_local_vmware_guest_vmhgfs_enable] will propagate my 
refresh event
debug: Exec[shell_config_unique_present 
'/etc/rc.confvmware_guest_vmhgfs_enable'](provider=posix): Executing check 
'test `grep -cE '^[ ]*vmware_guest_vmhgfs_enable=' -- /etc/rc.conf` -le 1'
debug: Executing 'test `grep -cE '^[ ]*vmware_guest_vmhgfs_enable=' -- 
/etc/rc.conf` -le 1'
debug: Exec[shell_config_create_present 
'/etc/rc.confvmware_guest_vmhgfs_enable'](provider=posix): Executing check 
'grep -qE '^[ ]*vmware_guest_vmhgfs_enable=' -- /etc/rc.conf'
debug: Executing 'grep -qE '^[ ]*vmware_guest_vmhgfs_enable=' -- /etc/rc.conf'
debug: Exec[shell_config_create_present 
'/etc/rc.confvmware_guest_vmhgfs_enable'](provider=posix): Executing 'printf 
'%s="%s"
' 'vmware_guest_vmhgfs_enable' 'YES' >> '/etc/rc.conf''
debug: Executing 'printf '%s="%s"
' 'vmware_guest_vmhgfs_enable' 'YES' >> '/etc/rc.conf''
notice: 
/Stage[main]/Virtualguest/Rc_conf[vmware_guest_vmhgfs_enable]/Shell_config[rc_conf_local_vmware_guest_vmhgfs_enable]/Exec[shell_config_create_present
 '/etc/rc.confvmware_guest_vmhgfs_enable']/returns: executed successfully
</pre>

* Actual Results:
* puppet 2.7.14_1 and puppet 2.7.16:

<pre>
notice: 
/Stage[main]/Virtualguest/Rc_conf[vmware_guest_vmhgfs_enable]/Shell_config[rc_conf_local_vmware_guest_vmhgfs_enable]/Exec[shell_config_update_present
 '/etc/rc.confvmware_guest_vmhgfs_enable']/returns: executed successfully
debug: 
/Stage[main]/Virtualguest/Rc_conf[vmware_guest_vmhgfs_enable]/Shell_config[rc_conf_local_vmware_guest_vmhgfs_enable]/Exec[shell_config_update_present
 '/etc/rc.confvmware_guest_vmhgfs_enable']: The container 
Shell_config[rc_conf_local_vmware_guest_vmhgfs_enable] will propagate my 
refresh event
debug: Exec[shell_config_unique_present 
'/etc/rc.confvmware_guest_vmhgfs_enable'](provider=posix): Executing check 
'test `grep -cE '^[ ]*vmware_guest_vmhgfs_enable=' -- /etc/rc.conf` -le 1'
debug: Executing 'test `grep -cE '^[ ]*vmware_guest_vmhgfs_enable=' -- 
/etc/rc.conf` -le 1'
debug: Exec[shell_config_create_present 
'/etc/rc.confvmware_guest_vmhgfs_enable'](provider=posix): Executing check 
'grep -qE '^[ ]*vmware_guest_vmhgfs_enable=' -- /etc/rc.conf'
debug: Executing 'grep -qE '^[ ]*vmware_guest_vmhgfs_enable=' -- /etc/rc.conf'
err: 
/Stage[main]/Virtualguest/Rc_conf[vmware_guest_vmhgfs_enable]/Shell_config[rc_conf_local_vmware_guest_vmhgfs_enable]/Exec[shell_config_create_present
 '/etc/rc.confvmware_guest_vmhgfs_enable']/returns: change from notrun to 0 
failed: Could not find command ' '
</pre>

* Notes:
* Resolved by using provider/exec.rb from puppet 2.7.10
* File: /usr/local/lib/ruby/site_ruby/1.8/puppet/provider/exec.rb
*

<pre>
--- /usr/local/lib/ruby/site_ruby/1.8/puppet/provider/exec.rb   2012-06-18 
11:27:07.000000000 +0200
+++ /root/provider_exec.rb      2012-06-18 11:26:20.000000000 +0200
@@ -1,3 +1,6 @@
+require 'puppet/provider'
+require 'puppet/util/execution'
+
 class Puppet::Provider::Exec < Puppet::Provider
   include Puppet::Util::Execution
 
@@ -63,9 +66,11 @@
   end
 
   def extractexe(command)
-    # easy case: command was quoted
-    if command =~ /^"([^"]+)"/
-      $1
+    if command.is_a? Array
+      command.first
+    elsif match = /^"([^"]+)"|^'([^']+)'/.match(command)
+      # extract whichever of the two sides matched the content.
+      match[1] or match[2]
     else
       command.split(/ /)[0]
     end
</pre>


-- 
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