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

In text python, how to access IP or hostname in a routine? You want to read the configuration file "conf / ip_address.conf", read the key / values โ€‹โ€‹(using ConfigParser), and then run the tasks on the remote servers.

Development of a tool for backup / version control of configuration files from a large number of hosts. The idea is to store the last modified timestamp of the configuration files locally. Use this to receive files only when they have been modified.

THX

+4
source share
1 answer

I assume that you need the IP address or host name of the remote host on which the command is currently running. env.host_string provides this. You should be able to configure a custom task and run it with execute , and inside the current host can be obtained via env.host_string

+8
source

Source: https://habr.com/ru/post/1490123/


All Articles