<!-- Source: https://docs.squirro.com/en/latest/getting/install/ansible/quickstart-examples.html -->
# Ansible Quickstart Examples

This section contains examples for how to set up a Squirro installation using Ansible. Please refer to the full documentation at [Install and Manage Squirro with Ansible](index.md#ansible) for more information.

## Basic Setup

If you’re looking for a quick single server setup of the latest Squirro release, follow the steps below.

1. Secure a Rocky Linux or Red Hat Enterprise Linux server. Squirro recommends [AWS](../../../a-z/industry-glossary.md#term-AWS), [GCP](../../../a-z/industry-glossary.md#term-GCP), Azure, Hetzner Cloud, or any physical server.

   For development, Vagrant is a great choice, but any [VM](../../../a-z/industry-glossary.md#term-VM) solution such as VirtualBox, Proxmox, VMware Workstation/Fusion/Player, etc. will work.
2. Ensure your setup meets the requirements detailed in [System Requirements](../system-requirements.md#install-system-requirements).
3. Log in to the server and become root.
4. Install Ansible.

   On supported versions of RHEL and Rocky Linux, `ansible-core` is available in the standard AppStream repository. For supported versions, see the [System Requirements](../system-requirements.md#install-system-requirements) page. Run:

   ```console
   yum install -y ansible-core
   ansible-galaxy collection install community.general
   ansible-galaxy collection install ansible.posix
   ```

   The `ansible-galaxy` commands require an internet connection to reach `galaxy.ansible.com`. For air-gapped environments, download the collection archives on a machine with internet access, transfer them to the server, then install them locally:

   ```console
   ansible-galaxy collection download community.general
   ansible-galaxy collection download ansible.posix
   ansible-galaxy collection install community-general-<version>.tar.gz
   ansible-galaxy collection install ansible-posix-<version>.tar.gz
   ```

   > **Note**
   >
   > Ansible is a Python application and can also be installed using pip.
5. Go to [mirror.squirro.net/ansible/](https://mirror.squirro.net/ansible/) and download the Squirro Ansible ZIP file with the highest version number (for example, `squirro-ansible-3.16.0.zip`). Then unzip it using the following command:

   ```console
   unzip squirro-ansible-x.x.x.zip
   ```

   Replace `x.x.x` with the version number of the downloaded file.
6. Edit `playbook-quickstart.yml` to and edit the yum username and password to match your Squirro mirror username and password.

   Example code shown below:

   ```yaml
   - name: Quickstart Install Squirro
     hosts: all
     become: true
     vars:
        squirro_clusternode: True
        squirro_storagenode: True
        yum_user: ...
        yum_password: ...
        squirro_channel: stable
        squirro_version: latest
        elasticsearch_discovery_type: single-node
     roles:
        - role: squirro-ansible
   ```
7. Install Squirro using the following command:

   ```console
   ansible-playbook --connection=local --inventory 127.0.0.1, playbook-quickstart.yml
   ```

   Depending on your system, the installation can take 15 to 20 minutes.
8. Open the HTTP and HTTPS port on the firewall as shown below:

   ```console
   firewall-cmd --zone=public --permanent --add-service=http
   firewall-cmd --zone=public --permanent --add-service=https
   firewall-cmd --reload
   ```
9. Validate if all services are running using the following command:

   ```console
   squirro_status
   ```
10. Access the service at `https://your-sytems-ip` or `http://your-systems-ip`.

## Offline Installation

If your machine cannot reach mirror.squirro.net, you can install Squirro offline as shown below:

```yaml
- name: Offline Squirro
  hosts: all
  become: true
  vars:
      squirro_clusternode: True
      squirro_storagenode: True
      squirro_install_mode: offline
      squirro_packages_tar: /path/to/os-n.n-stable-x86_64-n.n.n.tar.gz
      squirro_channel: stable
      squirro_version: latest
      elasticsearch_discovery_type: single-node

  roles:
      - role: squirro-ansible
```

The corresponding `tar.gz` file can be downloaded from the mirror.

Example: For Rocky Linux 8, you can get the correct package from: `https://mirror.squirro.net/rocky/8/stable/x86_64/`.

If you expect to run multiple installations, you can speed things up by extracting the `tar.gz` file and placing it on a shared file system, as shown below:

```yaml
- name: Offline Squirro
  hosts: all
  become: true
  vars:
      squirro_clusternode: True
      squirro_storagenode: True
      squirro_install_mode: filesystem
      yum_repo_folder: /path/to/offline/yum/repo
      squirro_channel: stable
      squirro_version: latest
      elasticsearch_discovery_type: single-node
  roles:
      - role: squirro-ansible
```

This can be faster as the unzipping will not take place each time.

Note: The `yum_repo_folder` variable needs to point at the location that contains the `repodata` folder.

## AWS Standalone Playbook

Expanding on the quickstart example, on Amazon Web Services, when deploying Squirro, it is best practice to leverage managed services to increase availability and enable horizontal scaling.

In the example below, the following are leveraged:

- RDS to externalize MariaDB / MySQL
- ElastiCache to externalize the Key/Value Store
- ElastiCache again to externalize the In-Memory Cache
- EFS as a shared file system

These resources can be spun up manually in the AWS web console.

Important: Squirro highly recommends you leverage infrastructure automation solutions such as AWS CloudFormation or [Terraform](https://www.terraform.io/).

Once complete, edit the `playbook-quickstart-aws.yml` file to fill in all the blanks and adjust the RDS and ElastiCache endpoints, credentials, and IP addresses.

```yaml
- name: Quickstart Install Squirro on AWS
  hosts: all
  become: true
  vars:
      squirro_clusternode: True
      squirro_storagenode: True
      yum_user: ...
      yum_password: ...
      squirro_channel: stable
      squirro_version: latest
      elasticsearch_squirro_cluster_name: squirro-quickstart
      elasticsearch_cluster_nodes: ['10.1.0.2', '10.1.0.3', '...']
      elasticsearch_network_interface: eth0
      remote_mysql_server: True
      mysql_host: yourproject-db.abcdefghij.eu-central-1.rds.amazonaws.com
      mysql_root_user: root
      mysql_root_password: ...
      mysql_shared_service_password: ...
      remote_redis_server: True
      redis_tls: True
      redis_storage_host: master.storage-abcdefgh.euc1.cache.amazonaws.com
      redis_storage_port: 6379
      redis_storage_password: ...
      redis_cache_host: master.storage-abcdefgh.euc1.cache.amazonaws.com
      redis_cache_port: 6380
      redis_cache_password: ...
      remote_filesystem: True
      remote_filesystem_path: /mnt/efs/squirro
  roles:
      - role: squirro-ansible
```

You then run the same steps as under the _Quickstart_ section to install Ansible, but instead run this command to execute the install:

```console
ansible-playbook --connection=local --inventory 127.0.0.1, playbook-quickstart-aws.yml
```

You can now repeat this on each EC2 instance.

Tip: For production deployments, Squirro typically recommends at least three instances.

This procedure can be fully automated with Cloud-init user data methods to bootstrap new instances or even to build [AMI](../../../a-z/industry-glossary.md#term-AMI) images using frameworks such as Packer.

> **Caution**
>
> This only serves as an example, for full production readiness you will need to delegate the secrets to a secrets manager (e.g. Hashicorp Vault) and also leverage the AWS EC2 discovery plugin for Elasticsearch.

## Next Steps

After the installation completes, create the first administrator, turn off open sign-up, and finish the required configuration. For the full list of steps, see the [Post-Installation Checklist](../post-installation-checklist.md#install-post-installation-checklist) page.
