Giter VIP home page Giter VIP logo

ansible_advance_homework's Introduction

Ansible Tower Config

  • From the cloned repo run site-config-tower.yml playbook to create job templates and workflow template.

[bastion]$ sudo -i
[bastion]# cd ansible_advance_homework
[bastion]# TOWER_GUID=<Ansible Tower Homework GUID from mail>
[bastion]# OSP_GUID=<Openstack for Ansible GUID from mail>
[bastion]# OPENTLC_LOGIN=<username-company.com>
[bastion]# OPENTLC_PASSWORD=<your openlc account password>
[bastion]# GITHUB_REPO=https://github.com/<githubhandler>/ansible_advance_homework
[bastion]# JQ_REPO_BASE=http://www.opentlc.com/download/ansible_bootcamp
[bastion]# REGION=<enter region name example us-east-1>
[bastion]# RH_MAIL_ID=<your mail id for dynamic inventory tag>
[bastion]# ansible-playbook site-config-tower.yml -e tower_GUID=${TOWER_GUID} -e osp_GUID=${OSP_GUID} -e opentlc_login=${OPENTLC_LOGIN} -e path_to_opentlc_key=/root/.ssh/mykey.pem -e param_repo_base=${JQ_REPO_BASE} -e opentlc_password=${OPENTLC_PASSWORD} -e REGION_NAME=${REGION} -e EMAIL=${RH_MAIL_ID} -e github_repo=${GITHUB_REPO}
Table 1. List of Playbooks
Files or dir Purpose

app-tier

Install application server role

db-tier

Install postgressql server for database role

lb-tier

Install HA proxy role

base-config

Setup yum repo and base packages role

setup-workstation

Setup workstation, create network, ssh keypair, security group etc. role

osp-servers

Provision OSP Instances role

osp-instance-delete

Delete OSP Instances role

osp-facts

Genrate in-memory inventory for OSP instances role

roles/config-tower/vars/main.yml

Very important file to review. All the variable values are set there. Please do not make any changes in the file

config-tower

Role to configure ansible tower job templates and workflow

aws_creds.yml

Fetch GUIDkey.pem from bastion of Three tier application env and create machine credential to connect to AWS instances

aws_provision.yml

Use order_svc.sh script to provision env

aws_status_check.yml

Check aws instances are up or not

site-3tier-app.yml

Playbook to deploy three tier app

site-install-isolated-node.yml

Playbook to install isolated node

site-config-tower.yml

Playbook to call role config-tower

site-osp-delete.yml

Playbook to call role

site-osp-instances.yml

Playbook to call role

site-setup-workstation.yml

Playbook to call role

site-smoke-osp.yml

Playbook to test three tier app on OSP

site-smoketest-aws.yml

Playbook to test three tier app on AWS

grading-script.yml

Self grading script

roles/config-tower/tasks/ec2_dynamic.yml

For creating Dynamic inventory in Ansible tower. Use AWS Access Key for credential

roles/config-tower/tasks/job_template.yml

For creating job templates

roles/config-tower/tasks/pre-config-tower.yml

Any pre config tasks needed

roles/config-tower/tasks/workflow_template.yml

genrate workflow from workflow.yml file

roles/config-tower/tasks/post-config-tower.yml

any post config jobs

OpenTLC Lab Environments

Following Lab environments must be provisioned on OpenTLC available under OPENTLC Automation group:

  • Ansible Advanced - OpenStack

  • Ansible Advanced - Homework

SSH key distribution

Following manual tasks should be performed after both Lab environments are provisioned by OpenTLC:

  • Copy OpenTLC private key to OSP Workstation /root/.ssh

  • Copy OpenTLC public key content to OSP Workstation /root/.ssh/authorized_keys

  • Copy OpenTLC private key to Homework Bastion /root/.ssh

  • Copy your GitHub private key to Homework Bastion /root/.ssh

Verify connectivity between Homework Bastion and OSP Workstation

ssh -i ~/.ssh/rd_opentlc_local_id_rsa workstation-aa3a.rhpds.opentlc.com

Prepare the Homework Project

Follow these manual steps to prepare Homework project before execution:

  • Create a workspace directory (For Example: /root/homework)

  • Clone your Homework GitHub repo to Homework Bastion in workspace directory. (Note: This is the repo forked and developed by you)

  • Update /root/homework/ansible_advance_homework/ssh.cfg with correct OSP Workstation Hostname

  • Add environment variables to /root/.bashrc

Homework env variables

export OSP_GUID=aa3a export TOWER_GUID=b996 export OPENTLC_LOGIN=rdurvas1-in.ibm.com export GITHUB_REPO=https://github.com/rajdurvasula/ansible_advance_homework export JQ_REPO_BASE=http://www.opentlc.com/download/ansible_bootcamp export REGION=us-east-1 export RH_MAIL_ID=[email protected]

  • source /root/.bashrc for future usage

Setup OSP resources and Tower Isolated Node on OSP Workstation

Follow these manual steps to configure OSP resources

  • Execute the provided script setup_workstation.sh

    • The script executes Ansible Playbook site-setup-workstation.yml

  • Verify connectivity from Homework Bastion to OSP Workstation with "cloud-user" user and openstack.pem key

ssh -i ~/.ssh/openstack.pem [email protected]

Configure Ansible Tower

Follow these steps to configure Ansible Tower

  • Execute the provided script config_tower.sh

    • The script executes Ansible Playbook site-config-tower.yml

    • NOTE: This script depends on Environment Variables that were set in Homework Bastion "/root/.bashrc"

    • At the prompt, provide your Red Hat OpenTLC password

Provision QA Environment

Follow these steps to provision QA environment on OSP instance

  • Execute Ansible Playbook site-osp-instances.yml

ansible-playbook site-osp-instances.yml

Deploy 3-Tier application on OSP server instances

  • Execute Ansible Playbook site-3tier-app.yml

ansible-playbook site-3tier-app.yml

Verify 3-Tier application on QA environment

  • Get the "frontend" server IP address

openstack server list
# Result:
+--------------------------------------+----------+--------+--------------------------------------+------------+
| ID                                   | Name     | Status | Networks                             | Image Name |
+--------------------------------------+----------+--------+--------------------------------------+------------+
| 7cd0a20f-f0e2-4c44-81b2-0b05075b2c5f | app1     | ACTIVE | int_network=20.20.20.7, 10.10.10.8   | rhel-guest |
| bb25e846-5a1a-41ff-887e-b5c774a9ba9e | app2     | ACTIVE | int_network=20.20.20.8, 10.10.10.6   | rhel-guest |
| 2d194710-d0cd-4ba4-b0c0-d9337423c6f2 | db       | ACTIVE | int_network=20.20.20.11, 10.10.10.11 | rhel-guest |
| 06146c50-f0ca-440c-a9c0-2b0b1ce94592 | frontend | ACTIVE | int_network=20.20.20.6, 10.10.10.3   | rhel-guest |
+--------------------------------------+----------+--------+--------------------------------------+------------+
  • Issue curl command on "frontend" ip address from RHOSP workstation node.

curl http://10.10.10.3
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Ansible Deployed Tomcat</title>
  <meta name="description" content="Ansible Created Content">
  <meta name="[email protected]" content="Ansible">
</head>
<body>
    <h1>Ansible has done its job - Welcome to Tomcat on 10.10.10.8</h1>
</body>
</html>
  • Again, issue curl command on "frontend" ip address from RHOSP workstation node.

curl http://10.10.10.3
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Ansible Deployed Tomcat</title>
  <meta name="description" content="Ansible Created Content">
  <meta name="[email protected]" content="Ansible">
</head>
<body>
    <h1>Ansible has done its job - Welcome to Tomcat on 10.10.10.6</h1>
</body>
</html>

Verify 3-Tier application on QA environment using Ansible Playbook

  • Execute Ansible Playbook site-smoke-osp.yml

ansible-playbook site-smoke-osp.yml

Test Ansibe Playbook to delete 3-Tier application server instances in QA environment

  • Execute ansible playbook site-osp-delete.yml

ansible-playbook site-osp-delete.yml

Ansible Tower Workflow Execution

  • Login to tower1 Web UI

  • Launch cicd_workflow Workflow Template

Final Result

  • Expect to see all the Workflow Job steps of cicd_workflow are executed successfully.

  • The following Ansible Jobs verify successful deployment of Three-tier Application on RH OSP and AWS EC2 instances respectively:

    • Smoke test QA Env

    • Smoke test Prod env

ansible_advance_homework's People

Contributors

prakhar1985 avatar rajdurvasula avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.