specinfra 2.89.0 → 2.90.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e50bdeee324833215a1b15370cfc44ef242b6c52dfd9dac888bd2391fb9e7de
4
- data.tar.gz: a99274248ab6323eea1f84a5692bb73aab86288169e70ee71d743a981b0a5e13
3
+ metadata.gz: d6192f34de8d2414c066911812cd4542641339486662cf67cdd02429ce627d1b
4
+ data.tar.gz: d6c662a4bb193a898b212af07665aa3f6c91b61f58bd7027873ac16b05837450
5
5
  SHA512:
6
- metadata.gz: 9fa6eacae5f42b7dca7743d83b052e0bdd9e3077649baa0638c3ba9bc7e7f6f3d2f8faa743c5bf3a36fdda7e7d068868f57830cdcf19b33a21f3519aa08a3849
7
- data.tar.gz: 97227f5e2114863c8afee052c8dd207fa4a2f20bc07b5e4c8b43a030cd44811764f7fb1ab0c16267dfc4bcf2c8968d6b87cd7c0944b567db0f8d0a025edac503
6
+ metadata.gz: 268a137b4e34aeecfe587e98cc8fe9dc635d7342d5543f4848c6aa413d82a13015f59d6a12948a9260b41394d7b0c6be110bee1b81c29869b09f84ec8901d2fa
7
+ data.tar.gz: 801e515067828d8faa1dfcdd6df2d25ba87da81949b85353bd7bf43dd70bc96ef45c02ad74b59d2395d48ce9414eac933799264af0a5037605e7c17adba21a8f
@@ -5,10 +5,13 @@ module Specinfra
5
5
  @host_inventory = host_inventory
6
6
 
7
7
  @base_uri = 'http://169.254.169.254/latest/meta-data/'
8
+ @token_uri = 'http://169.254.169.254/latest/api/token'
9
+ @token = ''
8
10
  @metadata = {}
9
11
  end
10
12
 
11
13
  def get
14
+ @token = get_token
12
15
  @metadata = get_metadata
13
16
  self
14
17
  end
@@ -64,7 +67,7 @@ module Specinfra
64
67
  def get_metadata(path='')
65
68
  metadata = {}
66
69
 
67
- keys = @host_inventory.backend.run_command("curl -s #{@base_uri}#{path}").stdout.split("\n")
70
+ keys = @host_inventory.backend.run_command("curl -H \"X-aws-ec2-metadata-token: #{@token}\" -s #{@base_uri}#{path}").stdout.split("\n")
68
71
 
69
72
  keys.each do |key|
70
73
  if key =~ %r{/$}
@@ -84,7 +87,16 @@ module Specinfra
84
87
  end
85
88
 
86
89
  def get_endpoint(path)
87
- ret = @host_inventory.backend.run_command("curl -s #{@base_uri}#{path}")
90
+ ret = @host_inventory.backend.run_command("curl -H \"X-aws-ec2-metadata-token: #{@token}\" -s #{@base_uri}#{path}")
91
+ if ret.success?
92
+ ret.stdout
93
+ else
94
+ nil
95
+ end
96
+ end
97
+
98
+ def get_token
99
+ ret = @host_inventory.backend.run_command("curl -X PUT -H \"X-aws-ec2-metadata-token-ttl-seconds: 21600\" -s #{@token_uri}")
88
100
  if ret.success?
89
101
  ret.stdout
90
102
  else
@@ -1,5 +1,5 @@
1
1
  module Specinfra
2
- VERSION = "2.89.0"
2
+ VERSION = "2.90.1"
3
3
 
4
4
  def self.ruby_is_older_than?(*version)
5
5
  (RUBY_VERSION.split('.').map(&:to_i) <=> version) < 0
data/specinfra.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  # TODO: at some point pin to a minumum version of ruby to reduce support burden in a major version bump
20
20
  # spec.required_ruby_version = '>= 2.3.0'
21
21
 
22
+ spec.add_runtime_dependency "base64"
22
23
  spec.add_runtime_dependency "net-scp"
23
24
  spec.add_runtime_dependency "net-ssh", ">= 2.7"
24
25
  spec.add_runtime_dependency "net-telnet" # intentionally version-unspecified for Ruby older than 2.3.0
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.89.0
4
+ version: 2.90.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-13 00:00:00.000000000 Z
11
+ date: 2024-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: base64
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: net-scp
15
29
  requirement: !ruby/object:Gem::Requirement