Lab 7

Automated hotel service deployment

Lab Goal

To leverage Ansible automation to deploy PHP web service in a container.

ARCHITECTURE

Deploy PHP web service in a container

WHERE ARE PLAYBOOKS?

  • The travel backend services are deployed using Ansible playbooks
  • They are found here:

    • $ cd support/playbooks/deploy-ocp-services


  • Let's deploy the hotel service:

    • $ ./ansible-playbook-phpservice.sh

PLAYBOOK START

  • The hotel service playbook stars with messages, setup and logging in to the OpenShift Container Platform:

    • $ ./ansible-playbook-phpservice.sh

PLAYBOOK DEPLOYMENT

  • The hotel service playbook finally deploys a new container, patches config to expose ports, exposes a service route and reports playbook status as it finishes:

IF BUILD FAILS

  • The playbook can fail if adding PHP stream failed
  • To determine cause, see the error message:

HOW TO FIX

For some reason the PHP stream was not added, do this by hand:

  • $ oc login -u system:admin

  • $ oc create -n openshift -f 'https://raw.githubusercontent.com/openshift/openshift-ansible/master/roles/openshift_examples/files/examples/latest/image-streams/image-streams-rhel7.json'



Then hotel service playbook again (or if build in OCP console failed, rebuild it):

  • $ ./ansible-playbook-phpservice.sh

HOTEL SERVICE

  • When a build finishes you see a new deployment container appears in Monitoring view under Deployments:

END LAB 7

QUESTIONS?

Eric D. Schabell
Portfolio Architect Director
@ericschabell
http://schabell.org

UP NEXT...

Lab 8 - Integration service playbook