0

Can I use create_resources as requirement in a exec command in puppet class

$configFileDetails = getConfigFileDetails($allConfigurations['configurations'])
create_resources(change_config::fill_template, $configFileDetails)


   Change_config::Fill_template<| |> -> Exec<| title == "strating" |>

   exec { "strating":
        user        => 'root',
        environment => "JAVA_HOME=/home/ubuntu/tools/jdk1.6.0_45",
        path        => $command_path,
        command     => "sh ${agentLocation}/${product_pack}/bin/server.sh ${serverOptions}",
        logoutput => true,
        timeout => 3600,
   }

}

Is there a way to use the create_resources as the requirement for exec here ?

Malintha
  • 4,512
  • 9
  • 48
  • 82
  • VERY closely related to the [previous question](http://stackoverflow.com/questions/25375880/is-there-a-way-to-define-relationships-between-create-resources). – Felix Frank Aug 19 '14 at 13:45
  • I applied the suggested answer in previous one. That didn't work for me and neither this did not worked. – Malintha Aug 22 '14 at 10:21

1 Answers1

1

I guess you mean by requiring create_resources to require the created resources, if so then you can use a collector ensure order

exec { "strating" :
   ....
}
Myclass::Myfunc <||> -> Exec <| title == "strating" |> 

Hope this helps

webNeat
  • 2,768
  • 1
  • 20
  • 22
  • Nope :-) `No title provided and "Myclass::Myfunc" is not a valid resource reference` – Felix Frank Aug 19 '14 at 13:27
  • I forgot about the title but `myclass::myfunc` is used in the `create_resources` call. So `Myclass::Myfunc` should be a valid resource reference. – webNeat Aug 19 '14 at 13:37
  • 1
    No, unfortunately. The first parameter to `create_resources` is the title of a native or defined type (a string). It results in the declaration of 0 or more resources, referenced through `Myclass::Myfunc[respective-title]`, but wildcard references are not implemented. - You **can** reference multiple resources by type when using a [collector](http://stackoverflow.com/a/25376321/3356612). (Yes this question is most definitely spurious.) – Felix Frank Aug 19 '14 at 13:44
  • Un-down-voted ;) Note that the second collector can be safely replaced by a regular reference, but either is fine in this context. – Felix Frank Aug 19 '14 at 14:29
  • I guess it should be "Myclass::Myfunc <||> -> Exec <| title == "strating" |>" but not "Myclass::Myfunc <||> -> Exec <| title = "strating" |>" , note the == there ? WDYT ? – Malintha Aug 22 '14 at 09:10
  • but it is not working for me. It doesn't run the exec part. But it runs the create_reouses part correctly – Malintha Aug 22 '14 at 09:18
  • please check that you didn't set `refreshonly => true` or use `onlyif` or `unless` attributs on the `exec` – webNeat Aug 22 '14 at 10:15
  • I edited my question with my original code. Note , there are no refreshonly=> true or onlyif or unless in my exec – Malintha Aug 22 '14 at 10:25
  • this is weird.Could you run `sudo puppet agent -t` and show use the output ? – webNeat Aug 22 '14 at 10:53
  • there is fault in my side for permission. This answer is working fine. marked it as the correct – Malintha Aug 22 '14 at 13:10