Is it possible to bring 4-5 containers with docker-compose then run ansible roles?(Ansible can be installed onto one container or run from my local pc to a containers) So basically those 4-5 containers will be my target hosts.
Sure, it's possible. You would target an image, not a container, by running Ansible as part of your Dockerfile. For example, something like:
FROM ubuntu:bionic
# Install prerequisities for Ansible
RUN apt-get update
RUN apt-get -y install python3 python3-nacl python3-pip libffi-dev
# Install ansible
RUN pip3 install ansible
# Copy your ansible configuration into the image
COPY my_ansible_project /ansible
# Run ansible to configure things
RUN ansible-playbook /ansible/playbook.yml
Note also that the packer tool can (a) build docker images and (b) has an ansible provisioner.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With