Skip to content

Instantly share code, notes, and snippets.

View arbabnazar's full-sized avatar
🏠
Working from home

Arbab Nazar arbabnazar

🏠
Working from home
View GitHub Profile
@arbabnazar
arbabnazar / dotnet.yaml
Created April 7, 2024 13:13 — forked from ninjarobot/dotnet.yaml
Ansible playbook to install the .NET Core SDK on an Ubuntu server.
---
- hosts: all
tasks:
- name: Download MS product repository
get_url:
url: https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
dest: /tmp/packages-microsoft-prod.deb
- name: Install MS product repository
apt: deb=/tmp/packages-microsoft-prod.deb
become: true
@arbabnazar
arbabnazar / settings.py
Created January 22, 2023 15:36 — forked from dryan/settings.py
Handling EC2 ELB health checks and Django's ALLOWED_HOSTS setting.
# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = [
'yourdomain.tld',
'.compute-1.amazonaws.com', # allows viewing of instances directly
]
import requests
EC2_PRIVATE_IP = None
try:
@arbabnazar
arbabnazar / app_defaults.py
Created January 14, 2023 18:33 — forked from tgerla/app_defaults.py
example lookup plugin for ansible
import ansible.utils as utils
#
# Put this file in lookup_plugins/ alongside your playbooks.
#
# Lookup plugins can be called two ways: via with_ as a task loop
# construct, or via lookup('name').
#
# You can find the code for the basic lookup plugins here:
# v1: https://github.com/ansible/ansible/tree/devel/v1/ansible/runner/lookup_plugins
# v2: https://github.com/ansible/ansible/tree/devel/lib/ansible/plugins/lookup
@arbabnazar
arbabnazar / script.sh
Created January 14, 2023 14:53 — forked from vielhuber/script.sh
PostgreSQL: Backup and restore export import pg_dump with password on command line #sql
# best practice: linux
nano ~/.pgpass
*:5432:*:username:password
chmod 0600 ~/.pgpass
# best practice: windows
edit %APPDATA%\postgresql\pgpass.conf
*:5432:*:username:password
# linux
@arbabnazar
arbabnazar / Vagrantfile
Created December 29, 2022 11:35 — forked from mgsisk/Vagrantfile
Vagrant triggers for updating host hosts
Vagrant.configure('2') do |config|
ENV['HOST'] ||= '_ sys._'
config.vm.box = 'debian/contrib-buster64'
config.vm.hostname = File.basename(Dir.pwd) + '.test'
config.vm.network 'private_network', type: 'dhcp'
config.trigger.after :reload, :resume, :up do |trig|
trig.info = 'Updating sytstem hosts...'
trig.ruby do |env, vm|
@arbabnazar
arbabnazar / ec2_info_retriever.py
Created January 20, 2022 09:44 — forked from dastergon/ec2_info_retriever.py
A basic boto3 based tool for retrieving information from running EC2 instances.
from collections import defaultdict
import boto3
"""
A tool for retrieving basic information from the running EC2 instances.
"""
# Connect to EC2
ec2 = boto3.resource('ec2')
aws s3 ls s3://my-prod/directory --recursive --human-readable --summarize --profile aws-profile
aws s3 ls --summarize --human-readable --recursive s3://my-prod/* --profile aws-profile
aws s3 ls s3://my-prod --recursive --human-readable --summarize --profile aws-profile
aws s3 ls --profile aws-profile s3://my-prod --recursive | grep -v -E "(Bucket: |Prefix: |LastWriteTime|^$|--)" | awk 'BEGIN {total=0}{total+=$3}END{print total/1024/1024" MB"}'
openssl req -x509 -out localhost.crt -keyout localhost.key \
-newkey rsa:2048 -nodes -sha256 -days 1024 \
-subj '/CN=localhost' -extensions EXT -config <( \
printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
#Get the list of all the queues
rabbitmqadmin -f tsv --vhost=/ --username=RABBITMQ_USER --password=RABBITMQ_PASSWORD -q list queues name > file.txt
#Remove all the queues
while read -r name; do rabbitmqadmin --vhost=/ --username=RABBITMQ_USER --password=RABBITMQ_PASSWORD -q delete queue name="${name}"; done < file.txt
@arbabnazar
arbabnazar / deregister-task-definitions.sh
Created April 19, 2021 16:56 — forked from jen20/deregister-task-definitions.sh
Script to deregister all ECS Task Definitions in a given region
#!/usr/bin/env bash
get_task_definition_arns() {
aws ecs list-task-definitions --region ${AWS_REGION} \
| jq -M -r '.taskDefinitionArns | .[]'
}
delete_task_definition() {
local arn=$1