lib/ohai/plugins/ec2.rb in ohai-8.6.0.alpha.1 vs lib/ohai/plugins/ec2.rb in ohai-8.6.0
- old
+ new
@@ -16,10 +16,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'ohai/mixin/ec2_metadata'
+require 'base64'
Ohai.plugin(:EC2) do
include Ohai::Mixin::Ec2Metadata
provides "ec2"
@@ -56,9 +57,14 @@
# http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html#instancedata-data-categories
next if k == 'iam' && !hint?('iam')
ec2[k] = v
end
ec2[:userdata] = self.fetch_userdata
+ #ASCII-8BIT is equivalent to BINARY in this case
+ if ec2[:userdata].encoding.to_s == "ASCII-8BIT"
+ Ohai::Log.debug("Binary UserData Found. Storing in base64")
+ ec2[:userdata] = Base64.encode64(ec2[:userdata])
+ end
else
Ohai::Log.debug("looks_like_ec2? == false")
false
end
end