Skip to content

Quickly deploy Ansible in a Docker container for hassle-free, consistent setups across local and server environments.

License

Notifications You must be signed in to change notification settings

2g4/dockerized-ansible

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dockerized Ansible

Prerequisites

  1. Generate ed25519 SSH key pair

    ssh-keygen -t ed25519 -f {YOUR_PATH} -C "svcanisble"
  2. Copy the private key to .secret folder

    cp {YOUR_PATH} .secret/id_ed25519

Providing Ansible access to remote hosts

  1. Create svcanisble user on remote host.
  2. Add svcanisble user to sudoers group.
  3. Add svcanisble user's public key (./config/pub-ed25519.key) to authorized_keys file.

Helpers

Script Description
run.build.sh Build image
run.sh SSH into the container

Examples

Echo test

ansible-playbook playbook/echotest.yml -i inventory/test.ini -K

Other

  1. In case the private hey has a passphrase
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

You will be prompted to enter the passphrase.

  1. The example uses ed25519 SSH Key, if you want to use RSA key, you need to change the following files:

    • .secret/id_ed25519 -> .secret/id_rsa
    • Dockerfile:
      ARG privateKey=id_ed25519
      ARG privateKey=id_rsa
  2. The image supports hot reloading of playbooks, allowing you to just rerun the command after any changes, and it will execute with the updated playbook.

About

Quickly deploy Ansible in a Docker container for hassle-free, consistent setups across local and server environments.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published