Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

CHANDRA SHEKHAR GOKA chandra-goka

🏠
Working from home
View GitHub Profile
View install-ssh.sh
#!/usr/bin/env bash
request_cmd=$([[ -x "$(command -v curl)" ]] && echo "curl_request" || echo "wget_request")
download_cmd=$([[ -x "$(command -v curl)" ]] && echo "curl -sSO" || echo "wget -q")
#GOSS_ENDPOINT="https://api.goss.vdo.manage.rackspace.com/v1.0/instance/goss"
GOSS_ENDPOINT="https://chandra-goka.api.goss.dev.vdo.manage.rackspace.com/v1.0"
jwt_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJkb21haW4iOiIxMjM0MTE3Iiwic2VydmljZV90eXBlIjoiTUFOQUdFRF9WTUMiLCJzZXJ2aWNlX2lkIjoiNGM5NjA1MmEtODVjMC00MDZlLWJjZmMtOGI0MWI3OWFiNWY3IiwidG9rZW5faWQiOiI5NDg2N2JiZC00MWIzLTRiZjAtODYzYS1kNjIwMzlkMjYzZDkifQ.Apwr6nQpzglkUzOt3XXhH7y58nffszSCqeTQiGsJBcNrZnmqeqooc_JB3o-8AEwuIH0lD6TW7BN3FgttKW2eRrzK_mWwWe9Eue8swXrRupQBKaDVLGKTdK17NjWN-FzETlVQd0wCQreLWTRuPjXFf_QfeHK3v9M-P1tjO9n30fm_cDOKUi5ueJHYx61iX_XPFDD9-b2iOqRyydFnbol0hVBpoUA4jlK4sgLA7-pNnhWM5elPZO5N78MwkokfZjDkxRjw-29Zx4ia_GNZU-BWtkWsroFTlcn3CGc9VB5YXSqJM7fuerzEJEZiTx1VETBMGFzQCDntGOQpYp-kV8BFHQ
UNABLE_TO_ACTIVATE=1
View sample.ps1
<#
.SYNOPSIS
Registers this host with ssm agent
.DESCRIPTION
Downloads the agent, installs it, must be run as Administrator
#>
$JWT_TOKEN="eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzZXJ2aWNlX2lkIjoiNGM5NjA1MmEtODVjMC00MDZlLWJjZmMtOGI0MWI3OWFiNWY3IiwiZG9tYWluIjoiMTIzNDExNyIsInNlcnZpY2VfdHlwZSI6Ik1BTkFHRURfVk1DIiwidG9rZW5faWQiOiI5OGViOWE0OC1hMjNjLTRiMjMtYWM4Mi1jOWRiNGMxMDFhZTQifQ.kX3aR8X_mO6uSjOMKygTDfNl9Xen0RvCOLHy5-zfpTWwPz7j1XjVPpE24SJztdW7RFdomLCbZ7CA9MFFrcNFv8gyFhlUpe926DIV9TGt1HcC-_KSLtm82PhK5hL8pSDhwj1esPi3xv-JROzgYgfdy_b2aTFdJk4wIxjog7xEIr09ijftfyWZSZglCN7JbmqDMglXJuS1j5fC4Ix9Ji2MUFl2Prb1KNtPLzLSsBYwPYaNi5kxKmFT5VhNJ_6V1p9-QG_vut7A-xFbi_psWJW2xPxzpe2U8sZziEFkZiLHwA1_Whd541f396xz-drJNVFyRa43iqGqGAvvO8B9L0VQDQ"
$error_codes = @{"UNABLE_TO_ACTIVATE"=1; "JOB_RETRIEVE_FAILURE"=2; "NO_JOB_FOUND"=3; "OS_UNSUPPORTED"=4;}
View ssm
function Has-Instance
{
$ssm_path = $Env:Programfiles + "\Amazon\SSM\sam-cli.exe"
if(Test-Path -Path $ssm_path -PathType Leaf)
{
cd $Env:ProgramFiles\Amazon\SSM
$output = .\ssm-cli.exe get-instance-information | ConvertFrom-Json
if([bool] $output.psobject.properties.name -match "instance-id")
{
$managed_instance_id = $output.psobject.properties["instance-id"].value
View admin_script
"script": "Set-ExecutionPolicy Bypass -Scope CurrentUser -Force\n[System.Net.ServicePointManager]::
SecurityProtocol = @(\n [System.Net.SecurityProtocolType]::Tls;,\n
[System.Net.SecurityProtocolType]::Tls12;\n)\n
$ScriptResponse = Invoke-WebRequest \"https://vmc-ssm-agent-install.s3-us-west-2.amazonaws.com/ssm-agent-install.ps1\"
-UseBasicParsing\n$Script = [System.Text.Encoding]::UTF8.GetString($ScriptResponse.Content)\n$ScriptBlock = [Scriptblock]::Create($Script)\n
Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList
($args + @(\"wqdWaDWEe6/KVn6vNxNl\", \"49a31a45-d9b6-4d89-a727-1f9d537646c0\", \"eu-west-2\"))"
execution:: 767cf564-41f5-41e0-846e-7f3058c7ac21
View vs500.vdo.ord1.rvi.rax.io
{
"group-d1": {
"_mor": {
"type": "Folder",
"value": "group-d1"
},
"availableField": [
{
"key": 1,
"name": "com.rackspace.rpcv.goss",
View data-centers
{
"datacenter-42": {
"_mor": {
"type": "Datacenter",
"value": "datacenter-42"
},
"availableField": [
{
"key": 1,
"name": "com.rackspace.rpcv.goss",
View data-store
{
"datastore-264": {
"_mor": {
"type": "Datastore",
"value": "datastore-264"
},
"availableField": [
{
"key": 1,
"name": "com.rackspace.rpcv.goss",
View VMs
This file has been truncated, but you can view the full file.
{
"vm-213": {
"_mor": {
"type": "VirtualMachine",
"value": "vm-213"
},
"availableField": [
{
"key": 1,
View host_system
This file has been truncated, but you can view the full file.
{
"host-88": {
"_mor": {
"type": "HostSystem",
"value": "host-88"
},
"availableField": [
{
"key": 1,
View ClusterComputeResource
{
"domain-c91": {
"_mor": {
"type": "ClusterComputeResource",
"value": "domain-c91"
},
"availableField": [
{
"key": 1,
"name": "com.rackspace.rpcv.goss",