Friday, 15 March 2013

Generate IAM certs for users on AWS


  1. openssl genrsa 1024 > username-env-pk.pem
    1. pk stands for private key
  2. openssl req -new -x509 -nodes -sha1 -days 365 -key username-env-pk.pem -outform PEM > username-env-cert.pem
    1. lasts for 365
  3. Paste username-env-cert.pem in to the AWS Signing Certificates area for that user
  4. Give user both username-env-pk.pem and username-env-cert.pem, and wish them luck

Redirect all command output, stdin/stderr, to a file on Linux

puppet agent --test --noop >/var/tmp/puppet_noop_20130315 2>&1

Notes:
  1. The 2>&1 redirects stderr to where stdin points
    1. stdin points to the console by default unless you change that
    2. here stdin is redirected to a file under /var/tmp


vagrant on aws


  1. vagrant plugin install vagrant-aws
  2. vagrant box add aws001 https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box
  3. vagrant init
  4. Adapt below and put in the "Vagrantfile" file
  5. vagrant up --provider=aws
  6. vagrant ssh
  7. vagrant destroy
Vagrant.configure("2") do |config|
  config.vm.box = "aws001"

  config.vm.provider :aws do |aws|
    aws.access_key_id = "<your_aws_key_id>"
    aws.secret_access_key = "<your_aws_secret>"
    aws.keypair_name = "<your_keypair_name>"
    aws.ssh_private_key_path = "/home/<you>/.ssh/<your_keypair_name>.pem"

    aws.region = "eu-west-1"
    aws.ami = "ami-01080b75"
    aws.ssh_username = "ubuntu"
  end
end

Thursday, 14 March 2013

2G swap file


  1. dd if=/dev/zero of=/swapfile bs=1M count=2048
  2. mkswap /swapfile
  3. swapon /swapfile

Wednesday, 13 March 2013

Get provisioned public key for AWS EC2 instance via curl

curl http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key

Tuesday, 12 March 2013

Specify ssh key when using rsync

WARNING: don't use ~ and don't use double quotes.
  1. rsync -av -e 'ssh -i /home/me/.ssh/id_rsa_other' root@logging.gumby.com:/remotedir/ /localdir/
Also, some alternative port:
  1. rsync -av -e 'ssh -p 2221' root@logging.gumby.com:/remotedir/ /localdir/

Tuesday, 5 March 2013

Build rpm of monit 5.5

  1. Download https://github.com/pcharlesleddy/misc/blob/master/monit.spec
    1. change "_topdir" to match your local system.
  2. cd into what you set _topdir to
  3. mkdir -p {BUILD,RPMS,SOURCES,SPECS,SRPMS,tmp}
  4. Download monit-5.5.tar.gz file and put it in the SOURCES directory
  5. Put monit.spec in the SPECS directory
  6. rpmbuild -v -bb --clean SPECS/monit.spec
    1. yum -y install rpmdevtools
  7. Output should mention where the rpm ended up
  8. rpm -qlp on the rpm file to see what's in it
Gory details: http://fedoraproject.org/wiki/How_to_create_an_RPM_package

Notes
  1. "%spec -q" means be "quiet" when untarring, not that interesting, but people use it a lot

    Interview questions: 2020-12

    Terraform provider vs provisioner Load balancing Network Load Balancer vs Application Load Balancer  Networking Layer 1 vs Layer 4 haproxy u...