I have several systemd-nspawn
containers I would like to connect to via ansible
and run a series of scripts on each of them.
The traditional way is to use an SSH connection, I do that for other environments. In this case, the Ansible playbook will be ran on containers running on the same host which do not have SSH installed.
Is it possible to configure the playbook so that it uses the shell
command of the containers to run its modules?
If not I will either install SSH on them, or use salt
which will source its calls from the containers out.
You should take a look at the connection plugins and use it by setting
ansible_connection
var for each host that is a nspawn container in your inventory.If you don't find one that fit your situation, you can develop one locally (inspired from the docker one e.g.) then reference it with the config
defaults.connection_plugins