Skip to content

Instantly share code, notes, and snippets.

@carbonin
carbonin / json_annotation.rs
Created August 29, 2023 15:44
Adding annotations to a json in rust
use serde_json::{Value, json};
fn main() {
let data = r#"
{
"metadata": {
"annotations": {
"thing": "stuff"
},
"name": "thing"
15:35:55:/tmp/requirements$ diff -y upstream downstream
adal adal
> ansible
> ansible-runner
apache-libcloud apache-libcloud
appdirs appdirs
applicationinsights applicationinsights
argcomplete argcomplete
asn1crypto asn1crypto
azure-cli-core azure-cli-core
@carbonin
carbonin / ansible_decrypt.rb
Last active June 26, 2019 15:19
AWX encrypt / vmdb decrypt test
require 'openssl'
require 'base64'
class Fernet256
attr_reader :hmac, :cipher, :signing_key, :encryption_key
InvalidToken = Class.new(ArgumentError)
def initialize(key)
decoded_key = Base64.urlsafe_decode64(key)
vacuum analyze metrics_00;
vacuum analyze metrics_01;
vacuum analyze metrics_02;
vacuum analyze metrics_03;
vacuum analyze metrics_04;
vacuum analyze metrics_05;
vacuum analyze metrics_06;
vacuum analyze metrics_07;
vacuum analyze metrics_08;
vacuum analyze metrics_09;
Definitions:
Containers - Lightweight mechanisms for isolating running processes so that they are limited to interacting with only their designated resources.
Pods - One or more containers deployed together on one node. The smallest compute unit that can be defined, deployed, and managed.
- Containers in a pod share the same filesystem, networking, and memory space.
- Components which are mutually dependent and scale in lock-step may be good candidates for a multi-container pod.
- Examples include proxies and log management
Labels - Key value pairs used to identify most objects (e.g. app: topological-inventory)
Selectors - Reference to labels used to group and identify objects
Deployment Configs - The definition of a pod, the number of replicas, deployment triggers, and lifecycle hooks. Pods belong to a deployment config and are related through labels and selectors.
content-server-1-nltm6
+ httpd -D FOREGROUND
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.32. Set the 'ServerName' directive globally to suppress this message
(13)Permission denied: AH00058: Error retrieving pid file /run/httpd/httpd.pid
AH00059: Remove it before continuing if it is corrupted.
dynflow-1-x2gmq
+ /usr/bin/wait_on_postgres.py
Waiting on postgresql to start...
Postgres started!
@carbonin
carbonin / embedded_ansible_foreman
Last active December 8, 2017 13:22
Run embedded ansible locally using Foreman
# create Procfile.ansible with this line
ansible: ruby lib/workers/bin/run_single_worker.rb EmbeddedAnsibleWorker
# create Procfile.workers with these lines (the -e option should be whatever the provider id is in your database once it is created)
generic: ruby lib/workers/bin/run_single_worker.rb MiqGenericWorker
embedded_ansible_refresh: ruby lib/workers/bin/run_single_worker.rb -e 1 ManageIQ::Providers::EmbeddedAnsible::AutomationManager::RefreshWorker
embedded_ansible_event: ruby lib/workers/bin/run_single_worker.rb -e 1 ManageIQ::Providers::EmbeddedAnsible::AutomationManager::EventCatcher
# From a clean environment
psql -d postgres -c 'DROP DATABASE awx'
@carbonin
carbonin / clean_manageiq.sh
Created November 6, 2017 20:39
Script to clean out the default setup of a ManageIQ appliance. This should make the appliance easier to configure in multi-server architectures.
#!/bin/bash
# Stop and disable services
systemctl stop evmserverd
systemctl disable evmserverd
systemctl stop $APPLIANCE_PG_SERVICE
systemctl disable $APPLIANCE_PG_SERVICE
# Remove auto-generated files
#!/usr/bin/env bash
# Remove stale RPMs from /var/cache/PackageKit/2[0-9]/metadata/updates/packages/
#
# They take a lot of space.
# Remove the ones that are no longer installed.
# It would be OK to remove even the ones already installed but that would
# probably prevent the use of Delta RPMs.
#
# Notes:
@carbonin
carbonin / scap.rb
Last active October 3, 2017 21:22
Ruby script for checking compliance with a specific set of rules
require 'yaml'
require 'nokogiri'
require 'openscap'
require 'tempfile'
require 'pathname'
require 'trollop'
class ScapTest
PROFILE_ID = "xccdf_org.ssgproject.content_profile_linux-admin-scap".freeze
SSG_XML_PATH = Pathname.new("/usr/share/xml/scap/ssg/content/")