Checking your snail mail with Python/Docker and Slack. (Part 2)

Packaging Python scripts with Docker

In Part 1 of this post I covered the creation of the initial MyUsps notification script. There’s quite a few dependencies in the environment required for running this script. At a bare minimum you will need a functional Linux or Windows environment with the following dependencies

There’s some challenges getting all of these things to work well together. It’s also very difficult to keep all of these applications in sync and distribute a working installation script to allow users to clone your environment.

Enter Docker. Continue reading “Checking your snail mail with Python/Docker and Slack. (Part 2)”

Checking your snail mail with Python/Docker and Slack. (Part 1)

Background

Recently I became aware of a service for USPS called “Informed Delivery”. This service will allow you to view mail items coming to your physical mailbox before they arrive, as well as a get an email with the same information.

This is a very cool service but unfortunately there is no way to get push notifications about this information, or have any kind of notification at all besides a email that doesn’t allow for any customization, or even show all of your mail items. There are apps for various platforms, but they are simple webkit wrappers around the USPS website and have fairly terrible reviews.

Obviously we are going to need to automate this. I decided to use python to automate grabbing this information and making it more useful. Continue reading “Checking your snail mail with Python/Docker and Slack. (Part 1)”

Mass create VMWare Guests with PowerCLI

Need to create a bunch of VM’s at once in your VMWare vSphere environment? You can use the below script to do so. Just fill in the blanks in the $vmlist variable (A hash table in this case) to define the IP of the machine in question, as well as a corresponding name value. You will also want to modify the other values to fit your environment. Before running this you will also need to create a template VM to base your clone on, as well as creating a customization template.

Continue reading “Mass create VMWare Guests with PowerCLI”

Creating a portable VMWare Autodeploy instance on vCenter 6.5 appliance with PowerCLI

Autodeploy is a great tool that is integrated with VMWare vCenter and is available for your use if you have the proper licensing levels. There are a few ways to utilize Autodeploy, and this guide will focus on using the “stateful” (Install to disk) deployment method.

I’ve put together the steps needed to deploy this service in a UEFI based PXE-boot environment. The initial boot configuration steps are specifically written to work with Dell Servers and the IDRAC tool CLI. The boot order commands below will place your SD’s cards at the beginning of the boot sequence.

I should note that this method requires no modification of the customer environment (Including DHCP options), and is completely portable (no installs).

Update the boot order on your hosts to allow PXE booting to take second place. (SSH to IDRAC IP of each host to enter console commands below)

 

Enable AutoDeploy Services on vCenter

  • In the web interface navigate to Home > Administration > System Configuration > Nodes > vCenter Server > Related Objects and start “Auto Deploy”

 

Download and run Tiny PXE server

  • Copy TFTP Files from vCenter to TFTP Server file root
  • Set boot file name below depending on type of device (UEFI vs Bios mode)

 

This PXE server is fairly unique in the sense that it offers a “DCHP Proxy” option.  This allows you to temporarily deploy this server and intercept DHCP requests, adding on only the options you need (Option 66 and 67). There’s great detail on this functionality here

Upload ESXI image to software depot in vCenter (use vendor image zip file)

 

Create minimal host profile.

This host profile can come from an existing host, or a new host you deploy with a blank profile.

  • Set “stateful install to usb” option in your host profile that was previously created. This is This can be found under “Advanced Configuration Settings > System Image Cache Configuration” in the vCenter Web Interface.

  • Set Root Password (otherwise no password is set). This is found under “Security Configuration > Administrator Password” in the vCenter Web Interface.

Set deploy rules in Autodeploy to match hosts and apply host profile previously created

Enable new AutoDeploy Rule

 

 

If client environment contains WDS (Windows Deployment Services) – Set PXE Delay to allow for DHCP options override from our temporary PXE server

Hosts will show up in vCenter when the deployment process is complete.

A complete script combining the commands above will be posted here when completed.

 

Using Curator to prune Elasticsearch Indices

If you are using Elasticsearch as a database to store data from various sources, you are going to need to a way to prune the indices before they end up filling your drive. Using Curator is one way to go about this task.

The following instructions are based on a Ubuntu LTS 16.04 install with Elasticsearch 5.6 locally installed on the same machine.

  • First, Add the source to your apt repository list –

  • Update your package listing and install the curator package

The Curator application uses the popular YAML format as a basis for it’s configuration files. We will need to create two files at a minimum to get going.

  • First, create a blank file for the base configuration –

Paste in the following basic configuration (Assuming your Elasticsearch sever is on the same machine as curator)

Then, create another “action file” that holds the action we want to run. Here, I’m using a slightly modified action from an example that will delete any indice older than 30 days that starts with “netflow-“. Modify this file to suit your needs. We will call it “delete_indices.yml”

Contents of file

We can then run the configuration file with the –dry-run parameter to simulate the actions taken. Remove –dry-run when you are ready to run it for real!

To run this on a schedule, simply add it to crontab. This will run it daily at midnight. Open your crontab with

Add these lines –