ansible_tower_client 0.20.0 → 0.21.2

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: '08f27f29feac6a32266e5c3f567a410d90caf9fb11cce3c3d7c079145784280e'
4
- data.tar.gz: 9136eeeab2dc3dbb0ac23dc72905e8e8ee19a0c73a1031693d00519671e7331c
3
+ metadata.gz: d12a1f9a637375a1f8aaa70f88f936ddc03f3fcd9731bbfcb6cfa497eec3a27a
4
+ data.tar.gz: 1819f01be11621925cd615ba65622a6d7f673cce55b0cae731cbc9f87be5a515
5
5
  SHA512:
6
- metadata.gz: 49034faefae5375f52d9e45afde8173bfb15430ad1e0ff0bc29b82a6e79ce1c69ea5a557a7fed788fcfecfcaa43822214fec8d088062ee7d0e4cf67c9465885e
7
- data.tar.gz: 8f31190deca0df56e1d21429a39e9eae367322d714a912f8a1bbf18deb9daba1b88eb597b790e10c878662e26fd37dbf8cc1c84242b17bb16656d138d4b64030
6
+ metadata.gz: d2b01f2da1c0d796a16463c67cc09023de86d33ab6f5d5b7808e023cb618e5598481b974b2b1744bd6c867c25172a124f7fd0755745160f04749fd9e26a1e470
7
+ data.tar.gz: 6b284cd8f8953f8cfc6e68b4239298dd88476391f5c92f4e87491cb5e3b95e48ca76cf684987140eee633aadd1dfdb8390eefc6b5b3b7ed3c483bbfb11416591
@@ -5,6 +5,34 @@ This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.21.2] - 2020-06-09
9
+ ### Fixed
10
+ - Return AnsibleTowerClient::ConnectionError if not able to parse response in #verify_credentials [(#144)](https://github.com/ansible/ansible_tower_client_ruby/pull/144)
11
+
12
+ ## [0.21.1] - 2020-02-17
13
+ ### Fixed
14
+ - Revert removal of trailing "/" on get of "config" [(#141)](https://github.com/ansible/ansible_tower_client_ruby/pull/141)
15
+
16
+ ## [0.21.0] - 2020-02-12
17
+ ### Added
18
+ - Add support for connection headers and proxy [(#134)](https://github.com/ansible/ansible_tower_client_ruby/pull/134)
19
+ - Allow request options to be passed to Faraday [(#140)](https://github.com/ansible/ansible_tower_client_ruby/pull/140)
20
+ - Add usage documentation to the README [(#138)](https://github.com/ansible/ansible_tower_client_ruby/pull/138)
21
+
22
+ ### Fixed
23
+ - Fix issue where passing no options gives a NilError [(#136)](https://github.com/ansible/ansible_tower_client_ruby/pull/136)
24
+
25
+ ### Changed
26
+ - Extract MockApi responses into JSON files [(#137)](https://github.com/ansible/ansible_tower_client_ruby/pull/137)
27
+
28
+ ## [0.20.2] - 2019-08-19
29
+ ### Fixed
30
+ - Ensure #vault_password is never nil [(#132)](https://github.com/ansible/ansible_tower_client_ruby/pull/132)
31
+
32
+ ## [0.20.1] - 2019-06-20
33
+ ### Fixed
34
+ - Only attempt to find a related job if there is a reference to one [(#131)](https://github.com/ansible/ansible_tower_client_ruby/pull/131)
35
+
8
36
  ## [0.20.0] - 2019-05-22
9
37
  ### Added
10
38
  - Added support for v2 API credential objects [(#123)](https://github.com/ansible/ansible_tower_client_ruby/pull/123)
@@ -118,7 +146,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
118
146
  ### Fixed
119
147
  - Adjusted project_spec to test on a Project [(#63)](https://github.com/ansible/ansible_tower_client_ruby/pull/63)
120
148
 
121
- [Unreleased]: https://github.com/ansible/ansible_tower_client_ruby/compare/v0.20.0...master
149
+ [Unreleased]: https://github.com/ansible/ansible_tower_client_ruby/compare/v0.21.2...master
150
+ [0.21.2]: https://github.com/ansible/ansible_tower_client_ruby/compare/v0.21.1...v0.21.2
151
+ [0.21.1]: https://github.com/ansible/ansible_tower_client_ruby/compare/v0.21.0...v0.21.1
152
+ [0.21.0]: https://github.com/ansible/ansible_tower_client_ruby/compare/v0.20.2...v0.21.0
153
+ [0.20.2]: https://github.com/ansible/ansible_tower_client_ruby/compare/v0.20.1...v0.20.2
154
+ [0.20.1]: https://github.com/ansible/ansible_tower_client_ruby/compare/v0.20.0...v0.20.1
122
155
  [0.20.0]: https://github.com/ansible/ansible_tower_client_ruby/compare/v0.19.1...v0.20.0
123
156
  [0.19.1]: https://github.com/ansible/ansible_tower_client_ruby/compare/v0.19.0...v0.19.1
124
157
  [0.19.0]: https://github.com/ansible/ansible_tower_client_ruby/compare/v0.18.0...v0.19.0
data/Gemfile CHANGED
@@ -1,11 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ plugin "bundler-inject", "~> 1.1"
4
+ require File.join(Bundler::Plugin.index.load_paths("bundler-inject")[0], "bundler-inject") rescue nil
5
+
3
6
  # Specify your gem's dependencies in ansible_tower_client.gemspec
4
7
  gemspec
5
-
6
- # Pull in a development Gemfile if one exists
7
- eval_gemfile('Gemfile.dev.rb') if File.exists?('Gemfile.dev.rb')
8
-
9
- # HACK: Rails 5 dropped support for Ruby < 2.2.2
10
- active_support_version = "< 5" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2.2")
11
- gem "activesupport", active_support_version
data/README.md CHANGED
@@ -23,6 +23,36 @@ Or install it yourself as:
23
23
 
24
24
  $ gem install ansible_tower_client
25
25
 
26
+ ## Usage
27
+
28
+ ```ruby
29
+ require 'ansible_tower_client'
30
+
31
+ # Optionally set a global logger
32
+ AnsibleTowerClient.logger = Logger.new(STDOUT)
33
+
34
+ # Create a connection
35
+ conn = AnsibleTowerClient::Connection.new(
36
+ :base_url => "https://awx.example.com/",
37
+ :username => "admin",
38
+ :password => "pa$$w0rd!",
39
+ :verify_ssl => OpenSSL::SSL::VERIFY_PEER # Optional: an OpenSSL::SSL::VERIFY_* constant
40
+ )
41
+
42
+ # Query the config
43
+ conn.api.config
44
+ # => {"eula"=>"text"
45
+ # "version"=>"3.2.2",
46
+ # "project_base_dir"=>"/var/lib/awx/projects",
47
+ # "ansible_version"=>"2.4.1.0",
48
+ # ...}
49
+
50
+ # Query a collection
51
+ conn.api.job_templates.all
52
+ # => [<AnsibleTowerClient::JobTemplate id=580, type="job_template", url="/api/v1/job_templates/580/", name="ems_refresh_spec-job_template", description="EmsRefreshSpec JobTemplate", ...>
53
+ # <AnsibleTowerClient::JobTemplate id=585, type="job_template", url="/api/v1/job_templates/585/", name="ems_refresh_spec-job_template2", description="EmsRefreshSpec JobTemplate", ...>]
54
+ ```
55
+
26
56
  ## Development
27
57
 
28
58
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -20,7 +20,10 @@ module AnsibleTowerClient
20
20
  end
21
21
 
22
22
  def verify_credentials
23
- JSON.parse(get("me/").body).fetch_path("results", 0, "username")
23
+ results = get("me/").body
24
+ JSON.parse(results).fetch_path("results", 0, "username")
25
+ rescue JSON::ParserError
26
+ raise AnsibleTowerClient::ConnectionError, "unexpected response"
24
27
  end
25
28
 
26
29
  def activity_stream
@@ -39,7 +39,10 @@ module AnsibleTowerClient
39
39
  end
40
40
 
41
41
  def vault_password
42
- @data['vault_password'] ||= inputs.vault_password.to_s
42
+ @data['vault_password'] ||= begin
43
+ has_vault_password = respond_to?(:inputs) && inputs.respond_to?(:vault_password)
44
+ (inputs.vault_password if has_vault_password).to_s
45
+ end
43
46
  end
44
47
  end
45
48
  end
@@ -5,7 +5,14 @@ module AnsibleTowerClient
5
5
  end
6
6
 
7
7
  def job
8
- api.jobs.find(job_id) if respond_to?(:job_id) && job_id
8
+ api.jobs.find(job_id) if job?
9
+ end
10
+
11
+ # to filter out WorkflowJobNode that is inventory sync or project sync
12
+ def job?
13
+ return false if !respond_to?(:job_id) || job_id.nil?
14
+
15
+ related.job.match?(/jobs/)
9
16
  end
10
17
  end
11
18
  end
@@ -5,8 +5,9 @@ module AnsibleTowerClient
5
5
  attr_reader :connection
6
6
 
7
7
  def initialize(options = nil)
8
- raise "Credentials are required" unless options[:username] && options[:password]
8
+ raise ":username and :password are required" if options.nil? || !options[:username] || !options[:password]
9
9
  raise ":base_url is required" unless options[:base_url]
10
+
10
11
  logger = options[:logger] || AnsibleTowerClient.logger
11
12
  verify_ssl = options[:verify_ssl] || OpenSSL::SSL::VERIFY_PEER
12
13
  verify_ssl = verify_ssl == OpenSSL::SSL::VERIFY_NONE ? false : true
@@ -15,7 +16,13 @@ module AnsibleTowerClient
15
16
  require 'faraday_middleware'
16
17
  require 'ansible_tower_client/middleware/raise_tower_error'
17
18
  Faraday::Response.register_middleware :raise_tower_error => -> { Middleware::RaiseTowerError }
18
- @connection = Faraday.new(options[:base_url], :ssl => {:verify => verify_ssl}) do |f|
19
+
20
+ connection_opts = { :ssl => {:verify => verify_ssl} }
21
+ connection_opts[:proxy] = options[:proxy] if options[:proxy].present?
22
+ connection_opts[:headers] = options[:headers] if options[:headers].present?
23
+ connection_opts[:request] = options[:request] if options[:request].present?
24
+
25
+ @connection = Faraday.new(options[:base_url], connection_opts) do |f|
19
26
  f.use(FaradayMiddleware::EncodeJson)
20
27
  f.use(FaradayMiddleware::FollowRedirects, :limit => 3, :standards_compliant => true)
21
28
  f.request(:url_encoded)
@@ -1,3 +1,3 @@
1
1
  module AnsibleTowerClient
2
- VERSION = "0.20.0".freeze
2
+ VERSION = "0.21.2".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ansible_tower_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.21.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Dunne
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-05-22 00:00:00.000000000 Z
12
+ date: 2020-06-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -183,8 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
183
  - !ruby/object:Gem::Version
184
184
  version: '0'
185
185
  requirements: []
186
- rubyforge_project:
187
- rubygems_version: 2.7.6.2
186
+ rubygems_version: 3.0.6
188
187
  signing_key:
189
188
  specification_version: 4
190
189
  summary: Ansible Tower REST API wrapper gem