Chris's Blog

Devops Shokunin

Better EC2 facts for Puppet

1 Comment »

I didn’t like the facts that came with the standard facter for ec2, so I wrote a custom fact plugin returning more detailed information.

It’s available on my GitHub

Sample output is below

 
ec2_ami_id => ami-cdXXXXXX
ec2_ami_launch-index => 0
ec2_ami_manifest-path => myamis/lenny-XXXXXXX-x86-20101207.manifest.xml
ec2_ancestor_ami-ids => ami-XXXXXXXX,ami-XXXXXXXXXX
ec2_block_device-mapping_ami => sda1
ec2_block_device-mapping_ephemeral0 => sda2
ec2_block_device-mapping_root => /dev/sda1
ec2_block_device-mapping_swap => sda3
ec2_hostname => ip-10-XXX-XXX-XXX.us-XXXXX-X.compute.internal
ec2_instance_action => none
ec2_instance_id => i-XXXXXX
ec2_instance_type => m1.small
ec2_kernel_id => aki-XXXXX
ec2_local_hostname => ip-XX-XXX-XXX-XXX.us-XXX-X.compute.internal
ec2_local_ipv4 => 10.10.10.10
ec2_placement_availability_zone => us-west-1b
ec2_profile => default-paravirtual
ec2_public_hostname => ec2-XX-XX-XX-XXX.us-west-1.compute.amazonaws.com
ec2_public_ipv4 => XXX.XXX.XXX.XXX
ec2_ramdisk_id => ari-XXXXXX
ec2_reservation_id => r-XXXX
ec2_security_groups => default,application1,application2

One Response

FYI. /usr/lib/ruby/site_ruby/1.8/facter/ec2.rb
Gets all that info, but has a bug.
See here: http://groups.google.com/group/puppet-dev/browse_thread/thread/ab1570b7fc9c49fd/c7fa205e641bec46

Once patched you get the following:

ec2_ami_id => ami-XXXXXXXX
ec2_ami_launch_index => 0
ec2_ami_manifest_path => (unknown)
ec2_block_device_mapping_ami => /dev/sda1
ec2_block_device_mapping_root => /dev/sda1
ec2_hostname => ip-XX-XX-XX-XX.ec2.internal
ec2_instance_id => i-XXXXXXX
ec2_instance_type => m1.large
ec2_kernel_id => aki-b51cf9d
ec2_local_hostname => ip-10-100-XX-XX.ec2.internal
ec2_local_ipv4 => 10.100.XX.XX
ec2_placement_availability_zone => us-east-1a
ec2_profile => default-paravirtual
ec2_public_hostname => ec2-174-129-XX-XX.compute-1.amazonaws.com
ec2_public_ipv4 => 174.129.XX.XX
ec2_public_keys_0_openssh_key => ssh-rsa XXXX
ec2_ramdisk_id => ari-b31cf9d
ec2_reservation_id => r-XXXXXXXX
ec2_security_groups => default