Add user to sudoers (RHEL)

$ sudo su

# adduser iwadmin

# passwd <password>

# usermod -aG wheel iwadmin

# vi /etc/sudoers

[...add this line after root line:...]

iwadmin    ALL=(ALL)       ALL

@ Kloud Office

Kloud Office on Elizabeth St/Collins St

Reboot an AWS EC2 Instance (Python)

from __future__ import print_function
import sys
import boto3
from botocore.exceptions import ClientError

boto3.setup_default_session(profile_name='default')

instance_id = 'i-094cf9bbbea2bdfbd' #sys.argv[2]
#action = sys.argv[1].upper()

ec2 = boto3.client('ec2')

# Do a dryrun first to verify permissions
try:
    ec2.start_instances(InstanceIds=[instance_id], DryRun=True)
except ClientError as e:
    if 'DryRunOperation' not in str(e):
        raise

# Dry run succeeded, run start_instances without dryrun
try:
    response = ec2.start_instances(InstanceIds=[instance_id], DryRun=False)
    print(response)
except ClientError as e:
    print(e)

Chef Cheatsheet

Download all cookbooks

$ cd ~/chef-repo

$ knife download cookbooks

Download all roles

$ cd ~/chef-repo

$ knife download roles

Download Specific Cookbook

$ knife download cookbooks/cert-QValent\*  --cookbook-version 0.1.0

Creating cookbook

$ cd ~/chef-repo

$ knife cookbook create newrelic-config     /OR/     cd cookbooks; chef generate cookbook newrelic-config

$ cd cookbooks/newrelic-config/recipes

$ touch update_config.rb

 $notepad update_config.rb

[...Author Recipe.....]

Upload cookbook

$ cd ~\chef-repo

$ ruby -c .\cookbooks\cert-QValent\recipes\qvalent-bit.rb

$ foodcritic .\cookbooks\trendMicro\recipes\*

$ knife cookbook test newrelic-config

$ knife cookbook upload newrelic-config

Modify role and include new recipe

$ vim  .\roles\portalapps.json

  >> "recipe[newrelic-config::update_config]"

Upload Role

$ knife upload .\roles\portalapps.json

Assign Role to Nodes

$ knife node list

$ knife node edit sit9-portalapps-ip-0a9a1670

Download cookbook from supermarket

$ knife cookbook site download

Vagrant Cheatsheet

Setting up new system

-Install VirtualBox

-Install Vagrant

- $ vagrant plugin install vagrant-vbguest

- $ vagrant box add hashicorp/precise64    (centos/7)

-Create Vagrantfile (see below)

- $ vagrant up

Debuggin issues

$ set VAGRANT_LOG=info

$ vagrant up

Vagrantfile

# -*- mode: ruby -*-

# vi: set ft=ruby :

Vagrant.configure("2") do |config|

  config.vm.box = "hashicorp/precise64"

  config.vm.network "public_network"

end

Set regional settings to Australia (Powershell)

# Script to configure language settings for each user

#Write settings to reg key for all users who logon to machine
#$RegKeyPath = "HKU:\Control Panel\International"

# Import 'International' module to Powershell session
Import-Module International

#Set Location to Australia
Set-WinSystemLocale en-AU
Set-WinHomeLocation -GeoId 0xC

# Set regional format (datetime etc.) to English (Australia) - this applies to all users
Set-Culture en-AU

# Check language list for non-US input languages, exit if found
#$currentlist = Get-WinUserLanguageList
#$currentlist  ForEach-Object {if(($_.LanguageTag -ne en-AU) -and ($_.LanguageTag -ne en-US)){exit}}

# Set the language list for the user, forcing English (Australia) to be the only language
Set-WinUserLanguageList en-AU -Force
Set-WinCultureFromLanguageListOptOut 0