MOURIK / ansible

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

#Working with playbooks and enhancing the same.

These playbooks shall be run inside the docker container but you can also run these on host os.

##Building test environmnet to run this playbook.

  • Log on to any linux server with docker installed and running.Pull below mentioned docker image.
docker pull thinkingmonster/centos7-ansible
  • This docker image is already having git and ansible installed to it.Once image is pulled start container using the same.
docker run -t -p 8085:8080 -i thinkingmonster/centos7-ansible  /bin/bash
  • once you get inside the container create a directory where you can pull these playbooks from github.
mkdir /playbooks
  • Get into the /playbooks directory and initialize the same.
git init
  • Pull these playbooks from the github
git pull https://github.com/thinkingmonster/ansible.git
  • Get inside any playbook. In this example we i will explaining with jenkins playbook
cd jenkins-playbook

![Get_inside_container]

  • Run below command to run the playbook
ansible-playbook jenkins.yml

Run_Ansible

  • Once you execute the above command,notice that playbook will do following.

  • Install java.

  • Install jenkins.

  • Install require plugings in the jenkins.

  • stop and start the jenkins.

  • Once Playbook run is done you can access the jenkins by accessing following url in your browser.

http://<host machine>:8085
  • Once you exit the container jenkins will also stop.To attach back to the container and continue your testing run below command to get your container id.
docker ps -a
  • Note down your container id and start the same.
docker start <containerid>
  • Once container is started.Get attached to the container.
docker attach <containerid>

![Attach_container]

Now you are back in your container and can start your testing inside container.Where you exited the container,you will find it in the same stage.With all files intact.You can do a git fetch and can test your changes related to jenkins playbook again.

About


Languages

Language:Shell 100.0%