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')
@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
@arbabnazar
arbabnazar / replace_ecs_cluster_instances.py
Created December 3, 2020 09:06 — forked from kevinmehall/replace_ecs_cluster_instances.py
Script to drain and replace EC2 instances in an ECS cluster auto-scaling group after changing the AMI or instance type
#!/usr/bin/env python3
#
# Script to replace EC2 instances in an ECS cluster's auto-scaling group after
# changing the AMI or instance type in the launch configuration. It
# checks for instances with the incorrect AMI or type, scales up the
# auto-scaling group with replacement instances, then drains the tasks
# from the old instances.
#
# Usage: aws-vault exec profile-name -- python3 replace_ecs_cluster_instances.py --group=asg-name --cluster=ecs-cluster-name --count=3
#
@arbabnazar
arbabnazar / ubuntu-hardening.md
Created October 10, 2019 12:39 — forked from lokhman/ubuntu-hardening.md
List of things for hardening Ubuntu

System Updates

http://bookofzeus.com/harden-ubuntu/initial-setup/system-updates/

Keeping the system updated is vital before starting anything on your system. This will prevent people to use known vulnerabilities to enter in your system.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove
sudo apt-get autoclean
@arbabnazar
arbabnazar / es_ping.py
Created July 2, 2019 06:56 — forked from jamesdavidson/es_ping.py
Ping Amazon Elasticsearch Service in Python3
import sys
from elasticsearch import Elasticsearch, RequestsHttpConnection
from aws_requests_auth.boto_utils import BotoAWSRequestsAuth
# sanity check Python version
assert(sys.version_info >= (3,6))
ES_ENDPOINT = 'search-dev-logs-kxsz2asdflkjlaksdfie7i36iry.ap-southeast-2.es.amazonaws.com'
AWS_REGION = 'ap-southeast-2'