# Danielfm's Workstation Collection for Ansible

This Ansible collection provides a comprehensive set of roles for setting up
and configuring Linux development workstations. It automates the installation
and configuration of development tools, security settings, audio production
capabilities, and backup solutions.

## Roles Overview

| Role                                               | Description                                   |
|----------------------------------------------------|-----------------------------------------------|
| [`danielfm.workstation.all`](./roles/all/)         | Meta-role that runs all other roles in order  |
| [`danielfm.workstation.base`](./roles/base/)       | Essential system configuration and packages   |
| [`danielfm.workstation.flatpak`](./roles/flatpak/) | Flatpak repository and application management |
| [`danielfm.workstation.audio`](./roles/audio/)     | Low-latency audio production setup            |
| [`danielfm.workstation.dev`](./roles/dev/)         | Development tools and environments            |
| [`danielfm.workstation.backup`](./roles/backup/)   | Automated backup with Restic                  |
| [`danielfm.workstation.xfce`](./roles/xfce/)       | Basic setup for the Xfce desktop environment  |
| [`danielfm.workstation.sway`](./roles/sway/)       | Setup for the Sway window manager             |

## System Requirements

- **Supported OS**: Debian or Fedora Linux distributions
- **Privileges**: Root access required for system configuration
- **Network**: Internet connection for package downloads
- **Ansible**: Version 2.9 or higher

## Installation

### Via Ansible Galaxy

```bash
ansible-galaxy collection install danielfm.workstation --upgrade
```

### Via Requirements File

Create a `requirements.yml` file:

```yaml
---
collections:
  - name: danielfm.workstation
    version: ">=0.1.0"
```

Then install:

```bash
ansible-galaxy collection install -r requirements.yml
```

## Quick Start

### Using Playbooks

The easiest way to set up your workstation is using one of the included
playbooks:

```bash
# Complete workstation with all features
ansible-playbook playbooks/full.yml -i playbooks/inventory

# Development workstation
ansible-playbook playbooks/dev-workstation.yml -i playbooks/inventory

# Audio production workstation
ansible-playbook playbooks/audio-workstation.yml -i playbooks/inventory
```

You can customize the configuration by creating a variables file:

```yaml
# vars.yml
---
base_system_timezone: America/Sao_Paulo
base_system_locales:
  - pt_BR.UTF-8
  - en_US.UTF-8

backup_restic_repositories:
  - name: local
    repository: '/media/user/backup-vol/restic'
backup_restic_password_file: 'passwd'

# See individual role READMEs for more options
```

Then run with:
```bash
ansible-playbook playbooks/full.yml -i playbooks/inventory -e @vars.yml
```

### Individual Role Usage

Run specific roles as needed:

```yaml
---
- hosts: localhost
  connection: local
  roles:
    - danielfm.workstation.base
    - danielfm.workstation.backup
    - danielfm.workstation.flatpak
    - danielfm.workstation.dev
    - danielfm.workstation.audio
    - danielfm.workstation.xfce
    - danielfm.workstation.sway
```

## Creating Custom Playbooks

### Using Individual Roles

If the included playbooks don't meet your needs, create a custom playbook
using individual roles:

```yaml
---
- hosts: localhost
  connection: local
  gather_facts: true
  
  vars:
    base_system_timezone: UTC
    base_system_locales:
      - en_US.UTF-8
    
    backup_restic_repositories:
      - name: local
        repository: '/media/user/backup-vol/restic'
      - name: remote
        repository: 's3:s3.us-east-1.amazonaws.com/bucket/path'
    backup_restic_password_file: 'passwd'
    backup_restic_extra_excludes:
      - '$HOME/Downloads'
      - '$HOME/.cache'
  
  roles:
    - danielfm.workstation.base
    - danielfm.workstation.flatpak
    - danielfm.workstation.backup
    - danielfm.workstation.dev
    - danielfm.workstation.sway
```

### Desktop Environment Only

To install just a desktop environment on an existing system:

```yaml
---
- hosts: localhost
  connection: local
  gather_facts: true
  
  roles:
    - danielfm.workstation.sway  # or danielfm.workstation.xfce
```

## Included Playbooks

This collection provides ready-to-use playbooks in the `playbooks/` directory
for common workstation configurations:

### `playbooks/full.yml`

Complete workstation setup that applies all roles in the recommended order:
- Base system configuration
- Flatpak application support
- Backup configuration
- Development tools
- Audio production setup
- Xfce desktop environment
- Sway window manager

Run with:
```bash
ansible-playbook playbooks/full.yml -i playbooks/inventory
```

### `playbooks/dev-workstation.yml`

Development-focused workstation configuration that includes:
- Base system configuration
- Flatpak application support
- Backup configuration
- Development tools (Node.js, Emacs, Kitty, tmux, Android SDK)

Ideal for software developers who want essential development tools without a specific desktop environment.

Run with:
```bash
ansible-playbook playbooks/dev-workstation.yml -i playbooks/inventory
```

### `playbooks/audio-workstation.yml`

Audio production workstation configuration that includes:
- Base system configuration
- Flatpak application support
- Backup configuration
- Low-latency audio optimizations (PipeWire/JACK, real-time kernel, CPU DMA latency)

Ideal for audio engineers and music producers who need professional audio capabilities.

Run with:
```bash
ansible-playbook playbooks/audio-workstation.yml -i playbooks/inventory
```

### `playbooks/sway.yml`

Minimal Sway window manager setup:
- Sway window manager and related tools only

Use this to add Sway to an existing workstation or combine with other roles.

Run with:
```bash
ansible-playbook playbooks/sway.yml -i playbooks/inventory
```

### `playbooks/xfce.yml`

Minimal Xfce desktop environment setup:
- Xfce desktop environment and related tools only

Use this to add Xfce to an existing workstation or combine with other roles.

Run with:
```bash
ansible-playbook playbooks/xfce.yml -i playbooks/inventory
```

**Note**: All playbooks support the `target` variable to specify which hosts to configure:
```bash
ansible-playbook playbooks/dev-workstation.yml -i playbooks/inventory -e "target=localhost"
```

## Testing

This collection includes Molecule tests for validation:

```bash
# Test all roles
molecule test

# Test specific scenario
molecule test -s default
```

## Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request

## License

MIT

## Author

This collection was created by Daniel Martins.

## Support

- **Issues**: Report bugs and feature requests via GitHub Issues
- **Documentation**: See individual role README files for detailed configuration options
- **Examples**: Check the `playbooks/` directory for additional usage examples
