SlideShare a Scribd company logo
Fabric workshop
(1)
Soshi Nemoto
Mulodo Vietnam Co., Ltd.
Our Purpose
Make ourselves ‘Business partner’ from
‘factory’.
Points
Engineering knowledge <- * TODAY *
Logical Thinking
Co-operation work
Resources
Meetup: http://www.meetup.com/Open-Study-Group-Saigon
Slideshare: http://www.slideshare.net/nemo-mulodo/
— Study Group —
Previous study
DevOps: What's DevOps
http://www.slideshare.net/nemo-mulodo/devops1-whats-devops-mosg	
DevOps: Vagrant
http://www.slideshare.net/nemo-mulodo/devops2-vagrant-mosg	
DevOps: Ansible
http://www.slideshare.net/nemo-mulodo/devops3-ansible-mosg	
DevOps: Ansible(2)
http://www.slideshare.net/nemo-mulodo/devops4-ansible2-mosg	
Preparation for workshop (tools)
http://www.slideshare.net/nemo-mulodo/instruction-dev-environment
Feedback of previous study
Goal
Server
Apps
Apache
PHP
MySQL
Product
Apps
Source
Data
Cron
Virtual server
Vagrant
+ ansible
+ fabric
automation
Goal
Server
Apps
Apache
PHP
MySQL
Product
Apps
Source
Data
Cron
Virtual server
Vagrant
+ ansible
+ fabric
automation
Goal
Server
Apps
Apache
PHP
MySQL
Product
Apps
Source
Data
Cron
Virtual server
Vagrant
+ ansible
+ fabric
automation
Today: learn Fabric
Fabric workshop
A radically simple IT automation engine
Share GOAL
create fabfile
AGENDA
GOAL
Create deploy tool
- deploy
- dev/staging/production
- tag name (any ascii)
- rollback
- use any tag deployed
- tag list
- remove tag.
GOAL
$ fab help
Usage:
<Deploy>
$ fab -R [ROLE] deploy
$ fab -R [ROLE] deploy:mode=[MODE],tag=[TAG],force=[True]
deploy source to servers which are defined as ROLE
Options:
mode : 'production', 'staging', ‘development(default)'
tag : any ASCII tag. (default = Epoch time + microtime)
force: set 'True' to overwrite. (default = False)
<Show existed tags>
$ fab -R [ROLE] tags
show existed tags
<Change version>
$ fab -R [ROLE] change:tag=XXXXXX
change working version to another tagged source
tag should be exactly same as shown by Tags command
<Remove specified tag>
$ fab -R [ROLE] remove:tag=XXXXXX
remove exist tags
tag should be exactly same as shown by Tags command
GOAL
DEMO
GOAL
Create deploy tool
- deploy
- dev/staging/production
- tag name (any ascii)
- rollback
- use any tag deployed
- tag list
- remove tag.
Share GOAL
create fabfile
AGENDA
local / print
remote(use Ansible inventory)
cd / file put / conditions
Install fabric (useing pip)
$ brew install python --framework
:
$ pip install fabric
Local task
$ cd {YOUR VAGRANT_DIR}
fabfile.py
---
from fabric import api
def localtest():
print "local test"
api.local('ls -al')
Local task (1)
$ fab -R {ROLE} -f {FILE} {COMMAND}
$ fab localtest
local test
[localhost] local: ls -al
total 44
drwxr-xr-x 10 nemo staff 340 Jan 14 15:05 .
drwxr-xr-x+ 427 nemo staff 14518 Jan 14 14:52 ..
drwxr-xr-x 3 nemo staff 102 Nov 19 20:10 .vagrant
-rw-r--r-- 1 nemo staff 3337 Jan 13 20:58 Vagrantfile
drwxr-xr-x 18 nemo staff 612 Jan 14 15:26 fabfile.py
-rw-r--r-- 1 nemo staff 29 Jan 7 18:34 hosts
drwxr-xr-x 6 nemo staff 204 Dec 10 18:47 playbooks
-rw-r--r-- 1 nemo staff 133 Dec 10 17:23 setup.yml
Done.
air:nemo@~/TEST_STUDY$
$ fab localtest
Share GOAL
create fabfile
AGENDA
local / print
remote(use Ansible inventory)
cd / file put / conditions
remote task
fabfile.py
---
from fabric import api
def remotetest():
print "remote test"
api.run('ls -al’)
api.sudo('ls -al’)
Remote task (2)
$ fab remotetest
No hosts found. Please specify (single) host string for connection: {IP_ADDRESS}
[192.168.33.50] run: ls -al
[192.168.33.50] out: total 44
[192.168.33.50] out: drwx------. 6 vagrant vagrant 4096 Jan 14 05:58 .
:
[192.168.33.50] out: drwxrwxr-x 3 vagrant vagrant 4096 Jan 13 11:47 src
[192.168.33.50] out:
total 44
$ fab remotetest
target host required...
$ fab -H {IP_ADDRESS} remotetest
Remote task (trouble?)
~/.ssh/config
---
Host {IP_ADDRESS_OF_YOUR_VAGRANT_MACHINE}
User vagrant
TCPKeepAlive yes
IdentityFile {PRIVATE_KEY_OF_YOUR_VAGRANT_MACHINE}
IdentitiesOnly yes
ControlPersist 2h
Where is the private key??
$ vagrant ssh-config
api.env.use_ssh_config = True
set option in your fabfile.py
Using ROLE instead of -H
$ fab -R httpd-server remotetest
:
from fabric.api import env
from fabric.decorators import roles
env.user = user
env.roledefs.update({
‘httpd-server': [‘{IP_ADDRESS}’, ‘{IP_ADDRESS}’],
'toolservers': [‘{IP_ADDRESS}’],
})
@roles(‘httpd-server')
def YOUR_COMMAND:
pass
Using ROLE (2)
But...
We want to use
Ansible inventory (hosts) file.
* Target host definition should be only one.
* The definition of targets in Fabric is in code,
so we should use Ansible’s inventory file.
Using Ansible inventory
fabfile.py
---
from ansible import inventory
from fabric.api import env, run, local
from fabric import api
inventory = inventory.Inventory('./hosts')
env.roledefs = inventory.groups_list()
env.use_ssh_config = True
def remotetest():
run('ls -al')
hosts
---
[httpd-server]
192.168.33.50
see) Ansible(1-3)
Using Ansible inventory
$ fab -R httpd-server remotetest
OK!!
Ansible inventory (Trouble?)
ex)
/usr/local/Cellar/ansible/1.9.4/libexec/lib/python2.7/site-packages
/usr/local/Cellar/ansible/1.9.4/libexec/vendor/lib/python2.7/site-
packages
fabfile.py
---
import sys
sys.path.append({YOUR_ANSIBLE_PATH})
If you couldn’t load Ansible libraries,
please set your ansible library path.
Share GOAL
create fabfile
AGENDA
local / print
remote(use Ansible inventory)
cd / file put / conditions
mkdir and cd
fabfile.py
---
from ansible import inventory
from fabric.api import env, run, local, cd
from fabric import api
inventory = inventory.Inventory('./hosts')
env.roledefs = inventory.groups_list()
env.use_ssh_config = True
def mkdir_and_cd():
run(‘mkdir -p TMP’)
with cd(‘TMP’):
run(‘pwd’)
$ fab -R httpd-server mkdir_and_cd
mkdir and cd (2)
fabfile.py
---
:
from fabric.contrib import files
:
:
def mkdir_and_cd():
if not files.exists(‘TMP’):
run(‘mkdir -p TMP’)
with cd(‘TMP’):
run(‘ls -al’)
$ fab -R httpd-server mkdir_and_cd
mkdir, cd and put
fabfile.py
---
:
from fabric.api import env, run, local, cd, put
from fabric.contrib import files
:
:
def mkdir_cd_and_put():
if not files.exists(‘TMP’):
run(‘mkdir -p TMP’)
with cd(‘TMP’):
if not files.exists({DEST_FILE}):
put({SRC_FILE}, {DEST_FILE})
$ fab -R httpd-server mkdir_cd_and_put

More Related Content

What's hot

Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestration
bcoca
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using docker
Larry Cai
 
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Puppet
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
Rayed Alrashed
 
Ansible not only for Dummies
Ansible not only for DummiesAnsible not only for Dummies
Ansible not only for Dummies
Łukasz Proszek
 
Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2
Brian Schott
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)
Michele Orselli
 
Configuration Surgery with Augeas
Configuration Surgery with AugeasConfiguration Surgery with Augeas
Configuration Surgery with Augeas
Puppet
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done right
Dan Vaida
 
Deploying Symfony2 app with Ansible
Deploying Symfony2 app with AnsibleDeploying Symfony2 app with Ansible
Deploying Symfony2 app with Ansible
Roman Rodomansky
 
Ansible fest Presentation slides
Ansible fest Presentation slidesAnsible fest Presentation slides
Ansible fest Presentation slides
Aaron Carey
 
Ansible for beginners ...?
Ansible for beginners ...?Ansible for beginners ...?
Ansible for beginners ...?
shirou wakayama
 
Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))
Michele Orselli
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
John Lynch
 
Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.
Łukasz Proszek
 
#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible
Cédric Delgehier
 
Docker perl build
Docker perl buildDocker perl build
Docker perl build
Workhorse Computing
 
Ansible Meetup Hamburg / Quickstart
Ansible Meetup Hamburg / QuickstartAnsible Meetup Hamburg / Quickstart
Ansible Meetup Hamburg / Quickstart
Henry Stamerjohann
 
Ansible - Introduction
Ansible - IntroductionAnsible - Introduction
Ansible - Introduction
Stephane Manciot
 
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpecTest-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
Martin Etmajer
 

What's hot (20)

Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestration
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using docker
 
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 
Ansible not only for Dummies
Ansible not only for DummiesAnsible not only for Dummies
Ansible not only for Dummies
 
Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)
 
Configuration Surgery with Augeas
Configuration Surgery with AugeasConfiguration Surgery with Augeas
Configuration Surgery with Augeas
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done right
 
Deploying Symfony2 app with Ansible
Deploying Symfony2 app with AnsibleDeploying Symfony2 app with Ansible
Deploying Symfony2 app with Ansible
 
Ansible fest Presentation slides
Ansible fest Presentation slidesAnsible fest Presentation slides
Ansible fest Presentation slides
 
Ansible for beginners ...?
Ansible for beginners ...?Ansible for beginners ...?
Ansible for beginners ...?
 
Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.
 
#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible
 
Docker perl build
Docker perl buildDocker perl build
Docker perl build
 
Ansible Meetup Hamburg / Quickstart
Ansible Meetup Hamburg / QuickstartAnsible Meetup Hamburg / Quickstart
Ansible Meetup Hamburg / Quickstart
 
Ansible - Introduction
Ansible - IntroductionAnsible - Introduction
Ansible - Introduction
 
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpecTest-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
 

Viewers also liked

CI : the first_step: Auto Testing with CircleCI - (MOSG)
CI : the first_step: Auto Testing with CircleCI - (MOSG)CI : the first_step: Auto Testing with CircleCI - (MOSG)
CI : the first_step: Auto Testing with CircleCI - (MOSG)
Soshi Nemoto
 
Vagrant - the essence of DevOps in a tool
Vagrant - the essence of DevOps in a toolVagrant - the essence of DevOps in a tool
Vagrant - the essence of DevOps in a tool
Paul Stack
 
DevOps: Using Vagrant to Enhance Your Day to Day Development
DevOps: Using Vagrant to Enhance Your Day to Day DevelopmentDevOps: Using Vagrant to Enhance Your Day to Day Development
DevOps: Using Vagrant to Enhance Your Day to Day DevelopmentRob Reynolds
 
Vagrant, Chef and TYPO3 - A Love Affair
Vagrant, Chef and TYPO3 - A Love AffairVagrant, Chef and TYPO3 - A Love Affair
Vagrant, Chef and TYPO3 - A Love Affair
Michael Lihs
 
DevOps: una breve introducción
DevOps: una breve introducciónDevOps: una breve introducción
DevOps: una breve introducción
Christian Rodriguez
 
DevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & AnsibleDevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & Ansible
Arnaud LEMAIRE
 

Viewers also liked (6)

CI : the first_step: Auto Testing with CircleCI - (MOSG)
CI : the first_step: Auto Testing with CircleCI - (MOSG)CI : the first_step: Auto Testing with CircleCI - (MOSG)
CI : the first_step: Auto Testing with CircleCI - (MOSG)
 
Vagrant - the essence of DevOps in a tool
Vagrant - the essence of DevOps in a toolVagrant - the essence of DevOps in a tool
Vagrant - the essence of DevOps in a tool
 
DevOps: Using Vagrant to Enhance Your Day to Day Development
DevOps: Using Vagrant to Enhance Your Day to Day DevelopmentDevOps: Using Vagrant to Enhance Your Day to Day Development
DevOps: Using Vagrant to Enhance Your Day to Day Development
 
Vagrant, Chef and TYPO3 - A Love Affair
Vagrant, Chef and TYPO3 - A Love AffairVagrant, Chef and TYPO3 - A Love Affair
Vagrant, Chef and TYPO3 - A Love Affair
 
DevOps: una breve introducción
DevOps: una breve introducciónDevOps: una breve introducción
DevOps: una breve introducción
 
DevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & AnsibleDevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & Ansible
 

Similar to Fabric workshop(1) - (MOSG)

Fabric for fun_and_profit
Fabric for fun_and_profitFabric for fun_and_profit
Fabric for fun_and_profit
Javier Jair Trejo García
 
Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Bangpypers april-meetup-2012
Bangpypers april-meetup-2012
Deepak Garg
 
Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled InfrastructureCloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Habeeb Rahman
 
Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python Deployment with Fabricandymccurdy
 
Puppet at Opera Sofware - PuppetCamp Oslo 2013
Puppet at Opera Sofware - PuppetCamp Oslo 2013Puppet at Opera Sofware - PuppetCamp Oslo 2013
Puppet at Opera Sofware - PuppetCamp Oslo 2013
Cosimo Streppone
 
Deployment with Fabric
Deployment with FabricDeployment with Fabric
Deployment with Fabricandymccurdy
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby Team
Arto Artnik
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
Alan Pinstein
 
Oracle API Gateway Installation
Oracle API Gateway InstallationOracle API Gateway Installation
Oracle API Gateway Installation
Rakesh Gujjarlapudi
 
Node.js basics
Node.js basicsNode.js basics
Node.js basicsBen Lin
 
Infrastructure as code - Python Saati #36
Infrastructure as code - Python Saati #36Infrastructure as code - Python Saati #36
Infrastructure as code - Python Saati #36
Halil Kaya
 
Fabric - a server management tool from Instagram
Fabric - a server management tool from InstagramFabric - a server management tool from Instagram
Fabric - a server management tool from Instagram
Jay Ren
 
Composer for busy developers - DPC13
Composer for busy developers - DPC13Composer for busy developers - DPC13
Composer for busy developers - DPC13
Rafael Dohms
 
Pythonic Deployment with Fabric 0.9
Pythonic Deployment with Fabric 0.9Pythonic Deployment with Fabric 0.9
Pythonic Deployment with Fabric 0.9
Corey Oordt
 
OpenNebula, the foreman and CentOS play nice, too
OpenNebula, the foreman and CentOS play nice, tooOpenNebula, the foreman and CentOS play nice, too
OpenNebula, the foreman and CentOS play nice, too
inovex GmbH
 
Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015
Alex S
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
biicode
 
Performance Profiling in Rust
Performance Profiling in RustPerformance Profiling in Rust
Performance Profiling in Rust
InfluxData
 
Virtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + PuppetVirtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + PuppetOmar Reygaert
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Herokuronnywang_tw
 

Similar to Fabric workshop(1) - (MOSG) (20)

Fabric for fun_and_profit
Fabric for fun_and_profitFabric for fun_and_profit
Fabric for fun_and_profit
 
Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Bangpypers april-meetup-2012
Bangpypers april-meetup-2012
 
Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled InfrastructureCloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
 
Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python Deployment with Fabric
 
Puppet at Opera Sofware - PuppetCamp Oslo 2013
Puppet at Opera Sofware - PuppetCamp Oslo 2013Puppet at Opera Sofware - PuppetCamp Oslo 2013
Puppet at Opera Sofware - PuppetCamp Oslo 2013
 
Deployment with Fabric
Deployment with FabricDeployment with Fabric
Deployment with Fabric
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby Team
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
Oracle API Gateway Installation
Oracle API Gateway InstallationOracle API Gateway Installation
Oracle API Gateway Installation
 
Node.js basics
Node.js basicsNode.js basics
Node.js basics
 
Infrastructure as code - Python Saati #36
Infrastructure as code - Python Saati #36Infrastructure as code - Python Saati #36
Infrastructure as code - Python Saati #36
 
Fabric - a server management tool from Instagram
Fabric - a server management tool from InstagramFabric - a server management tool from Instagram
Fabric - a server management tool from Instagram
 
Composer for busy developers - DPC13
Composer for busy developers - DPC13Composer for busy developers - DPC13
Composer for busy developers - DPC13
 
Pythonic Deployment with Fabric 0.9
Pythonic Deployment with Fabric 0.9Pythonic Deployment with Fabric 0.9
Pythonic Deployment with Fabric 0.9
 
OpenNebula, the foreman and CentOS play nice, too
OpenNebula, the foreman and CentOS play nice, tooOpenNebula, the foreman and CentOS play nice, too
OpenNebula, the foreman and CentOS play nice, too
 
Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 
Performance Profiling in Rust
Performance Profiling in RustPerformance Profiling in Rust
Performance Profiling in Rust
 
Virtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + PuppetVirtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + Puppet
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
 

Recently uploaded

Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 

Recently uploaded (20)

Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 

Fabric workshop(1) - (MOSG)

  • 2. Our Purpose Make ourselves ‘Business partner’ from ‘factory’. Points Engineering knowledge <- * TODAY * Logical Thinking Co-operation work Resources Meetup: http://www.meetup.com/Open-Study-Group-Saigon Slideshare: http://www.slideshare.net/nemo-mulodo/ — Study Group —
  • 3. Previous study DevOps: What's DevOps http://www.slideshare.net/nemo-mulodo/devops1-whats-devops-mosg DevOps: Vagrant http://www.slideshare.net/nemo-mulodo/devops2-vagrant-mosg DevOps: Ansible http://www.slideshare.net/nemo-mulodo/devops3-ansible-mosg DevOps: Ansible(2) http://www.slideshare.net/nemo-mulodo/devops4-ansible2-mosg Preparation for workshop (tools) http://www.slideshare.net/nemo-mulodo/instruction-dev-environment Feedback of previous study
  • 7. Fabric workshop A radically simple IT automation engine
  • 9. GOAL Create deploy tool - deploy - dev/staging/production - tag name (any ascii) - rollback - use any tag deployed - tag list - remove tag.
  • 10. GOAL $ fab help Usage: <Deploy> $ fab -R [ROLE] deploy $ fab -R [ROLE] deploy:mode=[MODE],tag=[TAG],force=[True] deploy source to servers which are defined as ROLE Options: mode : 'production', 'staging', ‘development(default)' tag : any ASCII tag. (default = Epoch time + microtime) force: set 'True' to overwrite. (default = False) <Show existed tags> $ fab -R [ROLE] tags show existed tags <Change version> $ fab -R [ROLE] change:tag=XXXXXX change working version to another tagged source tag should be exactly same as shown by Tags command <Remove specified tag> $ fab -R [ROLE] remove:tag=XXXXXX remove exist tags tag should be exactly same as shown by Tags command
  • 12. GOAL Create deploy tool - deploy - dev/staging/production - tag name (any ascii) - rollback - use any tag deployed - tag list - remove tag.
  • 13. Share GOAL create fabfile AGENDA local / print remote(use Ansible inventory) cd / file put / conditions
  • 14. Install fabric (useing pip) $ brew install python --framework : $ pip install fabric
  • 15. Local task $ cd {YOUR VAGRANT_DIR} fabfile.py --- from fabric import api def localtest(): print "local test" api.local('ls -al')
  • 16. Local task (1) $ fab -R {ROLE} -f {FILE} {COMMAND} $ fab localtest local test [localhost] local: ls -al total 44 drwxr-xr-x 10 nemo staff 340 Jan 14 15:05 . drwxr-xr-x+ 427 nemo staff 14518 Jan 14 14:52 .. drwxr-xr-x 3 nemo staff 102 Nov 19 20:10 .vagrant -rw-r--r-- 1 nemo staff 3337 Jan 13 20:58 Vagrantfile drwxr-xr-x 18 nemo staff 612 Jan 14 15:26 fabfile.py -rw-r--r-- 1 nemo staff 29 Jan 7 18:34 hosts drwxr-xr-x 6 nemo staff 204 Dec 10 18:47 playbooks -rw-r--r-- 1 nemo staff 133 Dec 10 17:23 setup.yml Done. air:nemo@~/TEST_STUDY$ $ fab localtest
  • 17. Share GOAL create fabfile AGENDA local / print remote(use Ansible inventory) cd / file put / conditions
  • 18. remote task fabfile.py --- from fabric import api def remotetest(): print "remote test" api.run('ls -al’) api.sudo('ls -al’)
  • 19. Remote task (2) $ fab remotetest No hosts found. Please specify (single) host string for connection: {IP_ADDRESS} [192.168.33.50] run: ls -al [192.168.33.50] out: total 44 [192.168.33.50] out: drwx------. 6 vagrant vagrant 4096 Jan 14 05:58 . : [192.168.33.50] out: drwxrwxr-x 3 vagrant vagrant 4096 Jan 13 11:47 src [192.168.33.50] out: total 44 $ fab remotetest target host required... $ fab -H {IP_ADDRESS} remotetest
  • 20. Remote task (trouble?) ~/.ssh/config --- Host {IP_ADDRESS_OF_YOUR_VAGRANT_MACHINE} User vagrant TCPKeepAlive yes IdentityFile {PRIVATE_KEY_OF_YOUR_VAGRANT_MACHINE} IdentitiesOnly yes ControlPersist 2h Where is the private key?? $ vagrant ssh-config api.env.use_ssh_config = True set option in your fabfile.py
  • 21. Using ROLE instead of -H $ fab -R httpd-server remotetest : from fabric.api import env from fabric.decorators import roles env.user = user env.roledefs.update({ ‘httpd-server': [‘{IP_ADDRESS}’, ‘{IP_ADDRESS}’], 'toolservers': [‘{IP_ADDRESS}’], }) @roles(‘httpd-server') def YOUR_COMMAND: pass
  • 22. Using ROLE (2) But... We want to use Ansible inventory (hosts) file. * Target host definition should be only one. * The definition of targets in Fabric is in code, so we should use Ansible’s inventory file.
  • 23. Using Ansible inventory fabfile.py --- from ansible import inventory from fabric.api import env, run, local from fabric import api inventory = inventory.Inventory('./hosts') env.roledefs = inventory.groups_list() env.use_ssh_config = True def remotetest(): run('ls -al') hosts --- [httpd-server] 192.168.33.50 see) Ansible(1-3)
  • 24. Using Ansible inventory $ fab -R httpd-server remotetest OK!!
  • 26. Share GOAL create fabfile AGENDA local / print remote(use Ansible inventory) cd / file put / conditions
  • 27. mkdir and cd fabfile.py --- from ansible import inventory from fabric.api import env, run, local, cd from fabric import api inventory = inventory.Inventory('./hosts') env.roledefs = inventory.groups_list() env.use_ssh_config = True def mkdir_and_cd(): run(‘mkdir -p TMP’) with cd(‘TMP’): run(‘pwd’) $ fab -R httpd-server mkdir_and_cd
  • 28. mkdir and cd (2) fabfile.py --- : from fabric.contrib import files : : def mkdir_and_cd(): if not files.exists(‘TMP’): run(‘mkdir -p TMP’) with cd(‘TMP’): run(‘ls -al’) $ fab -R httpd-server mkdir_and_cd
  • 29. mkdir, cd and put fabfile.py --- : from fabric.api import env, run, local, cd, put from fabric.contrib import files : : def mkdir_cd_and_put(): if not files.exists(‘TMP’): run(‘mkdir -p TMP’) with cd(‘TMP’): if not files.exists({DEST_FILE}): put({SRC_FILE}, {DEST_FILE}) $ fab -R httpd-server mkdir_cd_and_put