how to model maintenance activities with ansible

There was some discussion on irc about possible implementations where ansible can perform necessary maintenance activities. One example is making sure necessary services are running and restart if necessary. This could be a maintenance playbook that is run on the localhost via cron. This would avoid the need for an agent that is regularly running on a host. Since it is localhost only, it wouldn’t have to run over ssh.

Do others have any ideas for how such a maintenance mode might be implemented?

My thought is in connection.py we teach it that if the server is 127.0.0.1 or the literal “localhost” to use a local connection class, and therefore we make 127.0.0.1 special. Basically we’d create a LocalConnection class in connection.py,
so Runner wouldn’t need to know anything at all about this.

(The unit tests, probably, then move to cheat and use 127.0.0.2, which the code would still give a real SSH connection to)

This is also quite useful for running playbooks inside of a kickstart.

It would be neccessary to maintain the sudo behavior in connection.py, but that shouldn’t be too difficult as we could just exec various commands directly with sudo
instead of all the crazy things that module does to work around the TTY issues.

If you want to work on a patch for that, that would be great.