SSH Bastion Provisioning

Star 0
Version 1.4.1
SSH Bastion Provisioning
Maintainers
support[at]europeanweather.cloud
License
Support level
EWC
Category
Remote Access & Desktop Compute
Technology
Ansible Playbook Terraform Module

SSH Bastion Provisioning

✅ This template can be safely applied from any local work environment, even running outside an EWC tenancy's private network.

The SSH proxy or bastion server is a barrier between your internal machines (without public or floating IPs) and the public internet. With the SSH proxy, you'll have an extra layer of security on top of your instances. It's equipped with Fail2ban, intrusion prevention software designed to prevent brute-force attacks.

This is a configuration template (i.e. an Ansible Playbook) to customize your environment in the European Weather Cloud (EWC).

Functionality

The template is designed to:

  • Provision an instance via Terraform, with your specified Linux distribution and desired flavor (a.k.a VM plan):
    • If a terraform.tfstate state file is not found under the user-defined directory, attempts to create the instance from scratch

      OR

    • If terraform.tfstate file is found, leverages Terraform's out-of-the-box functionality to update the instance referenced on it

  • Configure the existing or newly provisioned RockyLinux virtual machines (with public IP address), as entrypoint for users who wish to reach private EWC networks from the public internet via SSH.

After successful provisioning, you can leverage Terraform's functionality to modify or delete individual components safely. Each will have its own main.tf definition and terraform.tfstate state file under the corresponding user-defined local directories.

To learn the basics about managing infrastructure with Terraform, check out Terraform in 100 seconds on YouTube. You can also find a step-by-step example applied to the EWC on the official EWC documentation.

Prerequisites

Usage

1. Clone the repository

git clone https://github.com/ewcloud/ewc-ansible-playbook-flavours-and-provisioning.git

1.1. Change to the specific Item's subdirectory

cd ewc-ansible-playbook-flavours-and-provisioning/playbooks/ssh-bastion-provisioning

1.2. (Optional) Checkout an specific Item's version

⚠️ Make sure to replace x.y.z in the command below, with your version of preference.

git checkout x.y.z

2. Download Ansible dependencies

💡 By default, Ansible Roles are installed under the ~/.ansible/roles directory within your working environment.

Download the correct version of the Ansible dependencies, if you haven't done so already:

ansible-galaxy role install -r requirements.yml

3. Configure and apply the template

3.1. Interactive Mode

By running the following command, you can trigger an interactive session that prompts you for the necessary user inputs, and then applies changes to your target EWC environment:

ansible-playbook ssh-bastion-provisioning.yml

3.2. Non-Interactive Mode

💡 To learn more about defining variables at runtime, checkout the official Ansible documentation.

You can also run in non-interactive mode by passing the --extra-vars or -e flag, followed by a map of key-value pairs; one for each and every available input (see inputs section below). For example:

ansible-playbook \
  -e '{
        "ewc_provider":"eumetsat",
        "ssh_bastion_tf_project_path":"~/ewc/ssh-bastion-1",
        "ssh_bastion_app_name":"ssh",
        "ssh_bastion_instance_name":"bastion",
        "ssh_bastion_instance_index":1,
        "ssh_bastion_flavor_name":"eo1.large",
        "ssh_bastion_image_name":"Rocky-9.5-20250604142417",
        "public_keypair_name":"my-public-key-name",
        "private_keypair_path":"~/.ssh/id_rsa",
        "private_network_name":"private",
        "security_group_name":"ssh",
        "fail2ban_whitelisted_ip_ranges":""
    }' \
  ssh-bastion-provisioning.yml

Inputs

Name Description Type Default Required
ewc_provider your target EWC provider. Must match that the provider of your OpenStack application credentials. Valid input values are ecmwf or eumetsat. string eumetsat yes
ssh_bastion_tf_project_path path to terraform working directory string ~/ewc/ssh-bastion-1 yes
ssh_bastion_app_name application name, used as prefix in the full instance name string ssh yes
ssh_bastion_instance_name name of the instance, used in the full instance name string bastion yes
ssh_bastion_instance_index index or identifier for the instance, used as suffix in the full instance name number 1 yes
ssh_bastion_flavor_name name the flavor to use for the instance. To learn about available options, checkout the official EWC VM plans documentation. 💡 A VM plan with at least 4GB of RAM is recommended for successful setup and stable operation. string eo1.large yes
ssh_bastion_image_name name of the image to use for the instance. For complete information on available options, see the official EWC Images documentation. ⚠️ Only RockyLinux 9.5 and RockyLinux 8.10 instances are currently supported due to constrains imposed by the required ewc-ansible-role-ssh-bastion Ansible Role string Rocky-9.5-20250604142417 yes
public_keypair_name name of public keypair (stored in OpenStack) to be copied into the instance for remote SSH access string n/a yes
private_keypair_name path to the local private keypair to use for SSH access to the instance string ~/.ssh/id_rsa yes
private_network_name private network name to attach the instance to string private yes
security_group_name security group name to apply to the instance string ssh yes
fail2ban_whitelisted_ip_ranges IPv4 ranges (in CIDR format) to be whitelisted in Fail2ban configuration. Example: ['10.0.0.0/24','192.168.1.0/24'] list(string) '' no

Dependencies

⚠️ Only RockyLinux 9.5 and RockyLinux 8.10 instances are currently supported due to constrains imposed by the required ewc-ansible-role-ssh-bastion Ansible Role.

💡 A VM plan with at least 4GB of RAM is recommended for successful setup and stable operation.

Name Version License Home URL
ewc-tf-module-openstack-compute 1.0 MIT https://github.com/ewcloud/ewc-tf-module-openstack-compute
ewc-ansible-role-ssh-bastion 1.4 MIT https://github.com/ewcloud/ewc-ansible-role-ssh-bastion
Other
Deployable