Wednesday, 2 November 2016

Run puppetmaster/puppetclients using Dockers 2/4


In my earlier post, we already have set up puppet master and puppet client in the Guest OS, since its easily portable for deployment of applications I would create an docker image so that it would be easy for us to deploy the same in other machines to test in any environment without any overheads.

you can see the previous post on how to install puppet : http://sunlnx.blogspot.in/2016/11/installconfigure-puppet-serverpuppet.html

You first need to install docker packages 


Downloaded the docker images of Centos 6, which will pull the latest docker image.

root@ubuntu:~# docker pull centos:6
6: Pulling from library/centos

Digest: sha256:f3cc24b376d42d9fd9fa914335dddee46ed7b5a2e2dd1ee6df045ce437199d79
Status: Image is up to date for centos:6
root@ubuntu:~#

You need to fire up two containers from the downloaded docker image, one for the puppetmaster and the other for puppetclient. 

root@ubuntu:~# docker run -it --name puppetmaster --hostname puppetmaster.example.com centos:6 /bin/bash
root@puppetmaster /] 

root@ubuntu:~# docker run -it --name puppetclient --hostname puppetclient.example.com centos:6 /bin/bash
root@puppetmaster /] 

root@ubuntu:~# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
7d2c3af9ff52        76aa66802274        "/bin/bash"         24 hours ago        Up 3 hours                              puppetclient
113707c588ab        6f9a4933ce57        "/bin/bash"         2 days ago          Up 3 hours                              puppetmaster
root@ubuntu:~#


Once you have fired up your docker containers, make sure you have your both hosts puppetmaster and puppetclient are resolvable, either in DNS or in /etc/hosts.
you can install/configure puppet master and puppet client as in the article http://sunlnx.blogspot.in/2016/11/installconfigure-puppet-serverpuppet.html 

once they are completed, you can stop both the containers. 
root@ubuntu:~#docker stop puppetmaster
puppetmaster
root@ubuntu:~#docker stop puppetclient
puppetclient

root@ubuntu:~#docker ps
<display no running containers>

root@ubuntu:~#docker commit -m "puppetmaster" <CONTAINER ID> <dockerid>/puppetmaster:<tag>
root@ubuntu:~#docker commit -m "puppetclient" <CONTAINER ID> <dockerid>/puppetclient:<tag>

root@ubuntu:~#docker images
<you could now see your image installed with puppetmaster and puppetclient>

anyone who has no account for docker hub, you can create a new account. https://hub.docker.com/
already account exists, then you can push you docker image created puppetmaster/puppetclient to your account and can be download later in any of the platform installed with dockers to fire up two containers. 

root@ubuntu:~#docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username (dockerid):
.
.
<successful>

root@ubuntu:~#docker push <dockerid>/puppetmaster:latest
root@ubuntu:~#docker push <dockerid>/puppetclient:lastest

you have now successfully uploaded your images to your dockerid repository. 

you can download anytime if you require your docker images using below command and start to firing up your container.

root@ubuntu:~#docker run -it --name puppetmaster --hostname puppetmaster.example.com <dockerid>/puppetmaster /bin/bash
root@puppetmaster /] service puppetmaster start
root@puppetmaster /] echo "172.17.0.3 puppetclient.example.com" >>/etc/hosts

root@ubuntu:~#docker run -it --name puppetclient --hostname puppetclient.example.com <dockerid>/puppetclient /bin/bash
root@puppetclient /]echo "172.17.0.2 puppetmaster.example.com" >>/etc/hosts"

Try to check if they are able to ping resolve both the nodes and once done your puppetmaster/puppetclient with docker images are ready to use.

try executing "testing" part from particle http://sunlnx.blogspot.in/2016/11/installconfigure-puppet-serverpuppet.html to see it all works as expected.

Thanks for re-sharing