ansible-wrapper 0.2.2 → 0.3.0

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: 2e5caf4e2e2b9582a3d4440288160b30e51895cab153c2cb6194fcc38f682144
4
- data.tar.gz: fc87385c8a099a7fb357a9d89a2b21c024dffa0534861b4afa9165def73d30cb
3
+ metadata.gz: 6e35370e56d2b0876cbfda0e4882a200ef13a264b7a69ddbdec2a7ce6d35b454
4
+ data.tar.gz: ad30a73f31c1502a9ae1180be242f5578dee582996d27a2cad523bce7fb6babf
5
5
  SHA512:
6
- metadata.gz: ed22098776f0eb16adcf65707310e85c982d04a050505d0ffcfb8fb701ccce106f665d1bf6710bf25f738c41e650e32ca404f958304bd0c97bcacf858030db6f
7
- data.tar.gz: 1d1ae31bbfd9cc8c4f1453bebc24d47a9a2e29496cf27efd924e6c3ec567e97becc489319aee5fe9bfe3752c180199b22574cb737d2c668eb728734bda7ff4c1
6
+ metadata.gz: 6cf8972c31e77a3b336c13ba884472c17b250adb18d797487a049beafbe0d55bd9fd616e83e22be6cbc2e42505011b048b215358f3a8b9c3b8a32e8a20c02a64
7
+ data.tar.gz: fc671344ebdee92cdec17d2cb823f40cecdf217f3b81dcd16f01d263bb878537b551fd810079264fb3d997dce20d38020ae758828fe87e391bcaae95e65d08f9
@@ -8,9 +8,10 @@ jobs:
8
8
  strategy:
9
9
  matrix:
10
10
  ansible:
11
- - 2.8.5
12
- - 2.7.12
13
- - 2.6.19
11
+ - 2.9.6
12
+ - 2.8.10
13
+ - 2.7.16
14
+ - 2.6.20
14
15
  - 2.5.15
15
16
  - 2.4.6
16
17
  - 2.3.3
@@ -19,30 +20,38 @@ jobs:
19
20
  - 2.0.2
20
21
  steps:
21
22
  - uses: actions/checkout@v1
22
- - name: Test against Ruby 2.6.4
23
+ - name: Test against Ruby 2.7.0
23
24
  env:
24
- RUBY_VERSION: 2.6.4
25
+ RUBY_VERSION: 2.7.0
25
26
  ANSIBLE_VERSION: ${{ matrix.ansible }}
26
27
  run: >
27
28
  docker run --rm -v $PWD:/app pgeraghty/ansible-ruby:$RUBY_VERSION-$ANSIBLE_VERSION
28
- /bin/sh -c "cd /app && bundle install --jobs=3 --retry=3 &&
29
+ /bin/sh -c "cp -r /app /tmp/app && cd /tmp/app && bundle install --jobs=3 --retry=3 &&
29
30
  COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_REPO_TOKEN }} COVERALLS_RUN_LOCALLY=true bundle exec rake"
30
31
 
31
- - name: Test against Ruby 2.5.6
32
+ - name: Test against Ruby 2.6.5
32
33
  env:
33
- RUBY_VERSION: 2.5.6
34
+ RUBY_VERSION: 2.6.5
34
35
  ANSIBLE_VERSION: ${{ matrix.ansible }}
35
36
  run: >
36
37
  docker run --rm -v $PWD:/app pgeraghty/ansible-ruby:$RUBY_VERSION-$ANSIBLE_VERSION
37
- /bin/sh -c "cd /app && bundle install --jobs=3 --retry=3 && bundle exec rake"
38
+ /bin/sh -c "cp -r /app /tmp/app && cd /tmp/app && bundle install --jobs=3 --retry=3 && bundle exec rake"
38
39
 
39
- - name: Test against Ruby 2.4.7
40
+ - name: Test against Ruby 2.5.7
40
41
  env:
41
- RUBY_VERSION: 2.4.7
42
+ RUBY_VERSION: 2.5.7
42
43
  ANSIBLE_VERSION: ${{ matrix.ansible }}
43
44
  run: >
44
45
  docker run --rm -v $PWD:/app pgeraghty/ansible-ruby:$RUBY_VERSION-$ANSIBLE_VERSION
45
- /bin/sh -c "cd /app && bundle install --jobs=3 --retry=3 && bundle exec rake"
46
+ /bin/sh -c "cp -r /app /tmp/app && cd /tmp/app && bundle install --jobs=3 --retry=3 && bundle exec rake"
47
+
48
+ - name: Test against Ruby 2.4.9
49
+ env:
50
+ RUBY_VERSION: 2.4.9
51
+ ANSIBLE_VERSION: ${{ matrix.ansible }}
52
+ run: >
53
+ docker run --rm -v $PWD:/app pgeraghty/ansible-ruby:$RUBY_VERSION-$ANSIBLE_VERSION
54
+ /bin/sh -c "cp -r /app /tmp/app && cd /tmp/app && bundle install --jobs=3 --retry=3 && bundle exec rake"
46
55
 
47
56
  - name: Test against Ruby 2.3.7
48
57
  env:
@@ -50,7 +59,7 @@ jobs:
50
59
  ANSIBLE_VERSION: ${{ matrix.ansible }}
51
60
  run: >
52
61
  docker run --rm -v $PWD:/app pgeraghty/ansible-ruby:$RUBY_VERSION-$ANSIBLE_VERSION
53
- /bin/sh -c "cd /app && bundle install --jobs=3 --retry=3 && bundle exec rake"
62
+ /bin/sh -c "cp -r /app /tmp/app && cd /tmp/app && bundle install --jobs=3 --retry=3 && bundle exec rake"
54
63
 
55
64
  - name: Test against Ruby 2.2.7
56
65
  env:
@@ -58,7 +67,7 @@ jobs:
58
67
  ANSIBLE_VERSION: ${{ matrix.ansible }}
59
68
  run: >
60
69
  docker run --rm -v $PWD:/app pgeraghty/ansible-ruby:$RUBY_VERSION-$ANSIBLE_VERSION
61
- /bin/sh -c "cd /app && bundle install --jobs=3 --retry=3 && bundle exec rake"
70
+ /bin/sh -c "cp -r /app /tmp/app && cd /tmp/app && bundle install --jobs=3 --retry=3 && bundle exec rake"
62
71
 
63
72
  - name: Test against Ruby 2.1.10
64
73
  env:
@@ -66,4 +75,4 @@ jobs:
66
75
  ANSIBLE_VERSION: ${{ matrix.ansible }}
67
76
  run: >
68
77
  docker run --rm -v $PWD:/app pgeraghty/ansible-ruby:$RUBY_VERSION-$ANSIBLE_VERSION
69
- /bin/sh -c "cd /app && bundle install --jobs=3 --retry=3 && bundle exec rake"
78
+ /bin/sh -c "cp -r /app /tmp/app && cd /tmp/app && bundle install --jobs=3 --retry=3 && bundle exec rake"
@@ -2,25 +2,36 @@ language: bash
2
2
  services:
3
3
  - docker
4
4
  env:
5
- - ANSIBLE_VERSION=2.8.5
6
- - ANSIBLE_VERSION=2.7.12
7
- - ANSIBLE_VERSION=2.6.19
8
- - ANSIBLE_VERSION=2.5.15
9
- - ANSIBLE_VERSION=2.4.6
10
- - ANSIBLE_VERSION=2.3.3
11
- - ANSIBLE_VERSION=2.2.3
12
- - ANSIBLE_VERSION=2.1.6
13
- - ANSIBLE_VERSION=2.0.2
5
+ global:
6
+ - CC_TEST_REPORTER_ID=2c0e6ce9e61357e6f15cf76a915b3868235d93e0b849218220242e456bfaa2aa
7
+ matrix:
8
+ - ANSIBLE_VERSION=2.8.10
9
+ - ANSIBLE_VERSION=2.7.16
10
+ - ANSIBLE_VERSION=2.6.20
11
+ - ANSIBLE_VERSION=2.5.15
12
+ - ANSIBLE_VERSION=2.4.6
13
+ - ANSIBLE_VERSION=2.3.3
14
+ - ANSIBLE_VERSION=2.2.3
15
+ - ANSIBLE_VERSION=2.1.6
16
+ - ANSIBLE_VERSION=2.0.2
17
+ before_script:
18
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
19
+ - chmod +x ./cc-test-reporter
14
20
  script:
15
21
  - >
16
- RUBY=2.6.4 && docker run --rm -e TRAVIS -e TRAVIS_JOB_ID -e TRAVIS_BRANCH -e TRAVIS_PULL_REQUEST -it
17
- -v $PWD:/app pgeraghty/ansible-ruby:$RUBY-$ANSIBLE_VERSION /bin/sh -c
18
- "cd /app && bundle install --jobs=3 --retry=3 && CI=true bundle exec rake"
22
+ RUBY=2.7.0 && docker run --rm -e TRAVIS -e TRAVIS_JOB_ID -e TRAVIS_BRANCH -e TRAVIS_PULL_REQUEST
23
+ -e CC_TEST_REPORTER_ID -it -v $PWD:/app pgeraghty/ansible-ruby:$RUBY-$ANSIBLE_VERSION /bin/sh -c
24
+ "cd /app && bundle install --jobs=3 --retry=3 &&
25
+ ./cc-test-reporter before-build &&
26
+ CI=true bundle exec rake && rm Gemfile.lock"
19
27
  - >
20
- RUBY=2.5.6 && docker run --rm -it -v $PWD:/app pgeraghty/ansible-ruby:$RUBY-$ANSIBLE_VERSION
28
+ RUBY=2.6.5 && docker run --rm -it -v $PWD:/app pgeraghty/ansible-ruby:$RUBY-$ANSIBLE_VERSION
29
+ /bin/sh -c "cp -r /app /tmp/app && cd /tmp/app && bundle install --jobs=3 --retry=3 && bundle exec rake"
30
+ - >
31
+ RUBY=2.5.7 && docker run --rm -it -v $PWD:/app pgeraghty/ansible-ruby:$RUBY-$ANSIBLE_VERSION
21
32
  /bin/sh -c "cd /app && bundle install --jobs=3 --retry=3 && bundle exec rake"
22
33
  - >
23
- RUBY=2.4.7 && docker run --rm -it -v $PWD:/app pgeraghty/ansible-ruby:$RUBY-$ANSIBLE_VERSION
34
+ RUBY=2.4.9 && docker run --rm -it -v $PWD:/app pgeraghty/ansible-ruby:$RUBY-$ANSIBLE_VERSION
24
35
  /bin/sh -c "cd /app && bundle install --jobs=3 --retry=3 && bundle exec rake"
25
36
  - >
26
37
  RUBY=2.3.7 && docker run --rm -it -v $PWD:/app pgeraghty/ansible-ruby:$RUBY-$ANSIBLE_VERSION
@@ -31,3 +42,7 @@ script:
31
42
  - >
32
43
  RUBY=2.1.10 && docker run --rm -it -v $PWD:/app pgeraghty/ansible-ruby:$RUBY-$ANSIBLE_VERSION
33
44
  /bin/sh -c "cd /app && bundle install --jobs=3 --retry=3 && bundle exec rake"
45
+ after_script:
46
+ - RUBY=2.6.4 && docker run --rm -e TRAVIS -e TRAVIS_JOB_ID -e TRAVIS_BRANCH -e TRAVIS_PULL_REQUEST
47
+ -e TRAVIS_TEST_RESULT -e CC_TEST_REPORTER_ID -it -v $PWD:/app pgeraghty/ansible-ruby:$RUBY-$ANSIBLE_VERSION
48
+ /bin/sh -c "cd /app && ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
data/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  ## Requirements
12
12
 
13
13
  Ensure [Ansible](http://docs.ansible.com/intro_getting_started.html) is installed and available to shell commands i.e. in PATH.
14
- [Tested](https://travis-ci.org/pgeraghty/ansible-wrapper-ruby) with Ansible versions 2.0.2 thru 2.8.5 and Ruby 2.1+, but please create an issue if you use a version that fails.
14
+ [Tested](https://travis-ci.org/pgeraghty/ansible-wrapper-ruby) with Ansible versions 2.0.2 thru 2.9.6 and Ruby 2.1+, but please create an issue if you use a version that fails.
15
15
 
16
16
  ## Installation
17
17
 
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  spec.add_dependency 'json'
33
33
 
34
- spec.add_development_dependency 'bundler','~> 1.10'
34
+ spec.add_development_dependency 'bundler'
35
35
  spec.add_development_dependency 'rake', '~> 10.0'
36
36
  spec.add_development_dependency 'rspec'
37
37
  spec.add_development_dependency 'coveralls'
@@ -2,14 +2,16 @@ PATH
2
2
  remote: ../..
3
3
  specs:
4
4
  ansible-wrapper (0.2.0)
5
+ json
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
9
10
  daemons (1.3.1)
10
11
  eventmachine (1.2.7)
12
+ json (2.3.0)
11
13
  mustermann (1.0.3)
12
- rack (2.0.7)
14
+ rack (2.0.8)
13
15
  rack-protection (2.0.7)
14
16
  rack
15
17
  sinatra (2.0.7)
@@ -18,21 +18,48 @@ module Ansible
18
18
 
19
19
  # Stream execution of a playbook using PTY because otherwise output is buffered
20
20
  # @param pb [String] path to playbook
21
+ # @param raise_on_failure [Symbol] Specifies if streaming should raise an exception when a Playbook failure occurs.
22
+ # Defaults to +:false+, can also be +:during+ to raise as soon as an error occurs or +:after+ to allow all output to stream first.
23
+ # @raise [Playbook::Exception] if +raise_on_failure+ is truthy
21
24
  # @return [Integer] exit status
22
- def stream(pb)
25
+ def stream(pb, raise_on_failure: false)
23
26
  cmd = config.to_s("#{BIN} #{pb}")
27
+ error_at_line = {}
28
+
29
+ pid = SafePty.spawn cmd do |r,_,_| # add -vvvv here for verbose
30
+ line_num = 0
24
31
 
25
- SafePty.spawn cmd do |r,_,_| # add -vvvv here for verbose
26
32
  until r.eof? do
27
33
  line = r.gets
34
+ line_num += 1
35
+
28
36
  block_given? ? yield(line) : puts(line)
29
37
 
30
- case line
31
- when /fatal: \[/ then raise Playbook::Exception.new("FAILED: #{line}")
32
- when /ERROR!/,/FAILED!/ then raise Playbook::Exception.new("ERROR: #{line}")
38
+ # track errors in output by line
39
+ if raise_on_failure
40
+ case line
41
+ when /fatal: \[/ then error_at_line[line_num] ||= "FAILED: #{line}"
42
+ when /ERROR!/, /FAILED!/ then error_at_line[line_num] ||= "ERROR: #{line}"
43
+ # allow errors on previous line to be ignored
44
+ when /...ignoring/ then error_at_line.delete(line_num-1)
45
+ end
46
+
47
+ if raise_on_failure == :during
48
+ # trigger failure unless it was ignored
49
+ fatal_unskipped_error = error_at_line[line_num-1]
50
+ raise Playbook::Exception.new(fatal_unskipped_error) if fatal_unskipped_error
51
+ end
33
52
  end
34
53
  end
35
54
  end
55
+
56
+ if raise_on_failure
57
+ # at this point, all output has been streamed
58
+ fatal_unskipped_error = error_at_line.first
59
+ raise Playbook::Exception.new(fatal_unskipped_error.last) if fatal_unskipped_error
60
+ end
61
+
62
+ pid
36
63
  end
37
64
  end
38
65
 
@@ -1,3 +1,3 @@
1
1
  module Ansible
2
- VERSION = '0.2.2'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ansible-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Geraghty
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-26 00:00:00.000000000 Z
11
+ date: 2020-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.10'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.10'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement