Ask Your Question

error in multiple file creation

asked 2014-11-11 06:00:16 -0500

Chutki gravatar image


I have written below code to create multiple file under /etc/dummy/manifests

class dummy::mulfil{

$filename = ["aaa","bbb","ccc"]

file {$filename:
ensure => 'file',
path => "/etc/dummy/manifests/${filename}"

need o/p like below


but I get below error

Failed to apply catalog: Cannot alias File[bbb] to ["/etc/dummy/manifestss/aaabbbccc"] at /etc/dummy/manifests/mulfil.pp:13; resource ["File", "/etc/dummy/manifests/aaabbbccc"] already declared at /etc/dummy/manifests/mulfil.pp:13

Also why its creating file name together "/etc/dummy/manifestss/aaabbbccc"

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-11-11 08:53:30 -0500

Future Parser has an iterator now

$mustseemovies = ['interstellar','hobbit','hunger games']
each($mustseemovies) |$movie| { notice "Go see ${movie} Now! " }
edit flag offensive delete link more


I am getting below error when i try to compile your code "Could not match |$movie| at /etc/dummy/manifests/movie.pp:4 on node" below is code class dummy::movie { $mustseemovies = ['interstellar','hobbit','hunger games'] each($mustseemovies) |$movie| { notice "Go see ${movie}"}

Chutki gravatar imageChutki ( 2014-11-12 00:49:42 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-11-11 06:00:16 -0500

Seen: 206 times

Last updated: Nov 11 '14