I'm looking on a way to test tag definition into my default node but did
not find it. What I would like to do is sort of:
node default {
if tagged("bootstrap") {
include bootstrap
}
}
so that "puppetd --test --tags bootstrap" matches, whereas "puppetd
--test" does not.
How could I achieve this ?
Regards,
JB
> I need to be able to execute some puppet statements at the end of an automatic
> installation, essentially packages removal. But I don't want it to be executed
> later.
The main question to answer is: why not? This makes your configuration
non-deterministic, which makes it vastly harder to express to puppet.
If you tell us why you want to do this, though, we might be able to suggest a
better approach that solves your problem. :)
Daniel
--
✣ Daniel Pittman ✉ dan...@rimspace.net ☎ +61 401 155 707
♽ made with 100 percent post-consumer electrons
I defined few steps in puppet configuration.
- The first one will be executed at the end of installation. It mainly
consist in packages removal and is called "bootstrap".
- The other ones will be executed after and consist in all other operations.
While performing some tests, I figure out that, for one node, one of the
package (let's call it package_A) I removed in first step is
re-installed because of dependency.
I'm fine with that except that this package_A will be purged during next
puppet run as well as the package I need to be installed. The run after
will reinstall packages, the next one will remove them, etc...
Basically, I've got 2 solutions:
1. keep package_A on all nodes
2. find a way to execute first step once, and once only.
As you can guess, I'm trying to use second one :)
In order to be able to apply my "bootstrap", I've included it in my
default node from which all others inherit. Now I need to find a way to
execute:
- Bootstrap step only at the beginning
- all steps but bootstrap after.
I tried tags (maybe wrongly) without success and that's why I'm asking
to the list.
Regards,
JB
> Hello, Seems I wasn't clear enough ;-)
Well, or I wasn't smart enough. ;)
[...]
> While performing some tests, I figure out that, for one node, one of the
> package (let's call it package_A) I removed in first step is re-installed
> because of dependency.
>
> I'm fine with that except that this package_A will be purged during next
> puppet run as well as the package I need to be installed. The run after will
> reinstall packages, the next one will remove them, etc...
>
> Basically, I've got 2 solutions:
> 1. keep package_A on all nodes
> 2. find a way to execute first step once, and once only.
>
> As you can guess, I'm trying to use second one :)
*nod* I would suggest one of two things:
One, find a way to declare that relationship statically to puppet rather than
dynamically, so that you don't get the cycle. Options there include using a
custom fact to determine if the package should be removed or not, using a
variable set on the node, or whatever.
Two, move the problem outside of puppet: you want this bootstrap to run once,
right? Can you get your node installation tool (we use people, FWIW) to run
that script once:
Step ten: execute 'wget -O- http://whatever/bootstrap | /bin/sh'
...or even use puppet:
exec { 'wget -O- http://whatever/bootstrap | /bin/sh':
creates => '/var/lock/bootstrap-run'
}
My preference is to use a "run once" script called by the SysV init process
that does the bootstrap operation, but whatever.
Oh, and that can be a puppet manifest if you want to stay coherent: you can
invoke puppet directly on a manifest without going through the central server,
so you don't have to resort to shell commands to make it work. :)
Regards,
class bootstrap {
if ($bootstrap_step){
... everything you want to do at this stage ...
}
}
node default {
include bootstrap
}
And in post-install actions in preseed/kickstart, just execute:
FACTER_bootstrap_step=true puppetd --test --server puppetsrv.domain.com
Regards,
JB