User Guide
Command Line Interface
The rift
command provides several subcommands for managing your infrastructure:
rift --help
Common Commands
init
Initialize a new Rift project:
rift init [project-name]
inventory
Manage your inventory:
rift inventory create # Create a new inventory
rift inventory list # List available inventories
rift inventory show # Show inventory details
deploy
Deploy your infrastructure:
rift deploy # Deploy all playbooks
rift deploy --playbook # Deploy specific playbook
Configuration
Project Configuration
The project configuration file (rift.yml
) supports the following options:
# Global settings
ansible_config: ansible.cfg
inventory_dir: inventory
playbook_dir: playbooks
role_dir: roles
# Default variables
variables:
environment: production
region: us-west-2
Inventory Management
Creating an Inventory
Create a new inventory:
rift inventory create my-inventory
Edit the inventory file:
all: children: webservers: hosts: web1: ansible_host: 192.168.1.10 web2: ansible_host: 192.168.1.11 databases: hosts: db1: ansible_host: 192.168.1.20
Playbook Management
Creating a Playbook
Create a new playbook:
rift playbook create my-playbook
Edit the playbook:
--- - name: Deploy application hosts: webservers tasks: - name: Install nginx package: name: nginx state: present
Role Management
Creating a Role
Create a new role:
rift role create my-role
Edit the role tasks:
--- - name: Install packages package: name: "{{ item }}" state: present loop: - nginx - php-fpm
Best Practices
Version Control: Always use version control for your playbooks and roles
Testing: Test your playbooks in a staging environment before production
Documentation: Document your roles and playbooks
Security: Use encrypted variables for sensitive data
Modularity: Break down complex tasks into smaller, reusable roles
Advanced Usage
Custom Modules
You can create custom modules for Rift:
# modules/my_module.py
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(
name=dict(type='str', required=True),
state=dict(type='str', default='present')
)
)
# Module implementation
module.exit_json(changed=True, msg='Success')
if __name__ == '__main__':
main()
Plugins
Rift supports custom plugins for extending functionality:
# plugins/filter_plugins/my_filters.py
def my_filter(value):
return value.upper()
class FilterModule(object):
def filters(self):
return {
'my_filter': my_filter
}