본문 바로가기

리눅스

fabric hello print on CentOS 7

반응형

fabric hello print on CentOS 7

컨테이너 실행

docker run -d --rm --network host --privileged --name fabric --hostname fabric centos "/sbin/init"

컨테이너 안으로 진입

docker exec -it fabric bash

python3, pip3, fabric3 설치

[root@fabric /]$ yum install -y python3-devel python3-pip vim net-tools git
[root@fabric /]$ pip3 install fabric3

python3 및 fab 버전 확인

[root@fabric ~]$ python3 --version
Python 3.6.8
[root@fabric ~]$ fab -V
Fabric3 1.14.post1
Paramiko 2.7.2

fabfile.py 편집

[root@fabric fctl]$ vim fabfile.py
def hello():
    print("Hello world!")

def hello2(name="world"):
    print("Hello %s!" % name)

fab 실행

[root@fabric fctl]$ fab --list
Available commands:

    hello
    hello2
[root@fabric fctl]$ fab hello
Hello world!

Done.
[root@fabric fctl]$ fab hello2:name=sangchul
Hello sangchul!

Done.

 

728x90
반응형