วันอังคารที่ 19 กุมภาพันธ์ พ.ศ. 2556

Installing Fabric Control Client

Requirements
  • Python 2.5+ with the development headers
  • python-setuptools and pip (optional, but preferred)
  • gcc

CentOS/RHEL 6.x

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

Set Authorized_Keys
(server)

$ ssh-keygen -t rsa

Open file /root/.ssh/id_rsa.pub And copy your public key
        (Example)
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAztitxAcgo8TpH0FgJFYW/sieMTWLqdTczN2E/BrXdbUb/1zS2S23n02Yg8NHuezOrf+STJ/ejQGnIJ5px4TN1FULwSP+mv8CIscdnJfWc9UQYYw5Y55FHTGNyJDOSnda++mgoS0nbjewGcNkzxE4WvAKXlJNVBkJs7d0sb+XjCn0z822tQznum8b27A7p5e0wbhmNcz0R92JEShS9OSle/72mlmueYt5ERRAxgcG2W6Qhb/asd#R$R$FEfaffvfkD1tDyqHm4CdBjUlv55RalncgzmEq33vjJLyDmw+MeGcYE6PWVi5KK+JzegyEOCZiA30iIYTPDVcLNNWvEkJf9dMLPw== root@xxxxxxxxxxxxxx

(All Clients)
  Add a new file  /root/.ssh/authorized_keys. and copy server public key

    (file name authorized_keys)

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAztitxAcgo8TpH0FgJFYW/sieMTWLqdTczN2E/BrXdbUb/1zS2S23n02Yg8NHuezOrf+STJ/ejQGnIJ5px4TN1FULwSP+mv8CIscdnJfWc9UQYYw5Y55FHTGNyJDOSnda++mgoS0nbjewGcNkzxE4WvAKXlJNVBkJs7d0sb+XjCn0z822tQznum8b27A7p5e0wbhmNcz0R92JEShS9OSle/72mlmueYt5ERRAxgcG2W6Qhb/asd#R$R$FEfaffvfkD1tDyqHm4CdBjUlv55RalncgzmEq33vjJLyDmw+MeGcYE6PWVi5KK+JzegyEOCZiA30iIYTPDVcLNNWvEkJf9dMLPw== root@xxxxxxxxxxxxxx
Save And Exit

Creating a fabfile
Create a basic fabfile.py which runs uptime on each of the remote hosts.(Do it on the server.)
#!/usr/bin/env python

from fabric.api import env, run

env.hosts = [ '192.168.1.100', '192.168.1.101', '192.168.1.102' ]

def uptime():
  run('uptime')
env.hosts ,This array is used to store the ip address of the client.

Result :






ไม่มีความคิดเห็น:

แสดงความคิดเห็น