Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/test-e2e-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ jobs:
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2

- name: Install Ansible
run: ./scripts/setup/install-ansible.sh
- name: Install dependencies
run: |
cargo build -p torrust-dependency-installer --bin dependency-installer
cargo run -p torrust-dependency-installer --bin dependency-installer -- install

- name: Setup Docker
uses: docker/setup-buildx-action@v3
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/test-e2e-provision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ jobs:
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2

- name: Install and configure LXD
run: ./scripts/setup/install-lxd-ci.sh

- name: Install OpenTofu
run: ./scripts/setup/install-opentofu.sh
- name: Install dependencies
run: |
cargo build -p torrust-dependency-installer --bin dependency-installer
cargo run -p torrust-dependency-installer --bin dependency-installer -- install

- name: Verify installations
run: |
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/test-lxd-provision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ jobs:
- name: Tune GitHub-hosted runner network
uses: smorimoto/tune-github-hosted-runner-network@v1

- name: Install and configure LXD
run: ./scripts/setup/install-lxd-ci.sh

- name: Install OpenTofu
run: ./scripts/setup/install-opentofu.sh

- name: Setup Rust toolchain and build template system
uses: dtolnay/rust-toolchain@stable
with:
Expand All @@ -58,6 +52,11 @@ jobs:
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2

- name: Install dependencies
run: |
cargo build -p torrust-dependency-installer --bin dependency-installer
cargo run -p torrust-dependency-installer --bin dependency-installer -- install

- name: Render template configurations
run: |
# Build the template system and render the static templates
Expand Down
143 changes: 64 additions & 79 deletions scripts/setup/README.md
Original file line number Diff line number Diff line change
@@ -1,115 +1,100 @@
# Setup Scripts
# Setup Scripts - MIGRATION NOTICE

This directory contains installation and configuration scripts for the tools required by the Torrust Tracker Deployer project.
**⚠️ This directory has been migrated to the Rust-based dependency installer.**

## Available Scripts
## Migration Notice

### Core Infrastructure Tools
The bash installation scripts (`install-opentofu.sh`, `install-ansible.sh`, `install-lxd-ci.sh`) have been **removed** and replaced with the Rust-based `dependency-installer` binary.

- **`install-opentofu.sh`** - Install OpenTofu (Terraform alternative)
- **`install-ansible.sh`** - Install Ansible automation platform
### New Installation Method

### Container/VM Providers

- **`install-lxd-ci.sh`** - Install and configure LXD (CI-optimized)

## Usage

### Individual Installation
For dependency installation, use the `dependency-installer` binary:

```bash
# Install OpenTofu
./scripts/setup/install-opentofu.sh

# Install Ansible
./scripts/setup/install-ansible.sh
# Install all dependencies
cargo run -p torrust-dependency-installer --bin dependency-installer -- install

# Install LXD (CI environment)
./scripts/setup/install-lxd-ci.sh
```
# Check which dependencies are installed
cargo run -p torrust-dependency-installer --bin dependency-installer -- check

### Batch Installation
# List all available dependencies
cargo run -p torrust-dependency-installer --bin dependency-installer -- list

```bash
# Install all core tools
./scripts/setup/install-opentofu.sh
./scripts/setup/install-ansible.sh
# Install specific dependency
cargo run -p torrust-dependency-installer --bin dependency-installer -- install --dependency opentofu

# Install container provider
./scripts/setup/install-lxd-ci.sh
# See all options
cargo run -p torrust-dependency-installer --bin dependency-installer -- --help
```

## CI vs Local Development

### CI Environment Detection

The scripts automatically detect CI environments and apply appropriate configurations:
### Benefits of the New Approach

- **CI Detection**: Checks for `CI=true`, `GITHUB_ACTIONS=true`, or `RUNNER_USER` environment variables
- **CI Optimizations**: Uses `sudo` commands and socket permission fixes
- **Logging**: Provides clear feedback about environment detection
- **Type-safe**: Rust's type system catches errors at compile time
- **Better error handling**: Clear, actionable error messages
- **Consistent logging**: Structured logging via `tracing` crate
- **Testable**: Unit and integration tests ensure reliability
- **Maintainable**: Single codebase for all dependency management
- **Cross-platform ready**: Foundation for supporting multiple platforms

### Local Development

For local development, see the dedicated documentation:

- **LXD**: [templates/tofu/lxd/README.md](../../templates/tofu/lxd/README.md)
- **LXD Tech Stack**: [docs/tech-stack/lxd.md](../../docs/tech-stack/lxd.md)
### Supported Dependencies

**Important**: The CI scripts use `sudo` commands and socket permission modifications that are **NOT recommended** for local development. Use proper group membership for local setups.
The dependency installer supports:

## Script Features
- **cargo-machete** - Detects unused Rust dependencies
- **OpenTofu** - Infrastructure provisioning tool (Terraform alternative)
- **Ansible** - Configuration management and automation platform
- **LXD** - Lightweight VM manager for container-based testing

### Common Features
### Documentation

- **Idempotent**: Safe to run multiple times
- **Verbose Logging**: Clear progress indicators with colored output
- **Error Handling**: Proper error checking and meaningful messages
- **Version Detection**: Skips installation if tool is already installed
For complete documentation on the dependency installer, see:

### Error Handling

All scripts use `set -euo pipefail` for strict error handling:
- **Package README**: [packages/dependency-installer/README.md](../../packages/dependency-installer/README.md)
- **LXD Setup**: [templates/tofu/lxd/README.md](../../templates/tofu/lxd/README.md)
- **LXD Tech Stack**: [docs/tech-stack/lxd.md](../../docs/tech-stack/lxd.md)

- **`-e`**: Exit on any command failure
- **`-u`**: Exit on undefined variable usage
- **`-o pipefail`**: Exit on pipe command failures
### CI/CD Integration

### Logging Levels
GitHub Actions workflows now use the dependency installer:

- **🟢 INFO**: Normal progress messages
- **🟡 WARN**: Important notices or CI-specific actions
- **🔴 ERROR**: Failure messages
- **`.github/workflows/test-e2e-provision.yml`** - E2E provision and destroy tests
- **`.github/workflows/test-e2e-config.yml`** - E2E configuration tests
- **`.github/workflows/test-lxd-provision.yml`** - LXD provisioning tests

## Integration with Workflows
Example workflow step:

These scripts replace duplicated installation code in GitHub Actions workflows:
```yaml
- name: Install dependencies
run: |
cargo build -p torrust-dependency-installer --bin dependency-installer
cargo run -p torrust-dependency-installer --bin dependency-installer -- install
```

- **`.github/workflows/test-e2e.yml`**
- **`.github/workflows/test-lxd-provision.yml`**
### Local Development

## Troubleshooting
For local development, the dependency installer automatically handles:

### Permission Issues
- **CI Detection**: Automatically applies CI-specific configurations when needed
- **Permissions**: Proper handling of LXD socket permissions
- **Group Membership**: Sets up appropriate user groups

If you encounter permission errors:
**Important**: For local LXD development, follow the proper group membership approach documented in the tech stack guides.

1. **For CI**: Scripts should handle permissions automatically
2. **For Local**: Follow the group membership setup in the tech stack documentation
### Troubleshooting

### Installation Failures
If you encounter issues with the dependency installer:

1. Check internet connectivity for download-based installations
2. Verify system requirements (Ubuntu/Debian for apt-based installs)
3. Check available disk space
4. Review script output for specific error messages
1. **Check installation status**: `cargo run -p torrust-dependency-installer --bin dependency-installer -- check`
2. **Enable debug logging**: Add `--verbose` flag or `--log-level debug`
3. **View available dependencies**: `cargo run -p torrust-dependency-installer --bin dependency-installer -- list`
4. **Check exit codes**: Exit code 0 = success, non-zero = failure

### Tool-Specific Issues
For detailed troubleshooting, see the [dependency installer README](../../packages/dependency-installer/README.md).

- **OpenTofu**: Requires `curl` and package management tools
- **Ansible**: Requires Python and pip (usually pre-installed)
- **LXD**: Requires snap and sufficient privileges
### Migration Timeline

## Future Enhancements
- **Created**: Issue #113 (Create Dependency Installation Package)
- **Migrated**: Issue #119 (Update CI Workflows and Remove Bash Scripts)
- **Removed bash scripts**: November 2025

These bash scripts are designed to be simple and maintainable. For more complex installation logic, they may be replaced by Rust utilities in the future while maintaining the same interface.
This directory is preserved for documentation purposes and may be removed in future versions.
15 changes: 0 additions & 15 deletions scripts/setup/install-ansible.sh

This file was deleted.

33 changes: 0 additions & 33 deletions scripts/setup/install-lxd-ci.sh

This file was deleted.

16 changes: 0 additions & 16 deletions scripts/setup/install-opentofu.sh

This file was deleted.