This repository was archived by the owner on Jun 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 217
Launch configuration/associate public ip #312
Open
benpillet
wants to merge
6
commits into
puppetlabs-toy-chest:master
Choose a base branch
from
benpillet:launch_configuration/associate_public_ip
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5125b34
Draft of associate_public_ip_address
benpillet 2edf3a1
Add unit test of type launchconfig associate_public_ip_address
benpillet 3355ad9
Add provider test for associate_public_ip_address
benpillet 69ed8aa
Cleanup extra cruft
benpillet d05293b
Add README doc
benpillet 4064e00
Make associate_public_ip_address a property boolean
benpillet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ def self.prefetch(resources) | |
def self.config_to_hash(region, config) | ||
# It appears possible to get launch configurations manually to a state where | ||
# they return the identifier of an invalid or a non-existent security groups | ||
# puts "config_to_hash(#{config})" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Odd indentation. |
||
security_group_names = begin | ||
group_response = ec2_client(region).describe_security_groups(group_ids: config.security_groups) | ||
group_response.data.security_groups.collect(&:group_name) | ||
|
@@ -49,7 +50,8 @@ def self.config_to_hash(region, config) | |
image_id: config.image_id, | ||
key_name: config.key_name, | ||
ensure: :present, | ||
region: region | ||
region: region, | ||
associate_public_ip_address: config.associate_public_ip_address, | ||
} | ||
end | ||
|
||
|
@@ -89,6 +91,7 @@ def create | |
security_groups: group_ids, | ||
instance_type: resource[:instance_type], | ||
user_data: data, | ||
associate_public_ip_address: resource[:associate_public_ip_address], | ||
} | ||
|
||
key = resource[:key_name] ? resource[:key_name] : false | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
require 'puppet/property/boolean' | ||
|
||
Puppet::Type.newtype(:ec2_launchconfiguration) do | ||
@doc = 'Type representing an EC2 launch configuration.' | ||
|
||
|
@@ -67,6 +69,19 @@ def insync?(is) | |
end | ||
end | ||
|
||
newproperty(:associate_public_ip_address, :boolean => true, :parent => Puppet::Property::Boolean) do | ||
desc 'Specifies whether to assign a public IP address to each instance launched in a Amazon VPC. If the instance is launched into a default subnet, the default is true.' | ||
defaultto :true | ||
newvalues(:true, :false) | ||
def insync?(is) | ||
is.to_s == should.to_s | ||
end | ||
|
||
def set(value) | ||
read_only_warning(value, self, should) | ||
end | ||
end | ||
|
||
autorequire(:ec2_securitygroup) do | ||
groups = self[:security_groups] | ||
groups.is_a?(Array) ? groups : [groups] | ||
|
@@ -77,3 +92,9 @@ def insync?(is) | |
end | ||
|
||
end | ||
def read_only_warning(value, property, should) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The module already has the ability for marking properties read-only; why this addition? |
||
msg = "#{property.name} is read-only. Cannot set to: #{should}" | ||
Puppet.warning msg | ||
#raise Puppet::Error, msg | ||
false | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs describe block devices; is that copy/paste?