Nov
20
2017
0

Ansible: How to automate past “Initial setup of CentOS Linux 7” message

 

I recently came across an annoying issue with CentOS 7 setup.  I started with a minimal install, completed my installation(including mate desktop) and rebooted.  When I attached to the console of the newly minted VM I discovered it was stuck at a license prompt.  To avoid this issue…

(more…)

Oct
15
2017
0

Ansible: How to set user passwords

 

I’m in the process of converting my Fabric PBX automated installation to an Ansible playbook, but I got stuck on the user module portion.  I want to pass a default password to user accounts.  Ansible’s user module requires the crypted SHA512 hash rather than taking a password.  In other words, instead of supplying a password, you must supply the key(or as they call it a “crypted value”).

I think requiring the “crypted value” is for security reasons, but I imagine if someone has access to the key they can brute force the password anyways.  Sometimes secure and inconvenient mean the same thing I guess!  In any case, the user module should itself generate the key or they should build the feature into ansible-vault.

I stumbled on the instructions provided on the Ansible website.   There were no clear examples of setting a default password on the Ansible user module page.  You would think that would be an obvious one.  There is a link to directions on the Ansible cryption FAQ suggest using ‘mkpasswd’.  However, on the system I use(Fedora 24) the command doesn’t have the ability to output SHA – 512  keys.   Another option presented is a Python 2.7 command that didn’t work for me either.  After some research and a little testing I found a solution.

 

Goals of this Post:

  • Create crypted user account password
  • Create credentials.yml – VARS FILE for password keys
  • Example of assigning a user module password in a playbook
  • Execute Ansible play and test

(more…)

Sep
23
2017
2

How to setup a Centurylink IQ SIP Trunk for Asterisk

Centurylink IQ architecture

I recently struggled to install a Centurylink SIP trunk.  Our rep could only provided us with Cisco configuration instructions.  From there we had to decipher the appropriate settings in Asterisk.  If you are reading this post you are probably in serious trouble right now.  Don’t worry!  Take a deep breath and keep reading!

 This is for Vanilla Asterisk 1.8.x.  I will cover sip.conf and extensions.conf examples.  The reference system is CentOS 7 paired with Asterisk 1.8.28.  This tutorial assumes you have working knowledge of Asterisk and the core configuration files.

Goals of the Post:

  • Configure Centurylink IQ SIP Trunk (sip.conf)
  • Configure Inbound/Outbound dialing (extensions.conf)
  • Set Hosts Mapping (/etc/hosts)

 

(more…)

Sep
11
2017
0

Automate WordPress backup with Python / Fabric

Python’s Fabric module makes automation easy.  This post shows how to use a Fabric script to backup a WordPress installation, but could be used for most LAMP backup situations!

Goals of this Post:

  • backup SQL to /tmp
  • backup WEB ROOT to /tmp
  • tar SQL + site & zip
  • download
  • delete /tmp

(more…)

Aug
20
2017
0

How to block outside IP addresses with firewalld on CentOS 7

There are situations were specific IP addresses or ranges may need to be blocked.  In my case I have SIP hackers trying to brute force a publicly exposed Asterisk server.  I don’t have control over the exterior gateway or firewalls between the server and public internet.  So in this case I have to specifically block access to a single host. 

From Asterisk:

[Aug 15 14:13:33] NOTICE[20986]: chan_sip.c:26214 handle_request_register: Registration from ‘”3292″ <sip:3292@64.56.135.10>’ failed for ‘195.154.188.25:5170’ – Wrong password

Goals of this Post:

  • Instruct firewalld to ‘drop’ all connection attempts from a single host

 

(more…)

Written by mattb in: Linux | Tags: , , , ,
Aug
10
2017
0

Google Interview Answered in Python

 

I’m in the process of moving my mindset from static linear scripting to an object oriented one.  My goal is to solve problems with algorithms I create myself.  It’s a tough climb because I come from Systems Admin/Networking side of things and didn’t benefit from Computer Science theory and advanced mathematics.  I’m hoping to eventually move into a DevOps role where I can organically absorb from devs.  It would be great to be able to observe other approaches to problem solving.

The video above is a Google interview prep question from Youtube.  The interviewee solves it with C++, I provide my version in Python below.  Essentially, they are solved in a similar way.  Granted, it took me two weeks of stewing on it and the man above did it on the spot, but he’s a Software Engineer, so I feel pretty good!

The problem is to find pairs of integers that add to 8 from a list assumed to be in ascending order.  Negatives and doubles are possible.

(more…)

Aug
01
2017
0

BASH script to cp/mv files of a certain date

I have a client that owns a high volume call center.  For quality assurance and training purposes they record all the calls.  Periodically the volume of recorded calls grows to the point that it slows down the NFS share to the Queuematrics call center software(Tomcat app).  I wrote a script that finds files by time and moves them to a different directory.

Usage: copy-by-date.sh -i INPUT_PATH -o OUTPUT_PATH -d +DAYS_OLD

(more…)

Jul
27
2017
0

Python module for generating NPC’s in Star Wars RPG

Recently table top gaming has made a huge comeback.  For the first time in 20 years my friends and I are role playing!  We agreed on the new Star Wars RPG by Fantasy Flight games, STAR WARS: Age of Rebellion role playing game.  It’s novel in many aspects compared to the previous D6 and D20 systems.  If you like Role Playing and Star Wars I advise that you take a look!  Since I’m frequently tasked as the GM I’ve automated the process of Non Player Character creation with Python to free up more time for story development.  I developed a module toward this end.  It’s portable between scripts and is easy customize.

The code is on the page below, but you can find updated SWNPC on Github as well.

Goals of this post:

  • Introduce SWNPC module
  • Demonstrate how to customize npc() object
  • Example use

(more…)

Jul
06
2017
0

How to Install mysql-connector for Python

For several months Python mysql-connector has been broken when attempting a install from pip.  In truth I’ve only tried Python 3, CentOS 6/7 and Fedora 21; in fact, this could be a more wide spread.  The simple solution is to install an earlier version.  The purpose of this post is to be a quick reminder of which is the most recent working version!

(more…)

Jul
03
2017
0

How to connect Asterisk SIP Clients over Duel Layers of NAT

A common problem with SIP is it’s difficulty handling NAT(especially over multiple layers).  A common symptom is no audio stream.  The Asterisk CLI  shows a successful call connection succeeding followed by an error in /var/log/asterisk/messages:

[Jun 14 17:16:26] WARNING[2967] chan_sip.c: Retransmission timeout reached on transmission 4e2a8586-3a91c1cf-e73f6b64@10.1.10.115 for seqno 2 (Critical Response) — See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 6399ms with no response

(more…)