3. What is Fabric?
- Python library. Command-line tool for streamlining the use of SSH for automations and deployments
- Higher level interface to the SSH protocol than other Python libraries
- Primary usage is for running tasks across multiple remote hosts
- Installation could not be easier
- sudo apt-get install fabric OR sudo yum install fabric
- pip install fabric
- Limited dependencies:
- Python installed
- setuptools packaging/installation library installed
- Python’s Paramiko SSH library and its PyCrypto dependency installed
4. - Super easy to get started (example1/fabfile.py)
- It all starts with the “env” dictionary (example2/fabfile.py)
- Remote commands (example3/fabfile.py)
- Dynamic hosts (example4/fabfile.py)
- Task arguments (example5/fabfile.py)
- Dynamic hosts: less typing === heck yeah! (example6/fabfile.py)
- Private functions vs tasks (example7/fabfile.py)
Fabric: First Steps
5. - Service management (example8/fabfile.py)
- System Stats (example9/fabfile.py)
- Tailing logs (example10/fabfile.py)
- Process search & watch (example11/fabfile.py)
- Tips and tricks (example12/fabfile.py)
Fabric: Example Control Tasks
6. - Installing packages (example13/fabfile.py)
- Uploading / Download files (example14/fabfile.py)
- Performing backups (example15/fabfile.py)
- Creating users (example16/fabfile.py)
Basically, any task or action that is performed usually by logging into the server can be automated.
Fabric: Automating tasks
7. - Simple dump and run (example17/fabfile.py)
- Throw in some source control (example18/fabfile.py)
Deployments, when you think about it, are simply a list of consecutive tasks that need to be executed to
make an application or piece of code available to someone or something. It’s not rocket-science, it’s a
combination of all the various things we have looked at today.
Fabric: Deployments made easy
8. And finally: A combination of everything we’ve learned (example19/fabfile.py)
● Forget logging into individual servers to execute regular tasks
● Take control of your infra
● Take control of your deployments
● Sleep soundly at night knowing your servers are configured properly
● Infra as Code and its supporting tools are not the Holy Grail but they make our lives easier
Even none of you end up using Fabric, at the very least, you have a new tool in your DevOps toolbelt.
Thanks!
In conclusion