From 37f9110b3a4971df6cf12a52f14203812e080d89 Mon Sep 17 00:00:00 2001 From: Lino Schmidt Date: Sun, 1 Feb 2026 12:34:13 +0100 Subject: [PATCH] Updated README --- README.md | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ab8b4fd..349efb7 100644 --- a/README.md +++ b/README.md @@ -1 +1,91 @@ -# Ansible \ No newline at end of file +# Ansible + +## Setup + +Rename `inventory/inventory.example.yml` to `inventory/inventory.yml` and adjust the host IPs and usernames as needed. + +To install and use Ansible on Windows, follow the [WSL Setup Instructions](#wsl-setup-instructions) below. + +## Usage + +run a playbook: + +```bash +ansible-playbook playbooks/.yml +``` + +run a playbook with sudo: + +```bash +ansible-playbook playbooks/.yml --ask-become-pass +``` + +## WSL Setup Instructions + +To use Ansible on Windows, you need to set up Windows Subsystem for Linux (WSL). +You then have the option to open a local Folder in VSCode and open a WSL terminal that points to the same folder under WSL. + +To enable proper file permissions for Ansible on WSL, you need to configure the WSL automount settings. + +```bash +sudo nano /etc/wsl.conf +``` + +Add the following lines: + +```ini +[automount] +enabled = true +options = "metadata,umask=022,fmask=0111" +``` + +restart WSL: + +```bash +wsl --shutdown +``` + +If you use a Network Drive, you have to mount it manually: + +```bash +sudo mkdir /mnt/ +sudo mount -t drvfs : /mnt/ -o metadata,umask=022,fmask=0111 +``` + +To mount it automatically on WSL start, add the following lines to `/etc/fstab`: + +```fstab +: /mnt/ drvfs metadata,umask=022,fmask=0111 0 0 +``` + +Reload fstab: + +```bash +sudo mount -a +``` + +Remove others write permissions: + +```bash +chmod -R o-w . +``` + +---- + +Install Ansible on WSL: + +```bash +sudo apt update +sudo apt install python3-pip pipx +sudo pipx install ansible +sudo apt install ssh-askpass +``` + +Add SSH Keys from Windows to WSL: + +```bash +cp -r /mnt/c/Users//.ssh ~/.ssh +chmod 700 ~/.ssh +chmod 600 ~/.ssh/id_rsa +chmod 644 ~/.ssh/id_rsa.pub +```