[Dnsmasq-discuss] dnsmasq command to add dhcp-host record?

Dominik dl6er at dl6er.de
Thu Jan 7 10:44:16 GMT 2021


Hey,

On 06.01.21 21:00, Jelle de Jong wrote:
> dnsmasq inotify is trigger happy and it would be nice to have a second
> or so delay in the actual re-scanning, that would help a lot...
>
> currently when ansible places the file dnsmasq tries to read the
> config file, but the content is not always there yet and then it is
> messed up. 

dnsmasq configured the inotify watchers to trigger on either
file-close-after-write or file-moved-into-directory. There should be no
way to write to the file without dnsmasq noticing this, EXCEPT, if the
file is not closed after having done the writing. I just tried the
following:

1. Created an empty file in my hostsdir (hostsdir=/etc/hostsdir) directory:

The dnsmasq log said:

Jan  7 11:36:03 dnsmasq[494780]: inotify, new or changed file
/etc/hostsdir/something
Jan  7 11:36:03 dnsmasq[494780]: read /etc/hostsdir/something - 0 addresses

2. Wrote some content into the file (echo "127.1.2.3 somebody" | sudo
tee /etc/hostsdir/something):

The dnsmasq log said:

Jan  7 11:37:49 dnsmasq[494780]: inotify, new or changed file
/etc/hostsdir/something
Jan  7 11:37:49 dnsmasq[494780]: read /etc/hostsdir/something - 1 addresses


On 06.01.21 21:00, Jelle de Jong wrote:
> currently when ansible places the file dnsmasq tries to read the
> config file, but the content is not always there yet and then it is
> messed up. 

Can you be a bit more specific about this messing up?


On 06.01.21 21:00, Jelle de Jong wrote:
> I need to rewrite the scripts to work in some notification bus

dnsmasq's dbus option may be something for you if you want to go down
this road.


Overall, I'd first check if Ansible closes the file correctly. dnsmasq
doesn't really have any other way to detect reliably when writing is
done. As you can see in my example above, everything works as expected
when doing things manually. Maybe there is another option specifically
for committing (writing + closing) the file in Ansible?


Best,
Dominik






More information about the Dnsmasq-discuss mailing list