Friday, February 10, 2017

Terraform



provider "azurerm" {
  subscription_id = "XXXXXXXXXXXXXXXXXXXXX"
  client_id       = "XXXXXXXXXXXXXXXXXXXxx"
  client_secret   = "XXXXXXXXXXXXXX"
  tenant_id       = "XXXXXXXXXXXXXXXXXXXXX"
}

# create a resource group
resource "azurerm_resource_group" "dhanesh-rs" {
  name = "terraformtest"
  location = "Southeast Asia"
}

resource "azurerm_virtual_network" "dhanesh-net"{

  address_space = ["10.0.0.0/16"]
  location = "Southeast Asia"
  name = "dhanesh-net"
  resource_group_name = "${azurerm_resource_group.dhanesh-rs.name}"
}

resource "azurerm_subnet" "dhanesh-sub" {
  address_prefix = "10.0.2.0/24"
  name = "dhanesh-sub"
  resource_group_name = "${azurerm_resource_group.dhanesh-rs.name}"
  virtual_network_name = "${azurerm_virtual_network.dhanesh-net.name}"
}

resource "azurerm_network_interface" "dhanesh-if" {

  location = "Southeast Asia"
  name = "dhanesh-if"
  resource_group_name = "${azurerm_resource_group.dhanesh-rs.name}"

  "ip_configuration" {

    name = "dhanesh-ifip"
    private_ip_address_allocation = "dynamic"
    subnet_id = "${azurerm_subnet.dhanesh-sub.id}"
  }
}

resource "azurerm_availability_set" "dhanesh-as" {

  name = "dhanesh-az"
  location = "Southeast Asia"
  resource_group_name = "${azurerm_resource_group.dhanesh-rs.name}"
  tags{
    environment="production"
  }

}

resource "azurerm_storage_account" dhanesh-ds {

  name = "dhaneshds"
  account_type = "Standard_LRS"
  location = "Southeast Asia"
  resource_group_name = "${azurerm_resource_group.dhanesh-rs.name}"
  tags {
    environment ="production"
  }
}

resource "azurerm_storage_container" "dhansh-sc" {
  name = "dhanesh-sc"
  resource_group_name = "${azurerm_resource_group.dhanesh-rs.name}"
  storage_account_name = "${azurerm_storage_account.dhanesh-ds.name}"
  container_access_type = "private"
}

resource "azurerm_virtual_machine" "dhanesh-vm" {
  name = "dhaneshvm"
  location = "Southeast Asia"
  resource_group_name = "${azurerm_resource_group.dhanesh-rs.name}"
  network_interface_ids = ["${azurerm_network_interface.dhanesh-if.id}"]
  vm_size = "Standard_A0"


  storage_image_reference {
    publisher = "Canonical"
    offer = "UbuntuServer"
    sku = "14.04.2-LTS"
    version = "latest"
  }

  storage_os_disk {
    name ="myosdisk"
    vhd_uri = "${azurerm_storage_account.dhanesh-ds.primary_blob_endpoint}${azurerm_storage_container.dhansh-sc.name}/myos.vhd"
    caching = "ReadWrite"
    create_option = "FromImage"
  }

  os_profile {

    admin_password = "Dhanesh@1234567"
    admin_username = "dhanesh"
    computer_name = "dhanesh-vm"
  }

  os_profile_linux_config {

    disable_password_authentication = false
  }

  tags {
   environment = "production"
  }

}

Thursday, February 9, 2017

Important Linux logs for auditing


/var/log/message – Whole system logs
/var/log/auth.log – Authentication logs.
/var/log/kern.log – Kernel logs.
/var/log/cron.log – Crond logs (cron job).
/var/log/maillog – Mail server logs.
/var/log/boot.log – System boot log.
/var/log/mysqld.log – MySQL database server log file.
/var/log/secure – Authentication log.
/var/log/utmp or /var/log/wtmp : Login records file.
/var/log/yum.log: Yum log files.

Removing sudo account


/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync

Tuesday, February 7, 2017

Creating Load in Linux Servers

Stress for Auto scaling testing [LINUX] 

For performance testing or auto scale testing we usually search for a method to generate CPU / Memory  load generator. Here is one of the tool which I have used for generating CPU load to test  auto scaling in Microsoft Azure is "stress" 

By default I didn't find the stress package in Centos so I had to enable epel repository .


yum install epel-release 
yum install stress

Which operating system you like most?