MAASTA is a wrapper to create an Ansible inventory for MAAS instances that are provisioned by Terraform.

Overview

MAASTA (MAAS Terraform Ansible)

Visits Badge GitHub last commit GitHub license GitHub stars GitHub forks GitHub issues

Twitter LinkedIn

Stargaze GitHub Repo stars if you find it useful.

MAASTA is a wrapper to create an Ansible inventory for MAAS instances that are provisioned by Terraform.

This script is used to build an end to end automation DevOps lifecycle.

What is MAAS?

MAAS (Metal as a Service) is a tool to turns real servers into bare-metal cloud. With MAAS, you can automate server provisioning and installing OS remotely on both physical and virtual servers. MAAS.io for more information.

What is Terraform?

Terraform is an infrastructure as code tool which is used originally for provisioning cloud instances on various cloud providers. With Terraform and the aid of the IaC, we can provision machines and cloud instances with codes and without direct human interactions. Terraform is responsible for provisioning systems, usually Immutable ones. Terraform.io for more information.

What is Ansible?

Ansible is another IaC tool but for configuration management. With the aid of Ansible, we can configure a multitude of systems without direct human interactions. Ansible is responsible for configuring existing systems, usually mutable ones. Ansible.com for more information.

Why do we need MAASTA?

Imagine you want to create the DevOps lifecycle for your on-premises infrastructure. In such a scenario, You need the MAAS to interact with your real infrastructure and bring your bare-metal or virtual machines into cloud-like infrastructure. After that, to achieve automation, you need the Terraform tool to interact with the MAAS to provisioning instances and managing them without direct human interactions. When the instances, machines, were provisioned by the Terraform, the time to configuring them comes. For configuring instances, you need the Ansible tool, but how Ansible can discover targets that are provisioned by the Terraform. The answer is MAASTA! MAASTA is used to discover Terraform provisioned MAAS instances and create an Ansible inventory file for them. With the aid of the MAASTA, you can create an end to end automation and integrate MAAS, Terraform, and Ansible together.

See /examples/README.md to get started with brief examples.

Get started guide:

MAASTA accepts two environment variables, MAAS_API_URL and MAAS_API_KEY, and reads the output of the terraform show -json command from stdin. The output of the Terraform is used to find the MAAS machines that are provisioned by the Terraform. MAASTA connects to the MAAS server and reads information (fqdn, hostname, ipaddr) of machines and creates an Ansible inventory for them. The inventory will write into inventory.yaml file.

Installation:

pip install git+https://github.com/ssbostan/maasta.git

Usage:

terraform show -json | python -m maasta

How to contribute:

Currently, MAASTA can create inventory for machines that are provisioned with Ubuntu distribution. The script is tested with minimum viable tests and may break in some situations.

Don't hesitate to contribute. In the case of a bug, please file an issue.

Copyright 2021 Saeid Bostandoust [email protected]

You might also like...
DevSecOps pipeline for Python based web app using Jenkins, Ansible, AWS, and open-source security tools and checks.
DevSecOps pipeline for Python based web app using Jenkins, Ansible, AWS, and open-source security tools and checks.

DevSecOps pipeline for Python Web App A Jenkins end-to-end DevSecOps pipeline for Python web application, hosted on AWS Ubuntu 20.04 Note: This projec

πŸš€ An asynchronous python API wrapper meant to replace discord.py - Snappy discord api wrapper written with aiohttp & websockets

Pincer An asynchronous python API wrapper meant to replace discord.py ❗ The package is currently within the planning phase πŸ“Œ Links |Join the discord

A wrapper for slurm especially on Taiwania2 (HPC CLI)A wrapper for slurm especially on Taiwania2 (HPC CLI)

TWCC-slurm-wrapper A wrapper for slurm especially on Taiwania2 (HPC CLI). For Taiwania2 (HPC CLI) usage, please refer to here. (δΈ­ζ–‡) How to Install? gi

Discord-Wrapper - Discord Websocket Wrapper in python

This does not currently work and is in development Discord Websocket Wrapper in

Aws-lambda-requests-wrapper - Request/Response wrapper for AWS Lambda with API Gateway

AWS Lambda Requests Wrapper Request/Response wrapper for AWS Lambda with API Gat

Use GitHub Actions to create a serverless service.

ActionServerless - Use GitHub Actions to create a serverless service ActionServerless is an action to do some computing and then generate a string/JSO

Attempting to create a framework for Discord Slash commands... yes

discord_slash.py Attempting to create a framework for Discord Slash commands... yes Installation pip install slashpy Documentation Coming soonβ„’ Why is

Create Multiple CF entry for multiple websites

AWS-CloudFront Problem: Deploy multiple CloudFront for account with multiple domains. Functionality: Running this script in loop and deploy CloudFront

Create a Neo4J graph of users and roles trust policies within an AWS Organization.
Create a Neo4J graph of users and roles trust policies within an AWS Organization.

AWS_ORG_MAPPER This tool uses sso-oidc to authenticate to the AWS organization. Once authenticated the tool will attempt to enumerate all users and ro

Comments
  • Adding MaaS Cloud_Init script to MaaSTA

    Adding MaaS Cloud_Init script to MaaSTA

    Hello there, first pf all thank you for making such a great tool. I was wondering how do I apply my own cloud_init script to the maasta wrapper so that when MaaS deploys the commissioned node it will apply the cloud_init script?

    I installed python 3.8 on Ubuntu 22.04LTS so that I can try this wrapper but I am currently receiving these errors on my node.

    (venv) ryzengrind@shogun:~/Documents/Workspaces/ClusterLab/ansible-playbooks/maasta/examples/single$ ./deploy 
    
    Initializing the backend...
    
    Initializing provider plugins...
    - Reusing previous version of suchpuppet/maas from the dependency lock file
    - Using previously-installed suchpuppet/maas v3.1.3
    
    Terraform has been successfully initialized!
    
    You may now begin working with Terraform. Try running "terraform plan" to see
    any changes that are required for your infrastructure. All Terraform commands
    should now work.
    
    If you ever set or change modules or backend configuration for Terraform,
    rerun this command to reinitialize your working directory. If you forget, other
    commands will detect it and remind you to do so if necessary.
    maas_instance.docker: Refreshing state... [id=gafn6t]
    
    Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
    -/+ destroy and then create replacement
    
    Terraform will perform the following actions:
    
      # maas_instance.docker is tainted, so must be replaced
    -/+ resource "maas_instance" "docker" {
          ~ id                   = "gafn6t" -> (known after apply)
            # (5 unchanged attributes hidden)
        }
    
    Plan: 1 to add, 0 to change, 1 to destroy.
    
    ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    
    Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now.
    maas_instance.docker: Refreshing state... [id=gafn6t]
    
    Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
    -/+ destroy and then create replacement
    
    Terraform will perform the following actions:
    
      # maas_instance.docker is tainted, so must be replaced
    -/+ resource "maas_instance" "docker" {
          ~ id                   = "gafn6t" -> (known after apply)
            # (5 unchanged attributes hidden)
        }
    
    Plan: 1 to add, 0 to change, 1 to destroy.
    maas_instance.docker: Destroying... [id=gafn6t]
    maas_instance.docker: Still destroying... [id=gafn6t, 10s elapsed]
    maas_instance.docker: Destruction complete after 12s
    maas_instance.docker: Creating...
    maas_instance.docker: Still creating... [10s elapsed]
    maas_instance.docker: Still creating... [20s elapsed]
    maas_instance.docker: Still creating... [30s elapsed]
    maas_instance.docker: Still creating... [40s elapsed]
    maas_instance.docker: Still creating... [50s elapsed]
    maas_instance.docker: Still creating... [1m0s elapsed]
    maas_instance.docker: Still creating... [1m10s elapsed]
    maas_instance.docker: Still creating... [1m20s elapsed]
    maas_instance.docker: Still creating... [1m30s elapsed]
    maas_instance.docker: Still creating... [1m40s elapsed]
    maas_instance.docker: Still creating... [1m50s elapsed]
    maas_instance.docker: Still creating... [2m0s elapsed]
    maas_instance.docker: Still creating... [2m10s elapsed]
    maas_instance.docker: Still creating... [2m20s elapsed]
    maas_instance.docker: Still creating... [2m30s elapsed]
    maas_instance.docker: Still creating... [2m40s elapsed]
    maas_instance.docker: Still creating... [2m50s elapsed]
    maas_instance.docker: Still creating... [3m0s elapsed]
    maas_instance.docker: Still creating... [3m10s elapsed]
    maas_instance.docker: Still creating... [3m20s elapsed]
    maas_instance.docker: Still creating... [3m30s elapsed]
    maas_instance.docker: Still creating... [3m40s elapsed]
    maas_instance.docker: Still creating... [3m50s elapsed]
    maas_instance.docker: Still creating... [4m0s elapsed]
    β•·
    β”‚ Error: [ERROR] [resourceMAASInstanceCreate] Error waiting for instance (gafn6t) to become deployed: %!s(<nil>)
    β”‚ 
    β”‚   with maas_instance.docker,
    β”‚   on main.tf line 25, in resource "maas_instance" "docker":
    β”‚   25: resource "maas_instance" "docker" {
    β”‚ 
    β•΅
    INFO: Ansible inventory created successfully.
    
    PLAY [docker] ********************************************************************************************************************************************************************
    
    TASK [Gathering Facts] ***********************************************************************************************************************************************************
    fatal: [moved-gull.maas]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.20.235 port 22: Connection timed out", "unreachable": true}
    
    PLAY RECAP ***********************************************************************************************************************************************************************
    moved-gull.maas            : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0 
    

    Kindly advise.

    opened by RyzeNGrind 2
  • Publishing in PyPI?

    Publishing in PyPI?

    Hi Saied,

    First and foremost, thank you for publishing this code. At our company we are looking for better ways to automate infra provisioning, and we bumped into your article about MAASTA and from there into this repo.

    I see you are not publishing this package in PyPI. Any specific reason for that? Any chance we are going to see that happening? Thanks!

    Cheers

    opened by russoz 2
  • adding ini inventory file feature

    adding ini inventory file feature

    change maasta.py and utils.py in order to add ini inventory output.

    it's checked several times with single and multi terraform state and it's been ok.

    opened by hosein-yousefii 1
Owner
Saeid Bostandoust
DevOps Engineer
Saeid Bostandoust
Terraform Cloud CLI for Managing Workspace Terraform Versions

Terraform Cloud Version Manager This tiny script makes it easy to update the Terraform Version on all of the Workspaces inside Terraform Cloud. It wil

Robert Hafner 1 Jan 7, 2022
Create a roles overview page for all Ansible roles/playbooks in Gitlab

ansible-create-roles-overview Overview The script ./create_roles_overview.py queries a Gitlab API for Ansible roles and playbooks. It will iterate ove

null 2 Oct 11, 2021
Use CSV files as a Nornir Inventory source with hosts, groups and defaults.

nornir_csv Use CSV files as a Nornir Inventory source with hosts, groups and defaults. This can be used as an equivalent to the Simple Inventory plugi

Matheus Augusto da Silva 2 Aug 13, 2022
tfquery: Run SQL queries on your Terraform infrastructure. Query resources and analyze its configuration using a SQL-powered framework.

??️ tfquery ??️ Run SQL queries on your Terraform infrastructure. Ask questions that are hard to answer ?? What is tfquery? tfquery is a framework tha

Mazin Ahmed 311 Dec 21, 2022
Cookies is a project inspired by python cookiecutter but used for terraform generation.

Introduction Cookies is a project inspired by python cookiecutter but used for terraform generation. How to run your terraform After you download your

Digger 6 Mar 14, 2022
Terraform module to ship CloudTrail logs stored in a S3 bucket into a Kinesis stream for further processing and real-time analysis.

AWS infrastructure to ship CloudTrail logs from S3 to Kinesis This repository contains a Terraform module to ship CloudTrail logs stored in a S3 bucke

Nexthink 8 Sep 20, 2022
Python binding for Terraform.

Python libterraform Python binding for Terraform. Installation $ pip install libterraform NOTE Please install version 0.3.1 or above, which solves the

Prodesire 28 Dec 29, 2022
A python script to acquire multiple aws ec2 instances in a forensically sound-ish way

acquire_ec2.py The script acquire_ec2.py is used to automatically acquire AWS EC2 instances. The script needs to be run on an EC2 instance in the same

Deutsche Telekom Security GmbH 31 Sep 10, 2022
Fully Dockerized cryptocurrencies Trading Bot, based on Freqtrade engine. Multi instances.

Cryptocurrencies Trading Bot - Freqtrade Manager This automated Trading Bot is based on the amazing Freqtrade one. It allows you to manage many Freqtr

CΓ©dric Dugat 47 Dec 6, 2022
Check AWS S3 instances for read/write/delete access

s3sec Test AWS S3 buckets for read/write/delete access This tool was developed to quickly test a list of s3 buckets for public read, write and delete

0xmoot 114 Dec 6, 2022