Showing posts with label Vagrant. Show all posts
Showing posts with label Vagrant. Show all posts

How To Install Apache Tomcat 7 on CentOS 6.5 by Yum


Video: clickMe

Install Tomcat
1. yum install tomcat or sudo yum install tomcat
2. /usr/share/tomcat
3. vi /usr/share/tomcat/conf/tomcat.conf
4. JAVA_OPTS > -Xmx500m -XX:MaxPermSize=256m -XX:+UseConcMarkSweepGC
Install Admin Packages
1. sudo yum install tomcat-webapps tomcat-admin-webapps
2. sudo vi /usr/share/tomcat/conf/tomcat-users.xml
3. Add
    <tomcat-users>
    <user username="tutorialbyexample" password="vinod"    roles="manager-gui,admin-gui"/>
     </tomcat-users>
or

Un comment the commented user and role

or

Replace the file content by below:

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<tomcat-users>
<!--
  NOTE:  By default, no user is included in the "manager-gui" role required
  to operate the "/manager/html" web application.  If you wish to use this app,
  you must define such a user - the username and password are arbitrary.
-->
<!--
  NOTE:  The sample user and role entries below are wrapped in a comment
  and thus are ignored when reading this file. Do not forget to remove
  <!.. ..> that surrounds them.
-->

  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <user username="tomcat" password="tomcat" roles="tomcat"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>
  <user username="role1" password="tomcat" roles="role1"/>


 <role rolename="admin"/>
 <role rolename="admin-gui"/>
 <role rolename="admin-script"/>
 <role rolename="manager"/>
 <role rolename="manager-gui"/>
<role rolename="manager-script"/>
 <role rolename="manager-jmx"/>
 <role rolename="manager-status"/>
<user name="admin" password="adminadmin" roles="admin,manager,admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status" />
</tomcat-users>


4. Start tomcat /etc/init.d/tomcat start
5. Access the Web Interface
    http://server_IP_address:8080 or  http://127.0.0.1:8080




How to install Apache 2 httpd in CentOS6.5 and sample example with html file


How to install Apache 2 httpd in CentOS6.5 and sample example with html file



Assumption, Installed:
CentOS
Putty
Internet connected or rpm download

How to install Apache 2 in CentOS
1. yum install httpd
2. start the apache > /etc/init.d/httpd start
3. abc.html for small demo
4. Run in any browser
5. Output


Please like and share it!

Vagrant tutorial and commands


Read more about Vagrant click me

Let's discussed more details of vagrant commands:

Install the Vagrant from https://hashicorp.com/ or other vendors.

Installation details: Click me

Open the any cmd windows for performing the Vagrant command, I'm using Git Base.

After installation, just type the
$ vagrant --version
Vagrant 1.3.5

Great, now we have Vagrant 1.3.5 version installed it. you can installed as per your requirement.



$ vagrant --help
Usage: vagrant [-v] [-h] command [<args>]

    -v, --version                    Print the version and exit.
    -h, --help                       Print this help.

Available subcommands:
     box
     destroy
     halt
     help
     init
     package
     plugin
     provision
     reload
     resume
     ssh
     ssh-config
     status
     suspend
     up

For help on any individual command run `vagrant COMMAND -h`

$ vagrant box --help
Usage: vagrant box <command> [<args>]

Available subcommands:
     add
     list
     remove
     repackage

$ vagrant destroy --help
Usage: vagrant destroy [vm-name]
    -f, --force                      Destroy without confirmation.
    -h, --help                       Print this help

$ vagrant init --help
Usage: vagrant init [box-name] [box-url]
    -h, --help                       Print this help

$ vagrant package --help
Usage: vagrant package [vm-name] [--base name] [--output name.box]
                       [--include one,two,three] [--vagrantfile file]

        --base NAME                  Name of a VM in virtualbox to package as a base box
        --output NAME                Name of the file to output
        --include x,y,z              Additional files to package with the box.
        --vagrantfile file           Vagrantfile to package with the box.
    -h, --help                       Print this help

$ vagrant plugin --help
Usage: vagrant plugin <command> [<args>]
Available subcommands:
     install
     license
     list
     uninstall
     update

$ vagrant provision --help
Usage: vagrant provision [vm-name] [--provision-with x,y,z]
        --provision-with x,y,z       Enable only certain provisioners, by type.
    -h, --help                       Print this help

$ vagrant reload --help
Usage: vagrant reload [vm-name]

        --[no-]provision             Enable or disable provisioning
        --provision-with x,y,z       Enable only certain provisioners, by type.
    -h, --help                       Print this help

$ vagrant resume --help
Usage: vagrant resume [vm-name]
    -h, --help                       Print this help

$ vagrant ssh --help
Usage: vagrant ssh [vm-name] [-c command] [-- extra ssh args]

    -c, --command COMMAND            Execute an SSH command directly.
    -p, --plain                      Plain mode, leaves authentication up to user.
    -h, --help                       Print this help

$ vagrant ssh-config --help
Usage: vagrant ssh-config [vm-name] [--host name]

        --host COMMAND               Name the host for the config..
    -h, --help                       Print this help

$ vagrant status --help
Usage: vagrant status [machine-name]
    -h, --help                       Print this help

$ vagrant suspend --help
Usage: vagrant suspend [vm-name]
    -h, --help                       Print this help

$ vagrant up --help
Usage: vagrant up [vm-name] [options] [-h]

        --[no-]provision             Enable or disable provisioning
        --provision-with x,y,z       Enable only certain provisioners, by type.
        --[no-]destroy-on-error      Destroy machine if any fatal error happens (default to true).
        --[no-]parallel              Enable or disable parallelism if provider supports it.
        --provider provider          Back the machine with a specific provider.
    -h, --help                       Print this help

While doing the vagrant, most of time I utilized it, vagrant init, vagrant up and vagrant ssh.

Reference: 
https://hashicorp.com/
https://en.wikipedia.org/wiki/Vagrant_(software)

Ansible, Centos65, Oracle VirtualBox, Vagrant and Provision

In Agile age, can't wait for environment’s (Development, Test, SIT and Pre-Prod and Prod) in place for start the development and configuration. What we need, just single windows system, where we can start provisioning with below tools and technologies. This will help more in Continues Development CD, Continues Integration CI and Continues Delivery CD.



Ansible centos virtualbox vagrant and provision
Ansible centos virtualbox vagrant and provision














Let’s discussed how it will possible:

Pre-quest:
Windows 7 OS 64
Install the Oracle VM VirtualBox  or any VM more
Install Vagrant more
Download Centos box more
Install ansible
Install Git Bash more

Open the Git Base
Windows Start > All Programs > Git > Git Base

Welcome to Git (version 1.9.5-preview20150319)

 Run 'git help git' to display the help index.
 Run 'git help <command>' to display help for specific commands.
 tutorialbyexample@WS7 ~

Crete the directory vagrant-ansible-centos under c:\
e.g. c:\vagrant-ansible-centos

Download it from https://github.com/tutorialbyexample/vagrant-ansible-centos.git


















c:\vagrant-ansible-centos
  - provision.sh
  - Vagrantfile 
  - centos65-x86_64-20140116.box
  - etc 
        -  ansible
                    - web.yml
                    - site.yml
                    - roles
                             - git
                                   - tasks
                                            - main.yml
                             - tar
                                   - tasks
                                            - main.yml
                             - zip
                                   - tasks
                                            - main.yml
  - inventory
        - dev 

Pest the all files under c:\vagrant-ansible-centos
1. Vagrantfile (no any extension)
#C:\vagrant-ansible-centos\Vagrantfile
# Vagrantfile Details
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "centos6"
  config.vm.provider "virtualbox" do |vb|
    vb.customize ["modifyvm", :id, "--memory", "5000", "--cpus", "2"]
  end
  config.vm.synced_folder ".", "/vagrant-ansible-centos"
  
end

2. provision.sh
#C:\vagrant-ansible-centos\provision.sh
cp -rf /vagrant-ansible-centos/inventory /tmp
chmod -x /tmp/inventory/*
sudo ansible-playbook -vvvv -i /tmp/inventory/$1 /vagrant-ansible-centos/etc/ansible/site.yml --extra-vars 'proxy_host="proxy_host" proxy_port="80" proxy_username="tutorialbyexample" proxy_password="password" proxy_required=true'
#sudo ansible-playbook -vvvv -i /tmp/inventory/$1 /vagrant-ansible-centos/etc/ansible/site.yml

3. dev (no extensions)
#C:\vagrant-ansible-centos\inventory
local ansible_ssh_port=2200 ansible_ssh_host=127.0.0.1 ansible_connection=local

[web-servers]
local

4. web.yml
#C:\vagrant-ansible-centos\etc\ansible\web.yml
---  
- hosts: web-servers
  remote_user: root
  sudo: yes
  roles:
    - zip
    - tar
    - git

5. site.yml 
#C:\vagrant-ansible-centos\etc\ansible\site.yml
---
- include: web.yml

6. main.yml (this is for git)
#C:\vagrant-ansible-centos\etc\ansible\roles\git\tasks\main.yml
---
- name: Install Git
  yum: name={{ item }} state=present
  with_items:
    - git
    - git-svn

7. main.yml (this is for tar)
#C:\vagrant-ansible-centos\etc\ansible\roles\tar\tasks\main.yml
---
- name: Install tar 
  yum: name=tar state=present  

8. main.yml (this is for zip)
#C:\vagrant-ansible-centos\etc\ansible\roles\zip\tasks\main.yml
---
- name: Install zip/unzip util
  yum: name={{ item }} state=present
  with_items:
    - "zip"
    - "unzip"

Need to switch our base tool to vagrant-ansible-centos directory
$ cd C:\vagrant-ansible-centos

$ pwd
/c/vagrant-ansible-centos

$ ls -tlr
centos65-x86_64-20140116.box
inventory
etc
provision.sh
Vagrantfile

Note: assuming centos65-x86_64-20140116.box has been downloaded under c:\vagrant-ansible-centos

$ vagrant box add centos6 centos65-x86_64-20140116.box
Downloading or copying the box...
Extracting box...ate: 2005k/s, Estimated time remaining: --:--:--)
Successfully added box 'centos6' with provider 'virtualbox'!

Note: You will experiences new folder created under /c/vagrant-ansible-centos with name .vagrant



$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'centos6'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Fixed port collision for 22 => 2222. Now on port 2200.
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2200 (adapter 1)
[default] Running 'pre-boot' VM customizations...
[default] Booting VM...
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] Mounting shared folders...
[default] -- /vagrant
[default] -- /vagrant-ansible-centos
[default] Configuring proxy environment variables...
[default] Configuring proxy for Yum...

Alternatively, ssh into localhost:2200 or 2222 what ever printed on above
using private key c/vagrant-ansible-centos\.vagrant\machines\default\virtualbox\private_key

$ vagrant ssh
[vagrant@vagrant-centos65 ~]$ pwd
/home/vagrant
[vagrant@vagrant-centos65 ~]$ ls -tlr
total 0
[vagrant@vagrant-centos65 ~]$ cd /vagrant-ansible-centos/
[vagrant@vagrant-centos65 vagrant-ansible-centos]$ ls -tlr
centos65-x86_64-20140116.box
inventory
etc
provision.sh
Vagrantfile

All this files will mount in /vagrant-ansible-centos/ as mentioned in Vagrent file.

Install the Ansible

[vagrant@vagrant-centos65 vagrant-ansible-centos]$ sudo yum install ansible
Loaded plugins: fastestmirror, versionlock
Determining fastest mirrors
epel/metalink                                                             
 * base: centos.openitc.uk
 * epel: epel.besthosting.ua
 * extras: centos.mirroring.pulsant.co.uk
 * updates: centos.serverspace.co.uk
...
..
Complete!

Verify the Ansible
[vagrant@vagrant-centos65 vagrant-ansible-centos]$ ansible --version
ansible 1.9.2
  configured module search path = None

Provision it, with provision.sh script along with Ansible

[vagrant@vagrant-centos65 vagrant-ansible-centos]$ ./provision.sh dev

PLAY [web-servers] ************************************************************

GATHERING FACTS ***************************************************************
ok: [local]

TASK: [zip | Install zip/unzip util] ******************************************
<127.0.0.1> REMOTE_MODULE yum name=zip,unzip state=present

TASK: [tar | Install tar] *****************************************************
<127.0.0.1> REMOTE_MODULE yum name=tar state=present
ok: [local] => {"changed": false, "msg": "", "rc": 0, "results": ["tar-1.23-11.el6.x86_64 providing tar is already installed"]}

TASK: [git | Install Git] *****************************************************
<127.0.0.1> REMOTE_MODULE yum name=git,git-svn state=present

PLAY RECAP ********************************************************************
local                      : ok=4    changed=2    unreachable=0    failed=0

[vagrant@vagrant-centos65 vagrant-ansible-centos]$

Verify the provision software, e.g. git, tar and zip

[vagrant@vagrant-centos65 vagrant-ansible-centos]$ git --version
git version 1.7.1
[vagrant@vagrant-centos65 vagrant-ansible-centos]$ tar --version
tar (GNU tar) 1.23
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
[vagrant@vagrant-centos65 vagrant-ansible-centos]$ zip --version
Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
This is Zip 3.0 (July 5th 2008), by Info-ZIP.
Currently maintained by E. Gordon.  Please send bug reports to
the authors using the web page at www.info-zip.org; see README for details.

Latest sources and executables are at ftp://ftp.info-zip.org/pub/infozip,
as of above date; see http://www.info-zip.org/ for other sites.

Compiled with gcc 4.4.4 20100525 (Red Hat 4.4.4-5) for Unix (Linux ELF) on Nov 11 2010.

Zip special compilation options:
        USE_EF_UT_TIME       (store Universal Time)
        SYMLINK_SUPPORT      (symbolic links supported)
        LARGE_FILE_SUPPORT   (can read and write large files on file system)
        ZIP64_SUPPORT        (use Zip64 to store large files in archives)
        UNICODE_SUPPORT      (store and read UTF-8 Unicode paths)
        STORE_UNIX_UIDs_GIDs (store UID/GID sizes/values using new extra field)
        UIDGID_NOT_16BIT     (old Unix 16-bit UID/GID extra field not used)
        [encryption, version 2.91 of 05 Jan 2007] (modified for Zip 3)

Encryption notice:
        The encryption code of this program is not copyrighted and is
        put in the public domain.  It was originally written in Europe
        and, to the best of our knowledge, can be freely distributed
        in both source and object forms from any country, including
        the USA under License Exception TSU of the U.S. Export
        Administration Regulations (section 740.13(e)) of 6 June 2002.

Zip environment options:
             ZIP:  [none]
          ZIPOPT:  [none]
[vagrant@vagrant-centos65 vagrant-ansible-centos]$

Is not it simple? For real implementation only we have to change the actual IP address of web server.

C:\vagrant-ansible-centos\inventory\dev

local ansible_ssh_port=2200 ansible_ssh_host=127.0.0.1 ansible_connection=local

[web-servers]
local

Note: instead of local need to change the actual IP address and it will work for you.