0

Please help me with solution to a problem I was facing , I am trying to install adobe CQ5(author/publish modes) using puppet script. I have defined instance.pp as defined type and passing ( author,publish) parameters in manifest file. But I am getting below mentioned error

"Duplicate declaration: Exec[] is already declared in file /tmp/vagrant-puppet/modules-0/cq/manifests/instance.pp:55; cannot redeclare at /tmp/vagrant-puppet/modules-0/cq/manifests/instance.pp:62 on node localhost.123.176.37.38"

Here is my puppet script for instance.pp

define cq::instance (
$installation_type,
$servername = $name,
$sling_run_modes = "author,dev",
$data_dir = "/home/vagrant/$name",
$install_path = "/home/vagrant/{$name}/cq5",
$min_heap = '256',
$max_heap = '1024',
$perm_gen = '300',
$cq_jar = "cq-author-4502.jar",
$port_author = "4502",
$port_publish = "4503",)  


{


$cq_port = $installation_type ? {
"author" => $port_author,
"publish" => $port_publish,
default => "4502",
}

if $installation_type in [ author, publish ] {
$type_real = $installation_type
} 


else {
fail('installation_type parameter must be author or publish')
}

   file { "/tmp/$servername .${cq_jar}" :
     ensure => "present",
     source => "puppet:///modules/cq/${cq_jar}",
     owner  => vagrant,
     mode   => 755

     }


file { [ "$data_dir", "$install_path", "$install_path/$type_real" ]:
ensure  => "directory",
mode    => 0755,
before  =>  Exec ["$name_move_jar"],
}   
exec {"$name_move_jar":
require => File["/tmp/${cq_jar}"],
cwd => "/tmp",
command => "cp ${cq_jar} $install_path/$type_real",
creates => "$install_path/$type_real/$cq_jar"
}

exec {"$name_unpack_CQ_jar":
command => "java -jar $cq_jar -unpack",
cwd => "$install_path/$type_real",
creates => "$install_path/$type_real/crx-quickstart",
require => Exec["$name_move_jar"],
}

file {"$install_path/$type_real/crx-quickstart/bin":
ensure  => directory,
require => Exec["$name_unpack_CQ_jar"],
}
file {"$name_start_script":
path => "$install_path/$type_real/crx-quickstart/bin/start",
content => template('cq/cq_5_6_start.erb'),
mode => 0777,
require => File["$install_path/$type_real/crx-quickstart/bin"],
before  => File["initd_script_$type_real"],
}
file {"$name_initd_script_$type_real":
path => "/etc/init.d/cq-$type_real",
content => template('cq/cq_init_d_5_6.erb'),
mode => 0777,
}


service {"cq-$type_real":
ensure => running,
enable=>true,
hasrestart  => true,
hasstatus => true,
require => File["initd_script_$type_real"],
}
}

and manifest file site.pp is

cq::instance {myauthor:
      installation_type => author,
    }

cq::instance {mypublish:
      installation_type => publish,
    }
Sven
  • 98,649
  • 14
  • 180
  • 226
Kiran
  • 123
  • 2
  • 5
  • 2
    You should work on your coding style, e.g. useful indentations that make your code more readable. – Sven Dec 17 '14 at 09:58

1 Answers1

3

Oh, that was hard to read!
You should really work on that, use puppet-lint.

The key problem is this:

Duplicate declaration: Exec[] is already declared in file

Notice how that says Exec[]?
It should contain the name of the exec, but it doesn't.

exec {"$name_move_jar":

This sets the name to the variable $name_move_jar.
That is not what you want.
You want ${name}_move_jar.
You really should use ${name} style variables.

Using curly braces makes it very clear which part is still part of the variable name and which isn't.
Functionally there is no difference, it just tells the parser more specific the variable name.
Take this for example:

notify { "$foo-bar": }

It's hard to tell what the variable here is. Is it $foo-bar? Or just $foo?
That example would be $foo (dashes are not allowed in variable names).
To avoid any confusion it's better to write ${foo}-bar instead.
Everybody knows that ${foo} is the variable.

If you need to concatenate variables to a string like:

notify { "${var1}${var2}": }

You must use that format.

faker
  • 17,496
  • 2
  • 60
  • 70