Skip to content

Instantly share code, notes, and snippets.

@clarabstract
Created July 29, 2014 21:02
Show Gist options
  • Select an option

  • Save clarabstract/b44389f68becd46e8975 to your computer and use it in GitHub Desktop.

Select an option

Save clarabstract/b44389f68becd46e8975 to your computer and use it in GitHub Desktop.
Puppet: The End of Reason
Puppet::Type.newtype(:aws_security_group) do
@doc = "Manage AWS Security Groups"
newparam(:name)
ensurable
newproperty(:description)
newproperty(:vpc)
autorequire(:aws_vpc) do
self[:vpc]
end
newproperty(:tags)
newproperty(:authorize_ingress) do
end
newproperty(:authorize_egress) do
end
end
# running apply noop
#Notice:
# .. /Aws_security_group[default]/authorize_ingress:
# current_value
{"protocol"=>"any", "ports"=>[], "sources"=>["0.0.0.0/0"]},
#should be
{"protocol"=>"any", "ports"=>[], "sources"=>["default"]}
# HI, where is my second array element pretty please?
# Ok, what if we do this?
newproperty(:authorize_ingress, :array_matching => :all) do
end
# Notice:
# .../Aws_security_group[default]/authorize_ingress:
# current_value
{"protocol"=>"any", "ports"=>[], "sources"=>["0.0.0.0/0"]},
#, should be
{"protocol"=>"any", "ports"=>[], "sources"=>["default"]} {"protocol"=>"tcp", "ports"=>"22", "sources"=>["0.0.0.0/0"]}
# WTF is this? Why isn't it an Array? Where are the []s and the separating comma?
# Is it actually a string? (btw, yes, yes it is)
# Why?
# WHY PUPPET, WHY?
aws_security_group {'default':
ensure => $ensure,
vpc => "$name-vpc",
authorize_ingress => [
{
protocol => 'any',
ports => [],
sources => ['default']
},
{
protocol => 'tcp',
ports => 22,
sources => ['0.0.0.0/0'],
},
],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment