loading...

Making a Windows Python Application to Manage Linux Ansible

schnipdip profile image schnipdip Updated on ・3 min read

Introduction

Purpose

The purpose of this project is to control a Linux Ansible controller through Windows.

Idea inception

The original idea originated from this trying to automate an IDAM solution called BeyondTrust. BeyondTrust wasn't meant to be automated, so it was a pretty daunting task through Ansible.

Proposed Solution

I wanted to create a solution for dumb users who aren't familiar with the Linux environment and for those who aren't familiar with Ansible. I wanted to create a Windows solution, since most people are familiar with Windows and know how to double-click an executable.

Why Python?

Libraries

One of the main reasons I love using Python is for their extensive library selection. I know that if I have thought of something I want, someone has most likely already found a solution.

The libraries I am using are located below:


import tkinter
import configparser
import sys
import logging
import paramiko
import os

Previous knowledge (familiarity)

I often think it's important to use something you are familiar with. There may be a better tool that does more and has more bells-and-whistles. However, it's important to stick with what you know, especially in a time sensitive situation. I could have easily learned a better language for application development. I'm sure there are better systems out there that are more efficient, require less code, consume less resources, etc. It was important for me to stick to my guns, Pythons. One of the requirements I self-imposed was a 3 week deadline. I felt 2 weeks was too fast and 4 weeks prolongs it and promotes procrastination. I wanted to avoid both situations; I felt that 3 weeks was a good medium. Being able to resort to Python, knowing that whatever I encounter Python has an answer.

Python also has an extremely large community. From what I have seen on Reddit and Stackoverflow, much more helpful too ;)

Resources Used

Hosting and Collaboration Tools

I will be utilizing AWS cloud services to help accomplish this project.

  • AWS EC2
  • AWS Cloud9

For code management and versioning I set up a Github private repository.

Getting Help

So I knew I couldn't accomplish this project on my own within the time frame I set. So I crowdsourced for help. Two other people are working on this project with me. I don't know them, but I have to give them proper credit because without their help this project would never have gotten done.

Python IDE (KISS)

The IDE I chose to work with is the Python IDE. I like to follow a simple philosophy - Keep It Simple Stupid (KISS). Keeping my working environment as bare bones as possible allows me to learn and understand what I am doing more, because I am at the wheel. It's like driving a manual compared to an automatic. Both are great and have their benefits, choose what fits you.

I remember being made fun of by my college professors in my Java 101 class for using JGRASP, jokes on them - I got a B.

Concept Design and Thoughts

The first design was based around the BeyondTrust stack. It was intended to just call an Ansible playbook based on the selections made.

Alt Text

This design would work really well for a single product deployment. The problem is that it doesn't follow any good dynamic design principles. It's extremely linear and doesn't allow for expandability.

The next design concept takes all of that BeyondTrust stuff and chucks it out the window. Instead of focusing on one product, why not allow the user to execute any playbook the way they wanted to using Linux syntax?

This is where I believe the final iteration of the product will end up. This design allows the product to be more dynamic and not locking it into a single use case.

Sharing Code

Creating an Ansible Hosts file based on system type and service. Note: this isn't final, but it provides a general understanding on how to create a more dynamic inventory based on the service you want to the target hosts.

Alt Text
Alt Text

Reminder

I want to remind everyone this project is still in progress. I am looking for help if anyone would like to contribute.

Discussion

pic
Editor guide