Skip to content

Instantly share code, notes, and snippets.

View nidr0x's full-sized avatar
🎯
💭

Carlos nidr0x

🎯
💭
  • Job&talent
  • Valencia (Spain)
View GitHub Profile
@nidr0x
nidr0x / azure-automation-poweron-poweroff
Created March 12, 2018 12:12
Schedule startup and shutdown of Azure Machines via PowerShell
# Input Parameters for
# - VmName: name of the vm to perform action to
# - ResourceGroupName: resource group where the vm belongs to
# - VmAction:action to perform (startup or shutdown)
Param(
[string]$VmName,
[string]$ResourceGroupName,
[ValidateSet("Startup", "Shutdown")]
[string]$VmAction
@nidr0x
nidr0x / azure_create_complete_vm.yml
Created March 14, 2018 11:37
Creating Azure VM in Ansible
- name: Create Azure VM
hosts: localhost
connection: local
tasks:
- name: Create virtual network
azure_rm_virtualnetwork:
resource_group: myResourceGroup
name: myVnet
address_prefixes: "10.0.0.0/16"
- name: Add subnet
@nidr0x
nidr0x / SSH configuration
Last active April 27, 2018 11:25
SSH configuration
Host *
ForwardAgent no
ForwardX11 no
ForwardX11Trusted yes
User root
Port 22
Protocol 2
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
ServerAliveInterval 60
netsh advfirewall firewall add rule name="Open Zabbix agentd port 10050 inbound" dir=in action=allow protocol=TCP localport=10050
netsh advfirewall firewall add rule name="Open Zabbix agentd port 10050 outbound" dir=out action=allow protocol=TCP localport=10050
netsh advfirewall firewall add rule name="Open Zabbix trapper port 10051 inbound" dir=in action=allow protocol=TCP localport=10051
netsh advfirewall firewall add rule name="Open Zabbix trapper port 10051 outbound" dir=out action=allow protocol=TCP localport=10051
- name: Download Hotfixes
win_get_url:
url: "{{ item.url }}"
dest: "C:/{{ item.kb }}.msu"
with_items:
- { kb: KB2919442, url: "https://download.microsoft.com/download/D/6/0/D60ED3E0-93A5-4505-8F6A-8D0A5DA16C8A/Windows8.1-KB2919442-x64.msu" }
- { kb: KB2919355, url: "https://download.microsoft.com/download/2/5/6/256CCCFB-5341-4A8D-A277-8A81B21A1E35/Windows8.1-KB2919355-x64.msu" }
- name: Install KB2919442 Hotfix
win_hotfix:
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
#Needed for installing SQL Server via Chocolatey in Win2012
- name: Download Hotfixes
win_get_url:
url: "{{ item.url }}"
dest: "C:/{{ item.kb }}.msu"
with_items:
- { kb: KB2919442, url: "https://download.microsoft.com/download/D/6/0/D60ED3E0-93A5-4505-8F6A-8D0A5DA16C8A/Windows8.1-KB2919442-x64.msu" }
- { kb: KB2919355, url: "https://download.microsoft.com/download/2/5/6/256CCCFB-5341-4A8D-A277-8A81B21A1E35/Windows8.1-KB2919355-x64.msu" }
#Needed to avoid provision stop in W2016 because is not needed
when: ansible_distribution == "Microsoft Windows Server 2012 R2 Datacenter" or ansible_distribution == "Microsoft Windows Server 2012 R2"
Enable-WSManCredSSP -Role Server -Force
Set-Item -Path "WSMan:\localhost\Service\Auth\CredSSP" -Value $true
# Don't be scared, wget is an alias for Invoke-WebRequest
wget https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1 -Outfile ConfigureRemotingForAnsible.ps1
.\ConfigureRemotingForAnsible.ps1
winrm quickconfig -transport:https
@nidr0x
nidr0x / gist:6a104040e2344fdef930736574b03e05
Created June 11, 2018 07:32
Powershell enable TCP SQL Server
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql13.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql13.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \