SlideShare a Scribd company logo
1 of 20
Powerful and Simple IT automation engine
 Ansible is radically simple IT
Configuration management and
Orchestration Tool that automates
Infrastructure, Provisioning,
configuration management,
application deployment, intra-service
orchestration, and many other IT
needs.
1. Agent-less communication
 SSH-based, so it doesn’t require installing any agents on
remote nodes.
2. Procedural and Ordered
 Allow you to perform Orchestration and perform tasks in an
order that you want to .
3. Easy learning curve
 It uses YAML because it is easier for humans to read and write
than other common data formats like XML or JSON.
4. Playbook structure is simple and clearly
structured.
5. Has a variable registration feature that enables
tasks to register variables for later tasks.
Dependencies
. Python
. PyYaml
. Jinja2
Ansible control server
P
Y
T
H
O
N
Ansible consists of…
1. Inventory Files.
2. Tasks.
3. Plays.
4. Playbooks.
5. Tags
6. Roles
 Inventory File
 Ansible works against multiple systems in your
infrastructure at the same time. It does this by selecting
portions of systems listed in Ansible’s inventory file, which
defaults to being saved in the location /etc/ansible/hosts.
 Inventory allows you to Group hosts together and then you can use
those groups as part of the targets.
• The format for /etc/ansible/hosts is an INI-like format and looks like
this:
[loadbalancer]
ec2-54-183-79-180.us-west-1.compute.amazonaws.com
[database]
ec2-54-183-79-180.us-west-1.compute.amazonaws.com
[webserver]
0.0.0.0
[control]
control ansible_connection=local
• Adding a lot of hosts?... If you have a number of hosts with
similar patterns you can do this rather than listing each
hostname:
[webservers]
www[01:50].example.com
• You can also select the connection type and user on a per
host basis:
[targets]
localhost ansible_connection=local
other1.example.com ansible_connection=ssh ansible_user=fsgapp
other2.example.com ansible_connection=ssh ansible_user=fsgapp
• Sample Ansible command to list hosts in an inventory.
[root@D4687277 ansible]# ansible –i dev –list-hosts all
[root@D4687277 ansible]# ansible –i dev –list-hosts webserver:control
[root@D4687277 ansible]# ansible –i dev –list-hosts webserver[0]
 Tasks
• In ansible a task is basic building block of all execution and
configuration.
• A task is made of building blocks consists of module and
arguments to that module.
• A simple task look like :
[root@D4687277 ansible]# ansible -i stg -m ping webserver
mdc2vra025 | SUCCESS => {
"changed": false,
"ping": "pong"
}
mdc2vra021 | SUCCESS => {
"changed": false,
"ping": "pong"
}
 Plays
• A play is executed as part of playbook and play is simply a
set tasks to execute against the target host/role.
 Playbooks
• A playbook is file written in YAML syntax made up of Plays.
• A sample playbook look like:
---
- hosts: control
become: true
tasks:
- name: install apache
yum: name={{item}} state=present update_cache=yes
with_items:
- httpd
- name: Start Service
service: name=httpd state=started enabled=yes
• A playbook with multiple plays look like
---
- hosts: webservers
remote_user: root
tasks:
- name: ensure apache is at the latest version
yum: name=httpd state=latest
- name: write the apache config file
template: src=/srv/httpd.j2 dest=/etc/httpd.conf
- hosts: databases
remote_user: root
tasks:
- name: ensure postgresql is at the latest version
yum: name=postgresql state=latest
- name: ensure that postgresql is started
service: name=postgresql state=running
Play 1
Play 2
 Install JDK1.8, Jboss-eap-6.4 version, Deploy
Jboss configuration and Deploy JBOSS
application Ansible Playbook.
My playbook contains set of tasks which use
modules provided by ansible.
Note: This playbook is for demo purpose only .
So need much more tuning.
1. Inventory File: To assign hosts and group
2. Playbook with plays.
3. Json file for passing variables.
4. Set of hosts with ssh keys.
Note: Assume ssh keys are in place on the
hosts.
My playbook give complete details on how to Install Jboss, Deploy Jboss Application and start/stop
jboss as service using tags
File look like this:
---
- name: Install JBOSS IF DOESN"T EXIST
hosts: webserver
become_user: {{user}}
tasks:
- name: CHECK IF JDK 1.8 exists
stat: path=/opt/jdk1.8.0_60
register: check_jdk_path
- name: It exists
debug: msg='Yay, the path exists!.So not Installing JDK1.8 again'
when: check_jdk_path.stat.exists
- name: It doesn't exist
when: check_jdk_path.stat.exists == false
command: "{{item}}"
args:
chdir: /opt
with_items:
- curl "http://server-ip/installables/jdk-8u60-linux-x64.tar.gz" -o "jdk-8u60-linux-x64.tar.gz"
- tar -xvf jdk-8u60-linux-x64.tar.gz
- chown -R {{user}}:{{user}} jdk1.8.0_60
- chmod -R 755 jdk1.8.0_60
- rm -rf jdk-8u60-linux-x64.tar.gz
- name: CHECK IF JBOSS-6.4 EXISTS
stat: path=/opt/jboss-eap-6.4
register: check_jboss_path
- name: CHECK IF STANALONE-your-app-name Profile exists
stat: path=/opt/jboss-eap-6.4/standalone-app-name
register: check_jboss_profile
- name: It exists
debug: msg='Yay, the path exists!.So not Installing Jboss again'
when: check_jboss_path.stat.exists
- name: It doesn't exist
when: check_jboss_path.stat.exists == false
command: "{{item}}"
args:
chdir: /opt
with_items:
- curl "http://mdc2vr6159/installables/jboss-eap-6.4.0.zip" -o "jboss-eap-6.4.0.zip"
- unzip jboss-eap-6.4.0.zip
- chown -R {{user}}:{{user}} jboss-eap-6.4
- rm -rf jboss-eap-6.4.0.zip
- cp -r jboss-eap-6.4/standalone jboss-eap-6.4/standalone-app-name
- name: deploy your-app-name jboss module configuration from svn
subversion: {{svn_user}}=user_name password={{password}}
repo=http://vcsorange/pwm/your-app-name-config/relbranches/{{version}}/{{ENV}}/modules
dest=/opt/jboss-eap-6.4/modules force=yes export=true
- name: deploy your-app-name jboss bin configuration from svn
subversion: {{svn_user}}=user_name password={{password}}
repo=http://vcsorange/pwm/your-app-name-config/relbranches/{{version}}/{{ENV}}/bin
dest=/opt/jboss-eap-6.4/bin force=yes export=true
- name: create jboss conf directory for service
file: path=/etc/jboss-as state=directory owner=root group=root mode=0775
- name: create jboss pid directory
file: path=/var/run/jboss-as state=directory owner=root group=root
mode=0775
- name: copy stom-jboss standalpone service file
when: check_jboss_path.stat.exists
command: "{{item}}"
args:
chdir: /opt/jboss-eap-6.4/
with_items:
- cp /opt/jboss-eap-6.4/bin/init.d/your-app-name-jboss /etc/init.d/
- cp /opt/jboss-eap-6.4/bin/init.d/jboss-as.conf /etc/jboss-as/
- chown root:root /etc/init.d/your-app-name-jboss
- chmod 755 /etc/init.d/your-app-name-jboss
- chmod 775 -R /var/run/jboss-as
- chmod 755 /etc/jboss-as/jboss-as.conf
- name: deploy your-app-name jboss standalone configuration from svn
subversion: {{svn_user}}=user_name password={{password}}
repo=http://vcsorange/pwm/your-app-name-
config/relbranches/{{version}}/STG/standalone-your-app-name dest=/opt/jboss-
eap-6.4/standalone-your-app-name force=yes export=true
- name: deploy UI war
maven_artifact: group_id=com.company.group artifact_id=your-app-name-ui
extension=war version={{version}}-RC1-SNAPSHOT
repository_url=http://{{nexus_url}}:{{port}}/nexus/content/repositories/stellaCIsnaps
hots dest=/opt/jboss-eap-6.4/standalone-your-app-name/deployments/your-
app-name-ui.war
- name: deploy services war
maven_artifact: group_id=com.company.your-app-name artifact_id=your-app-
name-services-war extension=war version={{version}}-RC1-SNAPSHOT
repository_url=http://{{nexus_url}}:{{port}}/nexus/content/repositories/stellaCIsnaps
hots dest=/opt/jboss-eap-6.4/standalone-your-app-name/deployments/your-
app-name-services.war
- name: change folder permissions
file: path=/opt/jboss-eap-6.4 owner={{user}} group={{user}} mode=755
recurse=yes
- name: change folder permissions
file: path=/www/a/logs/your-app-name owner={{user}} group={{user}}
mode=755 recurse=yes
- name: Start or Stop Service
service: name=storm-jboss state=restarted
tags:
- Start
- name: Start or Stop Service
service: name=storm-jboss state=stopped
tags:
- Stop
 ansible-playbook -i stg
playbooks/configure_jboss_stage.yml --
extra-vars "version=6.1.0 role=webserver
ENV=STG“ –skip-tags=“stop”
 http://docs.ansible.com/ansible/modules_by
_category.html
 http://docs.ansible.com/ansible/playbooks.h
tml

More Related Content

What's hot

What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
Simplilearn
 

What's hot (20)

Ansible
AnsibleAnsible
Ansible
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
 
Ansible intro
Ansible introAnsible intro
Ansible intro
 
Ansible
AnsibleAnsible
Ansible
 
Automating with Ansible
Automating with AnsibleAutomating with Ansible
Automating with Ansible
 
Ansible
AnsibleAnsible
Ansible
 
DevOps Meetup ansible
DevOps Meetup   ansibleDevOps Meetup   ansible
DevOps Meetup ansible
 
Best practices for ansible
Best practices for ansibleBest practices for ansible
Best practices for ansible
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
Ansible
AnsibleAnsible
Ansible
 
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
 
[1A7]Ansible의이해와활용
[1A7]Ansible의이해와활용[1A7]Ansible의이해와활용
[1A7]Ansible의이해와활용
 
Ansible - Introduction
Ansible - IntroductionAnsible - Introduction
Ansible - Introduction
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done right
 
DevOps with Ansible
DevOps with AnsibleDevOps with Ansible
DevOps with Ansible
 
Ansible 101
Ansible 101Ansible 101
Ansible 101
 
K8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals Training
 
NGINX: Basics and Best Practices
NGINX: Basics and Best PracticesNGINX: Basics and Best Practices
NGINX: Basics and Best Practices
 

Similar to Ansible presentation

Summit demystifying systemd1
Summit demystifying systemd1Summit demystifying systemd1
Summit demystifying systemd1
Susant Sahani
 
Apache ant
Apache antApache ant
Apache ant
koniik
 

Similar to Ansible presentation (20)

A tour of Ansible
A tour of AnsibleA tour of Ansible
A tour of Ansible
 
Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015
 
Asian Spirit 3 Day Dba On Ubl
Asian Spirit 3 Day Dba On UblAsian Spirit 3 Day Dba On Ubl
Asian Spirit 3 Day Dba On Ubl
 
#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible
 
MySQL Audit using Percona audit plugin and ELK
MySQL Audit using Percona audit plugin and ELKMySQL Audit using Percona audit plugin and ELK
MySQL Audit using Percona audit plugin and ELK
 
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
 
Managing Infrastructure as Code
Managing Infrastructure as CodeManaging Infrastructure as Code
Managing Infrastructure as Code
 
Ansible with oci
Ansible with ociAnsible with oci
Ansible with oci
 
Introduction to Ansible - (dev ops for people who hate devops)
Introduction to Ansible - (dev ops for people who hate devops)Introduction to Ansible - (dev ops for people who hate devops)
Introduction to Ansible - (dev ops for people who hate devops)
 
Ansible
AnsibleAnsible
Ansible
 
AAI-1304 Technical Deep-Dive into IBM WebSphere Liberty
AAI-1304 Technical Deep-Dive into IBM WebSphere LibertyAAI-1304 Technical Deep-Dive into IBM WebSphere Liberty
AAI-1304 Technical Deep-Dive into IBM WebSphere Liberty
 
Ansible
AnsibleAnsible
Ansible
 
Null Bachaav - May 07 Attack Monitoring workshop.
Null Bachaav - May 07 Attack Monitoring workshop.Null Bachaav - May 07 Attack Monitoring workshop.
Null Bachaav - May 07 Attack Monitoring workshop.
 
DevOps for database
DevOps for databaseDevOps for database
DevOps for database
 
Summit demystifying systemd1
Summit demystifying systemd1Summit demystifying systemd1
Summit demystifying systemd1
 
Riga Dev Day - Automated Android Continuous Integration
Riga Dev Day - Automated Android Continuous IntegrationRiga Dev Day - Automated Android Continuous Integration
Riga Dev Day - Automated Android Continuous Integration
 
Apache ant
Apache antApache ant
Apache ant
 
WebCamp 2016: DevOps. Ярослав Погребняк: Gobetween - новый лоад балансер для ...
WebCamp 2016: DevOps. Ярослав Погребняк: Gobetween - новый лоад балансер для ...WebCamp 2016: DevOps. Ярослав Погребняк: Gobetween - новый лоад балансер для ...
WebCamp 2016: DevOps. Ярослав Погребняк: Gobetween - новый лоад балансер для ...
 
Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeAnsible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less Coffee
 
Automating with ansible (Part A)
Automating with ansible (Part A)Automating with ansible (Part A)
Automating with ansible (Part A)
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

Ansible presentation

  • 1. Powerful and Simple IT automation engine
  • 2.  Ansible is radically simple IT Configuration management and Orchestration Tool that automates Infrastructure, Provisioning, configuration management, application deployment, intra-service orchestration, and many other IT needs.
  • 3. 1. Agent-less communication  SSH-based, so it doesn’t require installing any agents on remote nodes. 2. Procedural and Ordered  Allow you to perform Orchestration and perform tasks in an order that you want to . 3. Easy learning curve  It uses YAML because it is easier for humans to read and write than other common data formats like XML or JSON. 4. Playbook structure is simple and clearly structured. 5. Has a variable registration feature that enables tasks to register variables for later tasks.
  • 4. Dependencies . Python . PyYaml . Jinja2 Ansible control server P Y T H O N
  • 5. Ansible consists of… 1. Inventory Files. 2. Tasks. 3. Plays. 4. Playbooks. 5. Tags 6. Roles  Inventory File  Ansible works against multiple systems in your infrastructure at the same time. It does this by selecting portions of systems listed in Ansible’s inventory file, which defaults to being saved in the location /etc/ansible/hosts.
  • 6.  Inventory allows you to Group hosts together and then you can use those groups as part of the targets. • The format for /etc/ansible/hosts is an INI-like format and looks like this: [loadbalancer] ec2-54-183-79-180.us-west-1.compute.amazonaws.com [database] ec2-54-183-79-180.us-west-1.compute.amazonaws.com [webserver] 0.0.0.0 [control] control ansible_connection=local
  • 7. • Adding a lot of hosts?... If you have a number of hosts with similar patterns you can do this rather than listing each hostname: [webservers] www[01:50].example.com • You can also select the connection type and user on a per host basis: [targets] localhost ansible_connection=local other1.example.com ansible_connection=ssh ansible_user=fsgapp other2.example.com ansible_connection=ssh ansible_user=fsgapp • Sample Ansible command to list hosts in an inventory. [root@D4687277 ansible]# ansible –i dev –list-hosts all [root@D4687277 ansible]# ansible –i dev –list-hosts webserver:control [root@D4687277 ansible]# ansible –i dev –list-hosts webserver[0]
  • 8.  Tasks • In ansible a task is basic building block of all execution and configuration. • A task is made of building blocks consists of module and arguments to that module. • A simple task look like : [root@D4687277 ansible]# ansible -i stg -m ping webserver mdc2vra025 | SUCCESS => { "changed": false, "ping": "pong" } mdc2vra021 | SUCCESS => { "changed": false, "ping": "pong" }
  • 9.  Plays • A play is executed as part of playbook and play is simply a set tasks to execute against the target host/role.  Playbooks • A playbook is file written in YAML syntax made up of Plays. • A sample playbook look like: --- - hosts: control become: true tasks: - name: install apache yum: name={{item}} state=present update_cache=yes with_items: - httpd - name: Start Service service: name=httpd state=started enabled=yes
  • 10. • A playbook with multiple plays look like --- - hosts: webservers remote_user: root tasks: - name: ensure apache is at the latest version yum: name=httpd state=latest - name: write the apache config file template: src=/srv/httpd.j2 dest=/etc/httpd.conf - hosts: databases remote_user: root tasks: - name: ensure postgresql is at the latest version yum: name=postgresql state=latest - name: ensure that postgresql is started service: name=postgresql state=running Play 1 Play 2
  • 11.  Install JDK1.8, Jboss-eap-6.4 version, Deploy Jboss configuration and Deploy JBOSS application Ansible Playbook. My playbook contains set of tasks which use modules provided by ansible. Note: This playbook is for demo purpose only . So need much more tuning.
  • 12. 1. Inventory File: To assign hosts and group 2. Playbook with plays. 3. Json file for passing variables. 4. Set of hosts with ssh keys. Note: Assume ssh keys are in place on the hosts.
  • 13. My playbook give complete details on how to Install Jboss, Deploy Jboss Application and start/stop jboss as service using tags File look like this: --- - name: Install JBOSS IF DOESN"T EXIST hosts: webserver become_user: {{user}} tasks: - name: CHECK IF JDK 1.8 exists stat: path=/opt/jdk1.8.0_60 register: check_jdk_path - name: It exists debug: msg='Yay, the path exists!.So not Installing JDK1.8 again' when: check_jdk_path.stat.exists
  • 14. - name: It doesn't exist when: check_jdk_path.stat.exists == false command: "{{item}}" args: chdir: /opt with_items: - curl "http://server-ip/installables/jdk-8u60-linux-x64.tar.gz" -o "jdk-8u60-linux-x64.tar.gz" - tar -xvf jdk-8u60-linux-x64.tar.gz - chown -R {{user}}:{{user}} jdk1.8.0_60 - chmod -R 755 jdk1.8.0_60 - rm -rf jdk-8u60-linux-x64.tar.gz - name: CHECK IF JBOSS-6.4 EXISTS stat: path=/opt/jboss-eap-6.4 register: check_jboss_path - name: CHECK IF STANALONE-your-app-name Profile exists stat: path=/opt/jboss-eap-6.4/standalone-app-name register: check_jboss_profile - name: It exists debug: msg='Yay, the path exists!.So not Installing Jboss again' when: check_jboss_path.stat.exists
  • 15. - name: It doesn't exist when: check_jboss_path.stat.exists == false command: "{{item}}" args: chdir: /opt with_items: - curl "http://mdc2vr6159/installables/jboss-eap-6.4.0.zip" -o "jboss-eap-6.4.0.zip" - unzip jboss-eap-6.4.0.zip - chown -R {{user}}:{{user}} jboss-eap-6.4 - rm -rf jboss-eap-6.4.0.zip - cp -r jboss-eap-6.4/standalone jboss-eap-6.4/standalone-app-name - name: deploy your-app-name jboss module configuration from svn subversion: {{svn_user}}=user_name password={{password}} repo=http://vcsorange/pwm/your-app-name-config/relbranches/{{version}}/{{ENV}}/modules dest=/opt/jboss-eap-6.4/modules force=yes export=true - name: deploy your-app-name jboss bin configuration from svn subversion: {{svn_user}}=user_name password={{password}} repo=http://vcsorange/pwm/your-app-name-config/relbranches/{{version}}/{{ENV}}/bin dest=/opt/jboss-eap-6.4/bin force=yes export=true
  • 16. - name: create jboss conf directory for service file: path=/etc/jboss-as state=directory owner=root group=root mode=0775 - name: create jboss pid directory file: path=/var/run/jboss-as state=directory owner=root group=root mode=0775 - name: copy stom-jboss standalpone service file when: check_jboss_path.stat.exists command: "{{item}}" args: chdir: /opt/jboss-eap-6.4/ with_items: - cp /opt/jboss-eap-6.4/bin/init.d/your-app-name-jboss /etc/init.d/ - cp /opt/jboss-eap-6.4/bin/init.d/jboss-as.conf /etc/jboss-as/ - chown root:root /etc/init.d/your-app-name-jboss - chmod 755 /etc/init.d/your-app-name-jboss - chmod 775 -R /var/run/jboss-as - chmod 755 /etc/jboss-as/jboss-as.conf
  • 17. - name: deploy your-app-name jboss standalone configuration from svn subversion: {{svn_user}}=user_name password={{password}} repo=http://vcsorange/pwm/your-app-name- config/relbranches/{{version}}/STG/standalone-your-app-name dest=/opt/jboss- eap-6.4/standalone-your-app-name force=yes export=true - name: deploy UI war maven_artifact: group_id=com.company.group artifact_id=your-app-name-ui extension=war version={{version}}-RC1-SNAPSHOT repository_url=http://{{nexus_url}}:{{port}}/nexus/content/repositories/stellaCIsnaps hots dest=/opt/jboss-eap-6.4/standalone-your-app-name/deployments/your- app-name-ui.war - name: deploy services war maven_artifact: group_id=com.company.your-app-name artifact_id=your-app- name-services-war extension=war version={{version}}-RC1-SNAPSHOT repository_url=http://{{nexus_url}}:{{port}}/nexus/content/repositories/stellaCIsnaps hots dest=/opt/jboss-eap-6.4/standalone-your-app-name/deployments/your- app-name-services.war
  • 18. - name: change folder permissions file: path=/opt/jboss-eap-6.4 owner={{user}} group={{user}} mode=755 recurse=yes - name: change folder permissions file: path=/www/a/logs/your-app-name owner={{user}} group={{user}} mode=755 recurse=yes - name: Start or Stop Service service: name=storm-jboss state=restarted tags: - Start - name: Start or Stop Service service: name=storm-jboss state=stopped tags: - Stop
  • 19.  ansible-playbook -i stg playbooks/configure_jboss_stage.yml -- extra-vars "version=6.1.0 role=webserver ENV=STG“ –skip-tags=“stop”