First Fabric (Python deployment tool)

I tried using Fabric, a Python deploy tool, so I will show you how to use it.

Installation

[Desktop] sudo easy_install fabric
.
.
.
Finished processing dependencies for fabric
[Desktop] fab -V                                                                                                     16:37:15
Fabric 1.10.2
Paramiko 1.16.0
[Desktop]

Try local ()

Create fabfile.py in any directory

from fabric.api import local
def test():
  local("top")

The above statement means that if you run $ fab test in the directory where the created fabfile is located, it will run $ top in that directory. With this you can use it for multiple servers

run("cd /var/www/apps/your_app; git checkout master; git pull origin master")

You can do something like that.

About the run () command

The content itself is the same as local (), just that run is executed on a remote server.

SFTP transfer (put)

** About put **

--First argument: Local server (source) --Second argument: Remote server (destination) --Third argument and after: Specify access authority, execute authority, etc.

Example


put(
  "your_app_dir",
  "/var/www/apps/", 
  mode=0755,
  use_sudo=True
  
)

Notification to slack

fabric-slack-tool is the most decent library so far.

How to write a specific fabfile.py

If you search with Gist, you will find many Search · fabfile.py · GitHub

References

-Overview and Tutorial (Official Site) --Run commands on remote server using Fabric -[Fabric writing tips](http://qiita.com/narikei/items/99e77eb2ff4029f2157c#local%E3%81%A7%E5%AE%9F%E8%A1%8C%E3%81%97%E3%81 % 9F% E3% 81% 84) -Tips to help you use the Python deployment tool Fabric for the first time

Recommended Posts

First Fabric (Python deployment tool)
First time python
First Python 3 ~ First comparison ~
Idempotent guarantee with deployment tool fabric + cuisine
First time python
First Python ~ Coding 2 ~
First python [O'REILLY]
Why we chose Fabric as our deployment tool
First Python 3rd Edition
PyQ ~ Python First Steps ~
First Python image processing
[Python] Python / Scikit-learn's first SVM
First Python miscellaneous notes
[Python] Chapter 01-01 About Python (First Python)
[Python tutorial] Control structure tool
First neuron simulation with NEURON + Python
Install Cheminformatics Tool RDKit for Python
First simple regression analysis in Python
First Python 3 ~ The beginning of repetition ~
Use fabric as is in python (fabric3)
Web scraping with Python First step
First Python 3 ~ Extra: Numerical Random Fantasy ~
[GUI with Python] PyQt5-The first step-
Prepare your first Python development environment
Python package management tool personal summary
Python (from first time to execution)
C / C ++ programmer challenges Python (first step)
Created AtCoder test tool for Python
See python for the first time
[Python] Creating a scraping tool Memo
The first step in Python Matplotlib
Easy deployment environment with gaffer + fabric