This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| #--- it has a syntax error need to fix ----# | |
| # format of x9.csv, add error checking | |
| # ipaddr, password, user | |
| # 172.16.12.22, HKJP5763qhvf, ec2-user | |
| set -x | |
| echo "Start!" | |
| f=x9.csv | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| ## Requires jq install | |
| ## filter by region, here it is us | |
| regions=$(aws ec2 describe-regions --filters "Name=region-name,Values=*us*" | jq '.Regions[]| .RegionName') | |
| echo $regions | |
| ## | |
| ## regions=$(aws ec2 describe-regions --filters "Name=region-name,Values=*us*" --output text | cut -f 3) | |
| regions=$(aws ec2 describe-regions --filters "Name=region-name,Values=*us*" --query 'Regions[*].RegionName' --outpu | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | vpcname="linuxacademy" | |
| subnetcidr="10.0.2.0/24" | |
| region="us-east-1" | |
| az="${region}b" | |
| sgname="${vpcname}-sg" | |
| sshingress="0.0.0.0/0" # use your IP address /32 | |
| # query default vpc and tag | |
| vpcs=$(aws ec2 describe-vpcs) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | --- | |
| - name: Change password when connecting as a non-root/non-sudoer user. | |
| # https://stackoverflow.com /45988965/ | |
| # Ansible's 'user' module can only change a password if it is ran as a root user or 'become' is used. | |
| # For a non-root user, when you run 'passwd', it asks for current password before you can enter a new one. | |
| # Workaround: Create a a temporary script that updates the password and run that script remoteley | |
| # and use 'no_log' directive to prevent passwords being visible in any log. | |
| # Tested that passwords not visible in verbose output '-vvvvv' and not in 'history' of remote computers. | |
| # The temporary script is deleted remotley automatically by 'script' module. | |
| # Note: New password must comply with your passwd security policy. | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| # apt-cache policy docker-ce | |
| # START Install on all nodes | |
| export docker_version=5:18.09.9~3-0~ubuntu-bionic | |
| export user=$(whoami) | |
| export LBExt=3.91.9.240 | |
| export LBInt=10.21.0.223 | |
| export K8sCP1=10.21.0.71 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| sudo wget https://pkg.cfssl.org/R1.2/cfssl_linux-amd64 \ | |
| -O /usr/local/bin/cfssl | |
| sudo wget https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64 \ | |
| -O /usr/local/bin/cfssljson | |
| sudo chmod +x /usr/local/bin/cfssl* | |
| cfssl version | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| #-- Run in all Nodes --# | |
| #-- Install Docker K8sGPG --# | |
| curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
| curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - | |
| #-- Add Repos --# | |
| cat << EOF | sudo tee /etc/apt/sources.list.d/docker.list | |
| deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| # https://github.com/nvm-sh/nvm#git-install | |
| export NVM_DIR="$HOME/.nvm" && ( | |
| git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR" | |
| cd "$NVM_DIR" | |
| git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)` | |
| ) && \. "$NVM_DIR/nvm.sh" | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| # https://mywiki.wooledge.org/BashFAQ/030 | |
| # rename .tf to .ignore | |
| for f in *.tf | |
| do | |
| mv -- "$f" "${f%.tf}.ignore" | |
| done | |
| # reverse *.ignore to .tf | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| ## Find regions pipe it to jq to get an array, filter just the us regions | |
| aws ec2 describe-regions --filters "Name=endpoint,Values=*us*" | jq '.Regions[].RegionName' | |
| ## amazon instances | |
| instances=( $(aws ec2 describe-instances \ | |
| --query 'Reservations[*].Instances[*].[Tags[?Key==`Name`].Value[],PublicIpAddress]' \ | |
| --output text | awk '{ print $0}') ) |