Skip to content

maszyman/ansimple

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansimple

A simple version of Ansible, specifically the ansible-playbook program.

Features

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>.

Setup

Input files

Before running the playbook, please make sure that you defined the hosts in INI file, and the playbook in YAML file.

SSH

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_keys

Test the connection with ssh <username>@<host>. You should be able to log in without being asked for the password.

Usage

  • First, install the package:
python -m venv .venv
. .venv/bin/activate
python -m pip install .
  • To run ansimple with the provided exemplary input files:
ansimple --hosts ./data/hosts --playbook ./data/playbook.yaml

By default, the username $USER is used to connect to the nodes. You may change it, passing --user <username>.

Development:

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 install

Testing

To run the tests:

poetry run pytest .

Code quality

The code is formatted using black. Imports are sorted with isort. The code is linted with mypy. All those tools run with pre-commit.

About

Simple Ansible

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages