Boto3 get main route table

This entry is part 6 of 6 in the series Boto

This entry is part 6 of 6 in the series BotoWhile developing Botoform I ran into an issue with Boto3 where I couldn’t easily get the “main” route table of a VPC. I ended up adding a get_main_route_table method to do the duty. def get_main_route_table(self): “””Return the main (default) route table for VPC.””” main_route_table = […]

List all installed package names in Python

pkgs = lambda : list(__import__(‘pkg_resources’).working_set) pkg_names = lambda : [x.project_name for x in pkgs()] pkg_versions = lambda : [x.project_name + ‘==’ + x.version for x in pkgs()] >>> pkg_names() [‘ansible’, ‘pycrypto’, ‘PyYAML’, ‘Jinja2’, ‘…truncated…’, ‘virt-back’, ‘Werkzeug’, ‘xmltodict’] >>> pkg_versions() [‘ansible==1.7’, ‘pycrypto==2.6.1’, ‘…truncated…’, ‘virt-back==0.1.0’, ‘xmltodict==0.9.2’]

Filtering AWS resources with Boto3

This entry is part 1 of 6 in the series Boto

This entry is part 1 of 6 in the series Boto This post will be updated frequently when as I learn more about how to filter AWS resources using Boto3 library. Filtering VPCs by tags In this example we want to filter a particular VPC by the “Name” tag with the value of ‘webapp01’. >>> […]

Working with botocore’s ~/.aws/config

This entry is part 2 of 6 in the series Boto

This entry is part 2 of 6 in the series Boto I ran into a bug in botocore and this post will serve to document a work around as well as show how to use botocore session object to work with the values stored in ~/.aws/config. Pretend you have an aws config with two accounts […]

A Python script which searches for available interpreters

This entry is part 5 of 6 in the series Boto

This entry is part 5 of 6 in the series Boto This post describes how to write a polyglot — in this case a script which runs as valid Bash or Python, to search for available Python interpreters. The script initially runs as Bash but upon finding a first match, the script will call itself […]

Migrating libvirt KVM guest to SmartOS KVM guest

The following tutorial documents how to migrate a libvirt/KVM guest from Ubuntu to SmartOS. akuma: Ubuntu Hypervisor guy: SmartOS Hypervisor sagat: guest to migrate These commands were run on akuma: WORKDIR=/KVMROOT/migrate sudo mkdir $WORKDIR cd $WORKDIR # this tool simply stops and tarballs up the qcow and xml for libvirt KVM guest. sudo /usr/local/bin/virt-back –path=$WORKDIR […]

Setting region programmatically in Boto3

This entry is part 3 of 6 in the series Boto

This entry is part 3 of 6 in the series Boto At work I’m looking into the possibility of porting parts of our AWS automation codebase from Boto2 to Boto3. We desire to perform this port because Boto2’s record and result pagination appears defective. I started to familiarize myself with Boto3 by using the Interactive […]

Securely publish Jenkins build artifacts on Salt Master

Do you want a secure setup for publishing and staging build artifacts from a Jenkins build server to a Salt Master? This guide describes my fully automated pipeline to transport binaries using Salt’s encrypted “bus”. We start off with some Salt States to stand up a Jenkins build server “client”: jenkins/client.sls: # http://russell.ballestrini.net/securely-publish-jenkins-build-artifacts-on-salt-master/ # manage […]

Set postgres user password on PostgreSQL SmartOS Zone

Connect to zone and determine the auto generated password for postgres user: cat /var/svc/log/system-zoneinit\:default.log | grep PGSQL_PW document the result and log into postgres with the following command, entering the password when prompted: [root@psql ~]# psql –user postgres Alter the postgres role’s password: postgres=# ALTER ROLE postgres UNENCRYPTED PASSWORD ‘new-password’; Now exit (\q) then try […]

Risk, Process, and Balance

The operations of a company will have intrinsic risk. Risk occurs each time we decide to take an action or an inaction. This means that anything we choose to do, or not do, has associated risk. An organization which has an unhealthy aversion to risk has a much higher chance of failure. As time goes […]