I’ve run into a strange situation where calling data_bag_item()
results in converge-time updates to the resolv.conf
nameservers are not being picked up dynamically. In short:
- We leverage the
resolver
cookbook in the run_list to update our nameserver for DNS resolution. - Later in the run_list, we have a cookbook recipe with a
remote_file
resource which sources from an artifact repository who’s hostname is only resolvable using the updated nameservers.
Normally, this works perfectly fine, as the updated nameservers are dynamically picked up (per the chef-client switch to using Ruby’s resolv-replace instead of glibc). However, as soon as I modify the recipe, or another recipe in the cookbook, or a different cookbook in the run_list to include include a call to a data bag (encrypted in this case), the remote_file
resource fails to resolve the hostname unless I converge a second time.
I did manage to work around this by wrapping the data_bag_item(...)
call inside a lambda block, but further testing revealed that ALL data bag calls would need to be wrapped. Basically, the first recipe calling for data bag content and downloading a remote_file worked in isolation with the lambda function, but adding another recipe with a non-lambda data bag call to the run_list would again break the dynamic nameserver update.
Has anyone else run into this? It seems like this a bug in how Chef is handling the recipe/resource when the data bag enters the picture, almost like resolv-replace
is being overridden.
There is no functional dependency between our cookbook and the resolver
cookbook, as the artifact repository is a configurable attribute that we do flip between public/private repositories for testing purposes – therefore, I don’t have a dependency called out in the metadata.
Yes, I could completely circumvent the issue by either putting in an IP instead of a hostname, or by having a 2-phase bootstrap converge process (resolver update, then primary run_list)… but it seems odd that this works as expected when there are no data bag calls.