Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Fabric (Python Library) how to access IP/hostname in subrouties?

Tags:

python

fabric

In fabric python, how to access IP or hostname in the subroutine? Want to read configuration file "conf/ip_address.conf", read key/values (using ConfigParser) and then run jobs on remote servers.

Developing tool to backup/version control configuration files from large number of hosts. Idea is - store last modified timestamp of configuration files locally. Use that to get files only when they are modified.

thx,

like image 908
Sopan Avatar asked Jan 13 '23 23:01

Sopan


1 Answers

I am assuming you need the IP or hostname of the remote host that a command is currently executing on. env.host_string provides this. You should be able to set up a custom task and run it with execute and within the "current host" can be retrieved through env.host_string

like image 63
iruvar Avatar answered Feb 05 '23 15:02

iruvar