More about the fab tool

The fab tool itself supports many operations. It can be used to list the different tasks inside fabfile. It can also set the fab environment during execution. For example, you can define the host that will run the commands on it by using the -H or --hosts switches, without the need to specify it inside fabfile. This actually sets the env.hosts variable inside fabfile during execution:

fab -H srv1,srv2

On the other hand, you can define the command that you want to run by using the fab tool. This is something like Ansible ad hoc mode (we will discuss this in detail in Chapter 13, Ansible for System Administration):

fab -H srv1,srv2 -- ifconfig -a

If you don't want to store the password in clear text inside of the fabfile ...

Get Hands-On Enterprise Automation with Python. now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.