On Jul 25, 8:56 am, rvlinden <rene.vanderlinde...@gmail.com>
wrote:> All,
>
> I was wondering if I could create a relationship between a define and
> an exec (without using stages)
Certainly, and you provide an example yourself. I guess your question
is rather how to set up certain particular relationship(s).
> Example
>
> I call a define ''sudo::manage'' with the variable
''$sudofile'' where the
> variable contains and array or sudofiles I want to deploy.
>
> sudo::manage { $sudofile: }
>
> Once the sudofiles are installed, I want to execute a command to
> syntax check all the sudo files
>
> exec { ''sudo_syntax_check'':
> command => "/usr/sbin/visudo -cq",
>
> }
>
> I tried to create a relationship between the two, but I can''t get
it
> right
Does it not work to replace
sudo::manage { $sudofile: }
with
sudo::manage { $sudofile:
before => Exec[''sudo_syntax_check'']
}
? I mean, that''s the first thing that comes to mind for me, so maybe
you tried it already, but I don''t see offhand why it wouldn''t
work.
If it indeed doesn''t work then the error messages might be
illuminating.
> The only thing that does work is this line below, but that is not what
> I want (unless I could dynamically find out what the last records was
> instead of using [0])
>
> Sudo::Manage[$sudofile[0]] -> Exec[sudo_syntax_check]
>
> NOTE: As last resort I could use stages and run the exec in a post-
> main stage, but I''m trying to keep away from this.
Good for you. You should not need run stages for this problem, and
using them risks complicating your life more than you want or need.
To the best of my knowledge, every relationship graph achievable via
run stages is also achievable via resource-level declarations (in
principle). The converse, however, is false: run stages are a fairly
blunt tool, typically giving you many more relationships than you
actually need, or than you would write manually.
John
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.