Ansible setup - jhu-information-security-institute/infrastructure GitHub Wiki
Prerequisites:
- SSH access to host
- Install sshpass:
$ sudo apt-get install sshpass - Create ssh keys for your user:
$ ssh-keygen -t ed25519 -f id_ed25519 -C <USERNAME> - Copy the id_ed25519.pub contents into ~/.ssh
- Copy the key to the container:
$ ssh-copy-id -i ~/.ssh/id_ed25519.pub -p 2222 <USERNAME>@localhost - Test the key:
$ ssh -i ~/.ssh/id_ed25519 <USERNAME>@localhost -p 2222
Setup:
- Create a venv:
$ python3 -m venv ansible - Activate your new venv:
$ source ansible/bin/activate - Install ansible into the venv:
(ansible)$ pip install ansible - Create your
inventoryandinventory/group_varsfolders - Create your inventory files in the
inventoryfolder. E.g., create01-attack.ymlwith the following contentskali2024: hosts: localhost - Create your
all.ymlvariables file in theinventory/group_varsfolder. Example contents are:ansible_connection: ssh ansible_port: 2222 ansible_ssh_private_key_file: ~/.ssh/id_ed25519 - Verify the inventory:
(ansible)$ ansible-inventory -i inventory --list - Ping the hosts in your inventory:
(ansible)$ ansible <HOSTNAME> -m ping -i inventory -u <USERNAME>