Issue #19019 has been updated by Richard K. Miller.

Assignee changed from Richard K. Miller to eric sorenson

Hey thanks, Eric. For me, it's not clear how #2762 differs (much) from the 
alias attribute which already exists. As you know, we can already do the 
following, and for me there's not much gained by reversing the location of the 
command and the alias:
    exec { "curl -s https://getcomposer.org/installer | php -- 
--install-dir=/usr/local/bin":
      alias => "get_composer",
      creates => "/usr/local/bin/composer.phar",
    }

    file { "/usr/local/bin/composer.phar":
        require => Exec["get_composer"]
        mode => 0755,
        owner => "root",
    }

What I find elegant about a 'createdby' attribute on the "file" type is that it 
DRYs the duplication of the filename "/usr/local/bin/composer.phar" in the 
above two resource declarations and merges the two into one. I can manage the 
mode and owner in the same declaration as the exec. It also feels more "pure" 
to me to declare the resource as a noun (e.g. the file to be created) rather 
than as a verb (the command that does the creating.)

FWIW, I don't feel strongly about the attribute's name. It could be called 
"createdby" or "exec" or "source_exec". Maybe "source_exec" is most intuitive 
since the file type already has a "source" attribute. 

These two declarations seem elegant to me:

    file { "myfile":
      source => "puppet://mysource"
    }

    file { "myfile":
      source_exec => "mycommand"  # hypothetical syntactic sugar
    }


These two seem less elegant (though I recognize "exec" is sometimes necessary):

    exec { "mycommand":
      creates => "myfile"
    }

    source { "puppet://mysource":  # hypothetical syntactic vinegar
      creates => "myfile"
    }



----------------------------------------
Feature #19019: Add "createdby" parameter to "file" type
https://projects.puppetlabs.com/issues/19019#change-90426

* Author: Richard K. Miller
* Status: Needs More Information
* Priority: Normal
* Assignee: eric sorenson
* Category: language
* Target version: 
* Affected Puppet version: 
* Keywords: 
* Branch: 
----------------------------------------
I occasionally use **exec** + **creates** to install a file not easily 
available any other way.

<pre>
  exec { "curl -s https://getcomposer.org/installer | php -- 
--install-dir=/usr/local/bin":
    creates => "/usr/local/bin/composer.phar",
  }
</pre>

If there were a **createdby** parameter on the **file** type, I could reverse 
the clauses like this:
<pre>
  file { "/usr/local/bin/composer.phar":
    createdby => "curl -s https://getcomposer.org/installer | php -- 
--install-dir=/usr/local/bin",
  }
</pre>

...which would mean I could use **file** parameters like **mode**, **owner**, 
**group**, etc.

<pre>
  file { "/usr/local/bin/composer.phar":
    createdby => "curl -s https://getcomposer.org/installer | php -- 
--install-dir=/usr/local/bin",
    mode => 0755,
    owner => "root",
  }
</pre>

The **createdby** parameter would be somewhat similar to the **content** 
parameter except that it would create the file by running a local command 
instead of passing the content.

This may also help solve Issue #2762 and Issue #2546 .




-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to