Execute ansible playbook on a docker container

0 votes
I'm trying to execute an ansible playbook on a docker container before running it on the actual platform(just to be safe). How do I do this? Can I please get a dockerfile for the same?
Jan 21 in Ansible by Ram
279 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Hey @Ram, you could use a dockerfile something like this:

# Start with the ubuntu image
FROM ubuntu
# Update apt cache
RUN apt-get -y update
# Install ansible dependencies
RUN apt-get install -y python-yaml

 # Set variables for ansible
WORKDIR /tmp/ansible
ENV PATH /tmp/ansible/bin:/sbin:/usr/sbin:/usr/bin
ENV ANSIBLE_LIBRARY /tmp/ansible/library
ENV PYTHONPATH /tmp/ansible/lib:$PYTHON_PATH

 # add playbooks to the image. This might be a git repo instead
ADD playbooks/ /etc/ansible/
ADD inventory /etc/ansible/hosts
WORKDIR /etc/ansible

 # Run ansible using the site.yml playbook
RUN ansible-playbook /etc/ansible/site.yml -c local
answered Jan 21 by Vedant

Related Questions In Ansible

0 votes
1 answer
0 votes
1 answer

Running a playbook using Ansible on Jenkins

Hey, @Asha seems like you've added a ...READ MORE

answered Apr 4 in Ansible by Akhil
45 views
0 votes
1 answer

How do I execute a shell script and then use the result in ansible

This can work out for you: - name: ...READ MORE

answered Apr 11, 2018 in Ansible by shubham
• 6,480 points
223 views
0 votes
1 answer

Running ansible command on a single server when it is deployed to multiple servers

You can try the run_once attribute: Example from ...READ MORE

answered Jun 13, 2018 in Ansible by DareDev
• 6,520 points
76 views
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,120 points
57 views
0 votes
1 answer

Execute a command using ansible playbook

Hey @Reshma, You can use the URI ...READ MORE

answered Jan 17 in Ansible by Sameer
42 views
0 votes
1 answer

Ansible playbook to wget a file

Hey @Celia, one recommendation, try not using ...READ MORE

answered Jan 16 in Ansible by Vaishu
314 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.