Jira (PUP-11189) Add functions to iterate over files/templates in the current module

2021-09-21 Thread Ciprian Badescu (Jira)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Ciprian Badescu commented on  PUP-11189  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: Add functions to iterate over files/templates in the current module   
 

  
 
 
 
 

 
 We agree it is likely an improvement for the core functionality, but due to other issues demanding precedence, we don’t anticipate being able to address this any time soon. As such we are closing this as “Won’t Fix.” We may revisit it at a later time, and if so will re-open this ticket  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)  
 
 

 
   
 

  
 

  
 

   





-- 
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 puppet-bugs+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.408658.1627373801000.134716.1632218400095%40Atlassian.JIRA.


Jira (PUP-11189) Add functions to iterate over files/templates in the current module

2021-08-30 Thread Ben Ford (Jira)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Ben Ford commented on  PUP-11189  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: Add functions to iterate over files/templates in the current module   
 

  
 
 
 
 

 
 Dirk Heinrichs you might consider building and maintaining this yourself as a module on the Forge.  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)  
 
 

 
   
 

  
 

  
 

   





-- 
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 puppet-bugs+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.408658.1627373801000.119974.1630362840201%40Atlassian.JIRA.


Jira (PUP-11189) Add functions to iterate over files/templates in the current module

2021-08-05 Thread Dirk Heinrichs (Jira)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Dirk Heinrichs commented on  PUP-11189  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: Add functions to iterate over files/templates in the current module   
 

  
 
 
 
 

 
 Reid Vandewiele, thanks a lot for the detailed explanation. Yes, the request was to add (a) new function(s), not to modify any existing ones. I will definitely try to implement "module_files()" myself (using your example above) to get a quick result. However, I also think this might be useful for others, too, so it would be really great to have it shipped as part of Puppet itself.  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)  
 
 

 
   
 

  
 

  
 

   





-- 
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 puppet-bugs+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.408658.1627373801000.99868.1628144340032%40Atlassian.JIRA.


Jira (PUP-11189) Add functions to iterate over files/templates in the current module

2021-08-03 Thread Reid Vandewiele (Jira)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Reid Vandewiele commented on  PUP-11189  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: Add functions to iterate over files/templates in the current module   
 

  
 
 
 
 

 
 Thanks for that additional context, Dirk Heinrichs. That's helpful. I'm hearing that the simple case, copy files as-is from module to target, is achievable today with the File resource and recurse => remote. I'm also hearing that for a more complex, probably less common use case involving templates, it would be useful to have a general capability of inspecting module content dynamically from Puppet DSL code. Given the complexity and non-generality of the second use case, I don't think it would make sense to implement a series of content-type-specific functions to enable this. That is, I don't think extending or modifying find_template, find_file, etc. would be generally beneficial. It could make sense to extend a capability similar to the existing module_directory() function. For example, pairing it with a new module_files() function. A function like that could take a list of module-relative glob paths, and return an array of file paths. E.g.  
 
 
 
 
 call: module_files('module1/files/*', 'module2/templates/**/*.epp', 'module3/metadata.json')  
 
 
 return: [  
 
 
   "/etc/puppetlabs/code/environments/production/modules/module1/files/file1",  
 
 
   "/etc/puppetlabs/code/environments/production/modules/module1/files/file2",  
 
 
   "/etc/puppetlabs/code/environments/production/modules/module2/templates/tmp1.txt.epp",  
 
 
   "/etc/puppetlabs/code/environments/production/modules/module2/templates/tmp2.txt.epp",  
 
 
   "/etc/puppetlabs/code/environments/production/modules/module2/templates/subdir/tmp3.txt.epp",  
 
 
   "/etc/puppetlabs/code/environments/production/modules/module3/metadata.json",  
 
 
   

Jira (PUP-11189) Add functions to iterate over files/templates in the current module

2021-08-03 Thread Dirk Heinrichs (Jira)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Dirk Heinrichs commented on  PUP-11189  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: Add functions to iterate over files/templates in the current module   
 

  
 
 
 
 

 
 Reid Vandewiele, my use case is to manage files on the agent based on content of the "files" or "templates" directory of a module (or a sub directory thereof), so that I don't need to change the class' code every time new files are added. Anyway, I've read the documentation for the "file" resource again, and it looks like I can indeed achieve that with "recurse" (at least partly). Up to now, I've only used recurse together with "ensure => absent". It didn't come to my mind that it would also work this way. What's missing is the "templates" part, though. I also like the idea of using glob patterns here, which is currently not possible.  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)  
 
 

 
   
 

  
 

  
 

   





-- 
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 puppet-bugs+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.408658.1627373801000.97091.1627971180033%40Atlassian.JIRA.


Jira (PUP-11189) Add functions to iterate over files/templates in the current module

2021-08-02 Thread Reid Vandewiele (Jira)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Reid Vandewiele commented on  PUP-11189  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: Add functions to iterate over files/templates in the current module   
 

  
 
 
 
 

 
 I'm curious to understand the use case better. From my first reading of the desired goal, it seems like you should be able to do this today as follows:  
 
 
 
 
 file { 'target-directory':  
 
 
   ensure  => directory,
 
 
   path=> '/path/to/dir',  
 
 
   source  => 'puppet:///foo/subdir',  
 
 
   recurse => remote,  
 
 
 }  
 
 
 
  Dirk Heinrichs could you describe in a little bit more detail what you are trying to do specifically? Curious to understand better. Less the technical how-to of what you've tried; more the use case why/what-for. Hoping that a better understanding will shed some light on whether there's already a recommended way to do what you're looking for today, or if not, exactly what benefits the suggested improvement could provide, and how it looks when solving the target problem(s). Especially if introducing it would change the recommended way of solving the problem from an existing option today.  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
   

Jira (PUP-11189) Add functions to iterate over files/templates in the current module

2021-08-02 Thread Ciprian Badescu (Jira)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Ciprian Badescu commented on  PUP-11189  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: Add functions to iterate over files/templates in the current module   
 

  
 
 
 
 

 
 Ben Ford, is the required case also a common use case in the modules?  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)  
 
 

 
   
 

  
 

  
 

   





-- 
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 puppet-bugs+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.408658.1627373801000.96266.1627915260208%40Atlassian.JIRA.


Jira (PUP-11189) Add functions to iterate over files/templates in the current module

2021-07-29 Thread Dirk Heinrichs (Jira)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Dirk Heinrichs commented on  PUP-11189  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: Add functions to iterate over files/templates in the current module   
 

  
 
 
 
 

 
 I'm fine with globs, if extended glob syntax can be used, like "foo/sub/*/.ini".  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)  
 
 

 
   
 

  
 

  
 

   





-- 
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 puppet-bugs+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.408658.1627373801000.93757.1627550280024%40Atlassian.JIRA.


Jira (PUP-11189) Add functions to iterate over files/templates in the current module

2021-07-27 Thread Josh Cooper (Jira)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Josh Cooper commented on  PUP-11189  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: Add functions to iterate over files/templates in the current module   
 

  
 
 
 
 

 
 There is also the find_file function. It accepts a list of paths, but it only returns the first match:  
 
 
 
 
 ❯ tree  ~/.puppetlabs/etc/code/environments/production/modules/test/files/ 
 
 
 /home/josh/.puppetlabs/etc/code/environments/production/modules/test/files/  
 
 
 └── a  
 
 
 ├── b  
 
 
 └── c  
 
 
    
 
 
 1 directory, 2 files  
 
 
 ❯ bx puppet apply -e 'notice(find_file("test/a/b", "test/a/c"))'   
 
 
 Notice: Scope(Class[main]): /home/josh/.puppetlabs/etc/code/environments/production/modules/test/files/a/b  
 
 
 Notice: Compiled catalog for localhost in environment production in 0.02 seconds
  
 
 
 
  If we allow recurse, then there's the issue of recurse limit and making sure users don't accidentally DoS puppetserver dynamically adding file resources to the catalog (like PUP-10946). I have a preference for glob syntax, e.g. files('foo/subdir/*/.ini')? If we modify find_file then we should keep find_template in sync (as proposed in PUP-1214). Also, thoughts Charlie Sharpsteen and Reid Vandewiele?  
 
   

Jira (PUP-11189) Add functions to iterate over files/templates in the current module

2021-07-27 Thread Dirk Heinrichs (Jira)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Dirk Heinrichs commented on  PUP-11189  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: Add functions to iterate over files/templates in the current module   
 

  
 
 
 
 

 
 Would also be great if the new functions had an optional "recurse" parameter (default: false).  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)  
 
 

 
   
 

  
 

  
 

   





-- 
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 puppet-bugs+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.408658.1627373801000.90928.1627374240026%40Atlassian.JIRA.


Jira (PUP-11189) Add functions to iterate over files/templates in the current module

2021-07-27 Thread Dirk Heinrichs (Jira)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Dirk Heinrichs created an issue  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
 Puppet /  PUP-11189  
 
 
  Add functions to iterate over files/templates in the current module   
 

  
 
 
 
 

 
Issue Type: 
  New Feature  
 
 
Assignee: 
 Henrik Lindberg  
 
 
Components: 
 Functions, Language  
 
 
Created: 
 2021/07/27 1:16 AM  
 
 
Priority: 
  Normal  
 
 
Reporter: 
 Dirk Heinrichs  
 

  
 
 
 
 

 
 Puppet Version: 6.x, 7.x Puppet Server Version: 6.x, 7.x OS Name/Version: all Sometimes, one needs to put several files in place on an agent node that come from the same module. As it is now, one needs to explicitly name each file in an array to iterate over. This has the drawback that one needs to adapt the code whenever a new file is added to /files (or /templates) Desired Behavior: Be able to write something like that:  
 
 
 
 
 files('puppet:///modules/foo/subdir').each |$file| {  
 
 
   file {  
 
 
 ...  
 
 
   }  
 
 
  }