[PYTHON] How to install fabric and basic usage

How to install and use python's deployment tool fabric. An OS that can use yum such as CentOS is a prerequisite.

Introduction method

Install the required packages.

yum install gcc python-devel python-setuptools
easy_install pip
pip install fabric

Confirm that it has been installed.

fab -V

Command execution

Execute a command to the remote server to get system information. It is assumed that you can connect by specifying the host name with ssh. (Set ./ssh/config file, etc.)

Create a fabfile.

from fabric.api import run, env

env.use_ssh_config = True

def uname():
    run("uname")

Execute the fab command. (Specify the host name in hostname)

fab -H hostname uname

bonus

#Command execution on remote server
run("command")

#Command execution on local server
local("command")

#Send file to remote server
put("{Source file path}", "{Destination file path}")

#Receive files from remote server
get("{Source file path}", "{Destination file path}")

Specify the module first when executing each command.

from fabric.api import run, env, local, put, get

Recommended Posts

How to install fabric and basic usage
How to install and use Tesseract-OCR
How to install CUDA and nvidia-driver
How to install and use Graphviz
How to install and use pandas_datareader [Python]
How to install Python
How to install pip
How to install archlinux
How to install python
How to install BayesOpt
How to install Nbextensions
How to install Prover9
[2020.8 latest] How to install Python
How to install Python [Windows]
Beginners! Basic Linux commands and how to use them!
Tabpy 1.0 (2020-01 version) How to install
How to install Git GUI and Gitk on CentOS
How to install mkl numpy
How to install Pelican blog
How to install python using anaconda
How to install python-pip with ubuntu20.04LTS
How to install VMware-Tools on Linux
How to install pycrypto on Windows
How to install OpenCV on Mac
How to install MBDyn (Linux Ubuntu)
How to install PyPy on CentOS
How to install TensorFlow on CentOS 7
How to use .bash_profile and .bashrc
How to create a Dockerfile (basic)
Install fabric on Ubuntu and try
How to make a crawler --Basic
How to install mysql-connector with pip3
How to install Maven on CentOS
How to install Go on Ubuntu
How to install music 21 on windows
How to install Anaconda with pyenv
How to solve slide puzzles and 15 puzzles
How to install OpenCV on Cloud9 and run it in Python
How to pass and study the Python 3 Engineer Certification Basic Exam
[EC2] How to install chrome and the contents of each command
How to install pandas on EC2 (How to deal with MemoryError and PermissionError)
How to use Google Colaboratory and usage example (PyTorch x DCGAN)
[Linux] How to subdivide files and folders
How to package and distribute Python scripts
How to split and save a DataFrame
How to install aws-session-manager-plugin on Manajro Linux
How to install drobertadams / toggl-cli on Mac
python3 How to install an external module
[Kivy] How to install Kivy on Windows [Python]
How to install CatBoost [as of January 2020]
How to install DLIB with 2020 / CUDA enabled
How to install packages on Alpine Linux
How to install Anisble on Amazon Linux 2
How to install richzhang / colorization on Windows 10
How to install your own (root) CA
python: How to use locals () and globals ()
How to install Windows Subsystem For Linux
How to install Apache (httpd) on CentOS7
How to install php7.4 on Linux (Ubuntu)
How to install Eclipse GlassFish 5.1.0 on CentOS 7
[Python] How to calculate MAE and RMSE