Closed julienlavergne closed 1 year ago
What OS is host03
?
RHEL 6
Wondering what the best fix for this is - the BSD service checks use:
for SERVICE in `find /etc/rc.d /usr/local/etc/rc.d -type f`; do
$SERVICE status 2> /dev/null || $SERVICE check 2> /dev/null
echo "`basename $SERVICE`=$?"
done
The server.service
information will run through available init systems and RHEL6 is sysvinit based nothing newer (IIRC). I'm not sure why this would be executed though as /etc/init.d/
should exist on a RHEL 6 system? Which means it should match this check.
One option could be to check for "check" or "status" existing within the file, but that also feels very hacky.
A quick solution here is probably to make the above referenced check also check the OS is not Linux, because /etc/rc.d
is dangerous to look through on Linux machines.
Good question. What's wrong with doing something like this?
elif host.get_fact(Which, command="service"):
service_operation = sysvinit.service
Otherwise, I don't see where command
is set to the correct command.
I’ve expanded the check in https://github.com/Fizzadar/pyinfra/commit/1017a618a09d267234fee353c00586d59f39314b - relying on the service command alone could miss systems without it. I have also explicitly blocked loading the bsd init fact in https://github.com/Fizzadar/pyinfra/commit/fb5edc89af863677c326bfc5264dd7ec7164f531.
Describe the bug
While running this task:
the following command may be run on target host :
sudo /etc/rc.d/rc.sysinit check
, which triggers a host to reboot in order to perform a filesystem check, which cannot be performed on mounted devices.To Reproduce
I am not so sure what kind of host you need that, But I think it has to be a bit old, typically RHEL 6.
Task is trying to use
systemctl
,rc-service
andinitctl
which are all not available. To get a service status on this machine, the required command issudo service sshd status
.The relevant log with
--debug
and-vvv
:Expected behavior
I do not whish any command run by pyinfra to have the side effect of rebooting the machine without my consent.
Meta
v2.1