Yes that will work, there are a few erros in your code though:
- $location should not be quoted when calling epp()
- the name of the variable for epp should not begin with $

class profiles::upgrade ($location = undef) {

  file { '/root/my_file.txt':
      ensure  => file,
      content => epp('my_module/my_file.epp', { 'location' => $location })
  }
}

The template:

location = <%= $location %>

-Kevin

On Tuesday, September 17, 2019 at 2:40:11 PM UTC+2, Andy Hall wrote:
>
> That's great thanks !! So if I want to pass a param to the template from 
> the command line would this work ??
>
> 1. The command:
>
> bolt plan run profiles::puppet_upgrade servers=hostname.domain.com 
> location=uk --user root
>
> 2. The plan:
>
> plan profiles::puppet_upgrade(
>   TargetSpec $servers,
> ) {
>
>   apply($servers) {
>     class { 'profiles::upgrade': location => $location }
>   }
> }
>
> 3. The manifest:
>
> class profiles::upgrade ($location = undef) {
>
>   file { '/root/my_file.txt':
>       ensure  => file,
>       content => epp('my_module/my_file.epp', { '$_location' => 
> '$location' })
>   }
> }
>
> 4. The template:
>
> location = <%= $_location %>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/885d255a-902a-4dd4-a578-85f37122ae82%40googlegroups.com.

Reply via email to