fabric is a python deployment tool. http://fabric-ja.readthedocs.io/ja/latest/tutorial.html
Arbitrary command execution procedure can be written in python in local environment or remote environment. When setting up the PC, it became troublesome to execute the command every time, so I want to be able to execute it collectively with fabric.
You can write it in a shell script, but python is easier to describe conditional branching and seems to have a convenient API, so I will use this.
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="GalliumOS 2.1"
$ python --version
Python 2.7.12
It seems recommended to install fabric via pip. python was included from the beginning, but pip was not included, so I will include it.
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py
It seems that these are necessary. For the time being, the minimum.
$ sudo apt install python-dev build-essential libssl-dev
$ pip install fabric
$ cat fabfile_1.py
from fabric.api import local
def test():
local("echo hello!")
$ fab -f fabfile_1.py test
[localhost] local: echo hello!
hello!
Done.
Recommended Posts