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 / Install PHP 5.3 on Ubuntu 14.04(trusty)
Last active December 4, 2023 11:08
How to install PHP 5.3 on Ubuntu 14.04
#Add the Ubuntu 12.04(precise) repositories
cat <<EOF >> /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu precise main restricted universe
deb http://archive.ubuntu.com/ubuntu precise-updates main restricted universe
deb http://security.ubuntu.com/ubuntu precise-security main restricted universe multiverse
EOF
# Update the repos
apt-get update
@arbabnazar
arbabnazar / gist:6b9909cfba52ac066512ba5d1c1a1080
Created July 9, 2016 09:20 — forked from mpolden/gist:8559017
Example for Ansible git-module and ssh agent forwarding
# files/env:
Defaults env_keep += "SSH_AUTH_SOCK"
# tasks/main.yml
- name: ensure sudo keeps SSH_AUTH_SOCK in environment
copy: src=env
dest=/etc/sudoers.d/env
mode=0440
owner=root
group=root
@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|
let’s list block devices attached to our box:
lsblk
# install "cloud-guest-utils" if it is not installed already
apt install cloud-guest-utils
# resize partition
growpart /dev/xvda 1 OR growpart /dev/nvme0n1 1
# resize filesystem
@arbabnazar
arbabnazar / gist:b612e210fe31bcd33077
Created January 1, 2015 17:26
pythonscriptformysql
#!/usr/bin/env python
### Import required python libraries
import os
import time
import shutil
from boto.s3.connection import S3Connection
from boto.s3.key import Key
@arbabnazar
arbabnazar / rename-bulk-files-with-ansible.yml
Created April 2, 2016 10:23
This playbook is used to perform bulk files rename on remote hosts
- hosts: all
gather_facts: no
become: yes
tasks:
- shell: ls /files/*
register: files_to_rename
- copy:
src: "{{ item.1 }}"
dest: "/files/file-{{ item.0 + 1 }}"