Basically, I found that when I did a manual chef-client run across my
network, I found that it was always saying X resources updated even when
there should have been no changes. gchristensen from #chef pointed me at
the whyrun method of testing to see what was actually being flagged as
updated, and I found that in particular it was flagging on the NRPE LWRP
files that are generated. There is no check being done by the LWRP, it
simply creates the file on each client run.
I’d like to help fix this problem, since I have some available time to poke
at this, and I could use a pointer towards how other cookbooks approach
this kind of scenario. I don’t want to simply test if the file exists,
because the parameters could have been updated. I’m assuming that I should
instead generate the file inside the cache directory and then compare
checksums if the file exists and copy it to the destination if they do not
match (or if the file doesn’t previously exist)? Or is there a more elegant
way to handle this?
Looking through the logs and comments it looks like this used to be done
via a template, which I would assume would have actually solved this
problem natively. I’m not sure why that was moved away from, but I imagine
there was a good reason (possibly Erubis performance on generating
potentially lots of one-line files?).
–
~~ StormeRider ~~
“Every world needs its heroes […] They inspire us to be better than we
are. And they protect from the darkness that’s just around the corner.”
This is actually simpler than I thought. The problem was that the LWRP was
manually setting "new_resource.updated_by_last_action(true)", so it was
always being flagged as updated. When in reality, simply removing that
allows the file provider to properly flag whether or not the resource has
been updated.
--
~~ StormeRider ~~
"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."
Basically, I found that when I did a manual chef-client run across my
network, I found that it was always saying X resources updated even when
there should have been no changes. gchristensen from Chef Infra (archive) pointed me at
the whyrun method of testing to see what was actually being flagged as
updated, and I found that in particular it was flagging on the NRPE LWRP
files that are generated. There is no check being done by the LWRP, it
simply creates the file on each client run.
I'd like to help fix this problem, since I have some available time to
poke at this, and I could use a pointer towards how other cookbooks
approach this kind of scenario. I don't want to simply test if the file
exists, because the parameters could have been updated. I'm assuming that I
should instead generate the file inside the cache directory and then
compare checksums if the file exists and copy it to the destination if they
do not match (or if the file doesn't previously exist)? Or is there a more
elegant way to handle this?
Looking through the logs and comments it looks like this used to be done
via a template, which I would assume would have actually solved this
problem natively. I'm not sure why that was moved away from, but I imagine
there was a good reason (possibly Erubis performance on generating
potentially lots of one-line files?).
--
~~ StormeRider ~~
"Every world needs its heroes [...] They inspire us to be better than we
are. And they protect from the darkness that's just around the corner."