Ask Your Question
1

Order of types

asked 2013-04-26 11:14:11 -0500

xtraclass gravatar image

I have a simple question, but I think the issue is important.

Let's say, we have something like

exec {... }
->
file {... }

If I use an onlyif condition in the exec block, it can happen - of course - that the exec is not executed and therefore the file block is also not 'executed'.

Is there any nice and beautiful solution to achieve that the file block is done even if exec is not done (because not necessary)?

And I know it sounds like a totally 101 question, but it's not. It bothers me. I think the exec resource is some other ... (more)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-04-26 12:00:49 -0500

ramindk gravatar image

updated 2013-04-26 12:19:32 -0500

You're thinking about it incorrectly though it's a mistake many have made when they start using Puppet. Take this example

file { '/etc/haproxy/haproxy.conf': } ~> service { 'haproxy': }

You don't worry that the file is going to be rewritten every time or that each time Puppet looks at the file regardless of changes it will restart the service. The only real different between File and Exec in this case is the method of determining action is exposed to you with an Exec and not with File.

In your example the exec will always be evaluated before the file ... (more)

edit flag offensive delete link more
2

answered 2013-04-26 17:29:57 -0500

lavaman gravatar image

Ordering is totally separate from state checking.

In your example, even if an unless or onlyif keeps the exec from running, your file will still be applied if it is not present.

This is because puppet still treats those resources independently and only uses the -> to determine the order in which to apply the resources, not to determine whether it should apply the resources.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2013-04-26 11:14:11 -0500

Seen: 170 times

Last updated: Apr 26 '13