How to deploy Fuga Cloud infrastructure with Ansible


The possibilities with Ansible are endless. In this tutorial, we will teach you how to deploy your Fuga Cloud infrastructure automatically with Ansible.

Note: This tutorial is tested with Ansible 2.7.9 and Ubuntu 18.04 LTS. If your running the latest ansible version and experience any problems with this tutorial, please contact us.


Fuga Cloud account


  1. Install ansible and shade with pip3:

    sudo apt update
    sudo apt install python3-pip
    sudo pip3 install ansible
    sudo pip3 install shade
  2. Create a new folder called ansible somewhere on your system, this will contain all our files for this tutorial.

    mkdir ansible
  3. Copy or cut your OpenRC file into the new ansible folder.

  4. Open the ansible folder with the following command:

    cd ansible
  5. To give your Ansible playbook file access to your Fuga Account, enter the following command:

    source ./YOUR_OPENRC_FILE.SH
  6. When asked for your OpenStack password, enter your Fuga Cloud password

Deploying infrastructure in Fuga Cloud

  1. Start by creating a new Ansible playbook file in the ansible folder:

    touch provision_infra.yml
  2. Edit the provision_infra.yml (nano provision_infra.yml) and paste in the following code:

- name: Deploy OpenStack
hosts: localhost
gather_facts: false
- name: Create network
state: present
name: my_network
external: False
shared: False
register: my_network

- name: Create subnet
state: present
network_name: "{{ }}"
name: my_subnet
ip_version: 4
enable_dhcp: yes
register: my_subnet

- name: Create router
ignore_errors: yes
state: present
name: my_router
network: public
- my_subnet

- name: Create new example Security group for HTTP
state: present
name: example_group
description: security group for web servers

- name: Add example HTTP rule to security group
security_group: example_group
port_range_min: 80
port_range_max: 80
protocol: tcp

- name: Create volume for instance
state: present
size: 100
display_name: my_volume

- name: Deploy an instance
name: my_instance
state: present
image: Ubuntu 18.04 LTS
wait: yes
flavor: c3.small
auto_ip: yes
network: my_network
- default
- example_group
register: my_instance

- name: Attach volume to instance
state: present
server: my_instance
volume: my_volume
device: /dev/vdb

- name: Add VM to inventory
name: new_vm
groups: fuga_vms
ansible_host: "{{ my_instance.server.public_v4 }}"

- name: Adding host to fuga_hosts file
src: hosts_template.j2
dest: "fuga_hosts" 
  1. By default a volume of 100 GB is created, you can change this to any size within your Fuga quota limit. Search for the task Create volume for instance and update the size field.

  2. In the task Deploy an instance we have to update our SSH YOUR_SSH_KEY_NAME. This should be the name of your SSH key on the Fuga dashboard.

  3. It’s also possible to change the flavor of your instance. The default is a c3.small but this can be changed to anything within your limits. Search for the task Deploy an instance and update the flavor field.

  4. All the naming begins with my_. You can change them to your own preferences.

  5. Save the provision_infra.yml file.

  6. Create a new file that will be the template for our Ansible inventory. Execute the following command inside the ansible directory:

    touch hosts_template.j2
  7. Copy paste the following code inside hosts_template.j2 (nano hosts_template.j2) using your favorite text editor:

    ansible_python_interpreter=/usr/bin/env python3

    {{ my_instance.server.public_v4 }} 
  8. Save the file and exit your editor.

  9. You’re now ready to roll out your new infrastructure. To run this playbook file execute the following command:

    ansible-playbook provision_infra.yml
  10. When the Playbook is done deploying, a host has been added to your fuga_hosts file.


You now know how to deploy a basic infrastructure on Fuga Cloud using Ansible. The playbook used in this tutorial can be expanded to your liking.