A simple version of Ansible, specifically the ansible-playbook program.
The program allows to run the tasks from the playbook specified in YAML file (by default playbook.yaml in the current directory or specified with --playbook <filename>). Tasks are run on all the hosts from the group determined in the playbook. Available hosts are defined in INI file, by default taken from /etc/ansible/hosts or specified with --hosts <filename>.
Before running the playbook, please make sure that you defined the hosts in INI file, and the playbook in YAML file.
You need to set up the passwordless ssh connection so that ansimple can connect to the nodes specified in the hosts file. Please generate the keys and propagate the public one to the nodes. For example, for localhost:
ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod og-wx ~/.ssh/authorized_keysTest the connection with ssh <username>@<host>. You should be able to log in without being asked for the password.
- First, install the package:
python -m venv .venv
. .venv/bin/activate
python -m pip install .- To run
ansimplewith the provided exemplary input files:
ansimple --hosts ./data/hosts --playbook ./data/playbook.yamlBy default, the username $USER is used to connect to the nodes. You may change it, passing --user <username>.
This code makes use of Poetry to build, test, and package the project. To install the project run (remember to deactivate previously activated virtual environment):
poetry installTo run the tests:
poetry run pytest .The code is formatted using black. Imports are sorted with isort. The code is linted with mypy. All those tools run with pre-commit.