Skip to content

Instantly share code, notes, and snippets.

View nmaludy's full-sized avatar

Nick Maludy nmaludy

View GitHub Profile
@nmaludy
nmaludy / include_vars_if_not_exists.py
Last active February 24, 2023 21:01
Ansible include vars if not exists
# Copyright: (c) 2016, Allen Sanabria <asanabria@linuxdynasty.org>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from os import path, walk
import re
import ansible.constants as C
@nmaludy
nmaludy / print_apply_results.pp
Created November 7, 2022 13:45
Bolt apply() result printer function
# @summary Pretty print ResultSet
# A function for puppet plans to output and pretty print the resultset of an apply block for debugging purposes..
# @api private
# @param resultset A Result set of an apply block
# @param formats A Puppet String Cast compatible format object to format the output. By default it gets pretty printed
# with intendation for structured objects.
# @return [ResultSet] This function returns the resultset provided.
# @example Calling the function:
# $results = apply($nodes) {
# service {'httpd':
@nmaludy
nmaludy / wesp32_eth_init.c
Last active November 14, 2022 22:03
wESP32 Ethernet Initialization
#include "esp_event.h"
#include "esp_netif.h"
#include "esp_eth.h"
void init_wesp32_eth()
{
//////////////
// MAC
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG(); // apply default MAC configuration
eth_esp32_emac_config_t emac_config = ETH_ESP32_EMAC_DEFAULT_CONFIG();
@nmaludy
nmaludy / raid_ephemeral.sh
Created May 11, 2021 16:13
AWS raid_ephemeral.sh Supports NVMe
#!/bin/bash
#
# this script will attempt to detect any ephemeral drives on an EC2 node and create a RAID-0 stripe
# mounted at /mnt. It should be run early on the first boot of the system.
#
# Beware, This script is NOT fully idempotent.
#
MOUNT_PATH="/mnt"
FS_TYPE="xfs"
@nmaludy
nmaludy / network_info.py
Created May 7, 2021 19:24
Python to list all network interfaces and DNS servers
#!/usr/bin/env python
import json
import os
import re
import ipaddress
import subprocess
# pattenrs for parsing 'ip address' output
INTERFACE_PATTERN = re.compile(r'^(?P<idx>\d+): (?P<iface>[a-zA-Z0-9]+): <(?P<status>.*)> (?P<info>.*)$')
@nmaludy
nmaludy / st2actions_scheduler_entrypoint.py
Created July 8, 2020 01:54
st2actions/scheduler/entrypoint.py
# Copyright 2019 Extreme Networks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
get_ids:
action: xxx.concurrent_actions
input:
action: xxx.vm_update_id
timeout: "{{ ctx().concurrent_actions_timeout }}"
items: "{{ ctx().all_vms }}"
parameters:
vm_fqdn: "{_{ _.item.name }_}"
vm_moid: "{_{ _.item.moid }_}"
result: "{_{ _.result.vm_name }_}"
---
description: "Executes actions in parallel"
enabled: true
entry_point: concurrent_actions.py
name: concurrent_actions
pack: xxx
parameters:
action:
type: string
description: "Name of the pack.action to execute"
#!/usr/bin/env python
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@nmaludy
nmaludy / var-log-st2-st2-install.20190409T005730.log
Created April 9, 2019 01:07
StackStorm Install Error - Conflict While Try To Save To DB
20190409T005730+0000 ########################################################
20190409T005730+0000 Installing st2 unstable
20190409T005730+0000 ########################################################
20190409T005730+0000
20190409T005730+0000
20190409T005730+0000 ################################################################
20190409T005730+0000 ### Installing from staging repos!!! USE AT YOUR OWN RISK!!! ###
20190409T005730+0000 ################################################################
20190409T005731+0000 Loaded plugins: fastestmirror
20190409T005731+0000 Loading mirror speeds from cached hostfile