run playbooks in rc.local

I met a problem using ansible-playbook today.

I prepared a playbook, and tried to trigger the playbook inside rc.local. The idea is that the machine will be bootstrapped automatically on boot.

But rc.local does not output anything. While, if run ‘sudo /etc/rc.local’, the playbook is played correctly.

Has anyone tried to run playbook inside rc.local?

Regards

Hello Xiaohui ,

No idea if that will work, but here are just some quick ideas anyway: log output to a file, and then check the results. i.e., in rc.local: the_command > /tmp/debug.txt 2>&1 also, in case $PATH isn’t set, specify /the/full/path/to/files/and/commands.

I tried to run something different that depended on networking which
failed with the same symptoms (manually "yes", on boot "no")

At least on Debian it has/had to do with the transition from classic
init to systemd.
If you search the net for "rc.local not working" it seems the rc.local
stuff is executed too early.
E.g. https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=122207

So you might have to reconfigure it to run after networking is setup.

Regards,
Benjamin