"Building on Puppet and Puppet Forge" by Pedro Pessoa of Server Density at Puppet Camp London 2014. Find the video here: http://puppetlabs.com/community/puppet-camp
3. HTTP Load Balancer
from Pound to nginx
Server Density v2:
New version : new load balancer
nginx :
- WebSockets
- SPDY standard
keep :
- modules pulled from our Gihub repo by the
puppet master
- use of Puppet Console and Live Management
to trigger transient changes
4. Reinventing the wheel
(don't)
Writing our nginx module?
- add yet another one to the collection of
in-house developed modules
community reach?
- whether our problem had already been solved
- or a kick start where we could stand on
http://www.flickr.com/photos/conskeptical/
7. Integration
A) get the actual code into the master
puppet module install puppetlabs/nginx
(or)
git submodule add https://github.com/puppetlabs/puppetlabsnginx.git
B) run it on existing nodes
no parameterized classes on PE Console (2.8.x)
(or)
merge our site.pp (which is empty) and the console,
it being an ENC and all - (how-merging-works)
14. Alternatives
Puppet Labs nginx module:
https://github.com/serverdensity/puppetlabs-nginx
forked James Fryman's module:
https://github.com/jfryman/puppet-nginx
pick the later? Puppet Labs last update - 30th June
2011.
https://github.com/serverdensity/puppetlabs-nginx
15. Extending Server Density
Server Density collects server data from an open
source agent deployed on each device
Create a device on Server Density UI
Copy the device ID (agent key)
The agent reads the device ID from a config file:
[Main]
sd_url: http://mydomain.serverdensity.com
agent_key: 8160b409de9d8a612ec8d964c5b26bf
(...)
21. Extending Server Density
Server Density v2 - implementation:
Manages the life cycle of Rackspace and Amazon
cloud instances
A custom fact will return the cloud instance agent key
or use Server Density API to create a device on the
fly and return the resulting agent key
https://github.com/serverdensity/puppet-serverdensity
22. Extending Server Density
Custom fact:
Facter.add(:agent_key, :timeout => 10) do
if File::exist?('/etc/sdagentkey')
result = Facter::Util::Resolution.exec("cat /etc/sdagentkey")
elsif Facter.value('ec2_instance_id')
uri = URI("http://ec2meta.serverdensity.com/latest/userdata")
req = Net::HTTP::Get.new(uri.request_uri)
res = Net::HTTP.start(uri.host, uri.port) {|http|
http.request(req)
}
result = res.body.split(':').last if res.code == 200
end
setcode { result }
end
23. Extending Server Density
Custom function:
(...)
agent_key = lookupvar("agent_key")
# lookupvar returns undef if no value
# test against nil just in case
unless agent_key.nil? or agent_key == :undef
notice ["Agent Key Provided via Facter: #{ agent_key }"]
return agent_key
End
(...)