Developing web-apps and deploying them on top of docker containers using Ansible Playbooks

  1. RedHat Ansible 2.9.11
  2. Python 3.6.8
pip3 install ansible -y
ansible --version
vim /etc/myhosts.txt
vim /etc/ansible/ansible.cfg
ansible --version
ansible all --list-hosts
- hosts: dockerhost
gather_facts: false
tasks:
- name: conf yum for docker
yum_repository:
name: dockerrepo
baseurl: https://download.docker.com/linux/centos/7/x86_64/stable/
description: my docker repo desc
enabled: true
gpgcheck: 0
- name: install docker software
command: "yum install docker-ce --nobest -y"
- name: start docker services
service:
name: "docker"
state: started
enabled: yes
- name: install software python36
package:
name: python36
state: present
- name: install docker python library
pip:
name: docker-py
- name: pull image from hub
docker_image:
name: httpd:latest
source: pull
- name: run_container
docker_container:
name: myweb
image: httpd:latest
state: started
ports:
- "8082:80"
tty: true
detach: true
ansible-playbook docker.yml
docker ps
docker exec -it myweb /bin/bash
curl 192.168.0.12:8082
curl 192.168.99.103:8082/myapp.html

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store