ansible-wrapper 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test_via_docker.yml +56 -20
- data/.travis.yml +28 -16
- data/README.md +4 -4
- data/ansible-wrapper.gemspec +2 -0
- data/bin/console +1 -1
- data/bin/rake +29 -0
- data/examples/streaming/run.rb +1 -1
- data/lib/ansible-wrapper.rb +0 -1
- data/lib/ansible/ad_hoc.rb +26 -20
- data/lib/ansible/config.rb +47 -45
- data/lib/ansible/output.rb +35 -32
- data/lib/ansible/playbook.rb +1 -0
- data/lib/ansible/version.rb +1 -1
- metadata +17 -3
- data/ansible-wrapper-0.1.2.gem +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 502f430dd8b6fca43b1847722b1bdd51ae6a8df1eda0b8f2f035c93f6091ecc4
|
|
4
|
+
data.tar.gz: 48070b75f6cbcac9f1c90baa5371f7c651572699d342f219ba738ed2c011d3b8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5f7b489399ab99c55c69fa11793e8c24e0cf6860c6c4bdaf5637f2ba0540a2006ce395c96ad20d7f9334bbd4af32677fbf260a0cce5a2fb16c891724e62af52a
|
|
7
|
+
data.tar.gz: 7bb2ed85834fe9b2e4699e38c129c14739560e9a3a7aa7f4e65740f08fc8ebefeb0575c85a0b5ef0e585529f7432feae786aee2d7ef6fbbf6dffe419bff1c784
|
|
@@ -8,26 +8,62 @@ jobs:
|
|
|
8
8
|
strategy:
|
|
9
9
|
matrix:
|
|
10
10
|
ansible:
|
|
11
|
-
- 2.0.2
|
|
12
|
-
- 2.1.6
|
|
13
|
-
- 2.2.3
|
|
14
|
-
- 2.3.3
|
|
15
|
-
- 2.4.6
|
|
16
|
-
- 2.5.15
|
|
17
|
-
- 2.6.19
|
|
18
|
-
- 2.7.12
|
|
19
11
|
- 2.8.5
|
|
12
|
+
- 2.7.12
|
|
13
|
+
- 2.6.19
|
|
14
|
+
- 2.5.15
|
|
15
|
+
- 2.4.6
|
|
16
|
+
- 2.3.3
|
|
17
|
+
- 2.2.3
|
|
18
|
+
- 2.1.6
|
|
19
|
+
- 2.0.2
|
|
20
20
|
steps:
|
|
21
21
|
- uses: actions/checkout@v1
|
|
22
|
-
- name:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
- name: Test against Ruby 2.6.4
|
|
23
|
+
env:
|
|
24
|
+
RUBY_VERSION: 2.6.4
|
|
25
|
+
ANSIBLE_VERSION: ${{ matrix.ansible }}
|
|
26
|
+
run: >
|
|
27
|
+
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
|
+
COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_REPO_TOKEN }} COVERALLS_RUN_LOCALLY=true bundle exec rake"
|
|
30
|
+
|
|
31
|
+
- name: Test against Ruby 2.5.6
|
|
32
|
+
env:
|
|
33
|
+
RUBY_VERSION: 2.5.6
|
|
34
|
+
ANSIBLE_VERSION: ${{ matrix.ansible }}
|
|
35
|
+
run: >
|
|
36
|
+
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
|
+
|
|
39
|
+
- name: Test against Ruby 2.4.7
|
|
40
|
+
env:
|
|
41
|
+
RUBY_VERSION: 2.4.7
|
|
42
|
+
ANSIBLE_VERSION: ${{ matrix.ansible }}
|
|
43
|
+
run: >
|
|
44
|
+
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
|
+
|
|
47
|
+
- name: Test against Ruby 2.3.7
|
|
48
|
+
env:
|
|
49
|
+
RUBY_VERSION: 2.3.7
|
|
50
|
+
ANSIBLE_VERSION: ${{ matrix.ansible }}
|
|
51
|
+
run: >
|
|
52
|
+
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"
|
|
54
|
+
|
|
55
|
+
- name: Test against Ruby 2.2.7
|
|
56
|
+
env:
|
|
57
|
+
RUBY_VERSION: 2.2.7
|
|
58
|
+
ANSIBLE_VERSION: ${{ matrix.ansible }}
|
|
59
|
+
run: >
|
|
60
|
+
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"
|
|
62
|
+
|
|
63
|
+
- name: Test against Ruby 2.1.10
|
|
64
|
+
env:
|
|
65
|
+
RUBY_VERSION: 2.1.10
|
|
66
|
+
ANSIBLE_VERSION: ${{ matrix.ansible }}
|
|
67
|
+
run: >
|
|
68
|
+
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"
|
data/.travis.yml
CHANGED
|
@@ -1,21 +1,33 @@
|
|
|
1
|
-
language:
|
|
1
|
+
language: bash
|
|
2
2
|
services:
|
|
3
3
|
- docker
|
|
4
4
|
env:
|
|
5
|
-
- ANSIBLE_VERSION=2.0.2
|
|
6
|
-
- ANSIBLE_VERSION=2.1.6
|
|
7
|
-
- ANSIBLE_VERSION=2.2.3
|
|
8
|
-
- ANSIBLE_VERSION=2.3.3
|
|
9
|
-
- ANSIBLE_VERSION=2.4.6
|
|
10
|
-
- ANSIBLE_VERSION=2.5.15
|
|
11
|
-
- ANSIBLE_VERSION=2.6.19
|
|
12
|
-
- ANSIBLE_VERSION=2.7.12
|
|
13
5
|
- ANSIBLE_VERSION=2.8.5
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
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
|
|
20
14
|
script:
|
|
21
|
-
-
|
|
15
|
+
- >
|
|
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"
|
|
19
|
+
- >
|
|
20
|
+
RUBY=2.5.6 && docker run --rm -it -v $PWD:/app pgeraghty/ansible-ruby:$RUBY-$ANSIBLE_VERSION
|
|
21
|
+
/bin/sh -c "cd /app && bundle install --jobs=3 --retry=3 && bundle exec rake"
|
|
22
|
+
- >
|
|
23
|
+
RUBY=2.4.7 && docker run --rm -it -v $PWD:/app pgeraghty/ansible-ruby:$RUBY-$ANSIBLE_VERSION
|
|
24
|
+
/bin/sh -c "cd /app && bundle install --jobs=3 --retry=3 && bundle exec rake"
|
|
25
|
+
- >
|
|
26
|
+
RUBY=2.3.7 && docker run --rm -it -v $PWD:/app pgeraghty/ansible-ruby:$RUBY-$ANSIBLE_VERSION
|
|
27
|
+
/bin/sh -c "cd /app && bundle install --jobs=3 --retry=3 && bundle exec rake"
|
|
28
|
+
- >
|
|
29
|
+
RUBY=2.2.7 && docker run --rm -it -v $PWD:/app pgeraghty/ansible-ruby:$RUBY-$ANSIBLE_VERSION
|
|
30
|
+
/bin/sh -c "cd /app && bundle install --jobs=3 --retry=3 && bundle exec rake"
|
|
31
|
+
- >
|
|
32
|
+
RUBY=2.1.10 && docker run --rm -it -v $PWD:/app pgeraghty/ansible-ruby:$RUBY-$ANSIBLE_VERSION
|
|
33
|
+
/bin/sh -c "cd /app && bundle install --jobs=3 --retry=3 && bundle exec rake"
|
data/README.md
CHANGED
|
@@ -43,15 +43,15 @@ Ansible::AdHoc.run 'all -m shell -a "echo Test" -i localhost,'
|
|
|
43
43
|
### Playbooks
|
|
44
44
|
|
|
45
45
|
```ruby
|
|
46
|
-
Ansible::Playbook.run '-i localhost, spec/mock_playbook.yml'
|
|
46
|
+
Ansible::Playbook.run '-i localhost, spec/fixtures/mock_playbook.yml'
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
```ruby
|
|
50
|
-
Ansible::Playbook.stream('-i localhost, spec/mock_playbook.yml') # defaults to standard output
|
|
50
|
+
Ansible::Playbook.stream('-i localhost, spec/fixtures/mock_playbook.yml') # defaults to standard output
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
```ruby
|
|
54
|
-
Ansible::Playbook.stream('-i localhost, spec/mock_playbook.yml') { |line_of_output| puts line_of_output }
|
|
54
|
+
Ansible::Playbook.stream('-i localhost, spec/fixtures/mock_playbook.yml') { |line_of_output| puts line_of_output }
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
### Shortcuts
|
|
@@ -69,7 +69,7 @@ A['all -i localhost, --list-hosts'] # alias for Ansible::AdHoc.run
|
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
```ruby
|
|
72
|
-
A << '-i localhost, spec/mock_playbook.yml' # alias for Ansible::Playbook.stream
|
|
72
|
+
A << '-i localhost, spec/fixtures/mock_playbook.yml' # alias for Ansible::Playbook.stream
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
## Coming Soon
|
data/ansible-wrapper.gemspec
CHANGED
|
@@ -27,6 +27,8 @@ Gem::Specification.new do |spec|
|
|
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
28
28
|
spec.require_paths = ['lib']
|
|
29
29
|
|
|
30
|
+
spec.add_dependency 'json'
|
|
31
|
+
|
|
30
32
|
spec.add_development_dependency 'bundler','~> 1.10'
|
|
31
33
|
spec.add_development_dependency 'rake', '~> 10.0'
|
|
32
34
|
spec.add_development_dependency 'rspec'
|
data/bin/console
CHANGED
data/bin/rake
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
require "pathname"
|
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
13
|
+
Pathname.new(__FILE__).realpath)
|
|
14
|
+
|
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
|
16
|
+
|
|
17
|
+
if File.file?(bundle_binstub)
|
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
|
19
|
+
load(bundle_binstub)
|
|
20
|
+
else
|
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
require "rubygems"
|
|
27
|
+
require "bundler/setup"
|
|
28
|
+
|
|
29
|
+
load Gem.bin_path("rake", "rake")
|
data/examples/streaming/run.rb
CHANGED
|
@@ -63,7 +63,7 @@ get '/streaming' do
|
|
|
63
63
|
#content_type 'text/plain'
|
|
64
64
|
stream do |out|
|
|
65
65
|
out << CONSOLE_OUTPUT_START
|
|
66
|
-
Ansible.stream ['-i', 'localhost,', File.expand_path('../../../spec/mock_playbook.yml', __FILE__)]*' ' do |line|
|
|
66
|
+
Ansible.stream ['-i', 'localhost,', File.expand_path('../../../spec/fixtures/mock_playbook.yml', __FILE__)]*' ' do |line|
|
|
67
67
|
Ansible::Output.to_html line, out
|
|
68
68
|
end
|
|
69
69
|
out << CONSOLE_OUTPUT_END
|
data/lib/ansible-wrapper.rb
CHANGED
data/lib/ansible/ad_hoc.rb
CHANGED
|
@@ -1,30 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
require 'ansible/config'
|
|
2
|
+
require 'json'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
alias :[] :one_off
|
|
4
|
+
module Ansible
|
|
5
|
+
module Methods
|
|
6
|
+
BIN = 'ansible'
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
def one_off cmd
|
|
9
|
+
`#{config.to_s "#{BIN} #{cmd}"}`
|
|
10
|
+
end
|
|
11
|
+
alias :[] :one_off
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
def list_hosts cmd
|
|
14
|
+
output = one_off("#{cmd} --list-hosts").gsub!(/\s+hosts.*:\n/, '').strip
|
|
15
|
+
output.split("\n").map(&:strip)
|
|
16
|
+
end
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
def parse_host_vars(host, inv_file, filter = 'hostvars[inventory_hostname]')
|
|
19
|
+
cmd = "all -m debug -a 'var=#{filter}' -i #{inv_file} -l #{host}"
|
|
20
|
+
json = self[cmd].split(/>>|=>/).last
|
|
21
|
+
|
|
22
|
+
# remove any colour added to console output
|
|
23
|
+
# TODO move to Output module as #bleach, perhaps use term-ansicolor
|
|
24
|
+
# possibly replace regexp with /\e\[(?:(?:[349]|10)[0-7]|[0-9]|[34]8;5;\d{1,3})?m/
|
|
25
|
+
# possibly use ANSIBLE_NOCOLOR? or --nocolor
|
|
26
|
+
json = json.strip.chomp.gsub(/\e\[[0-1][;]?(3[0-7]|90|1)?m/, '')
|
|
27
|
+
|
|
28
|
+
hostvars = JSON.parse(json)
|
|
29
|
+
|
|
30
|
+
hostvars[filter]
|
|
23
31
|
end
|
|
24
32
|
end
|
|
25
|
-
end
|
|
26
33
|
|
|
27
|
-
module Ansible
|
|
28
34
|
module AdHoc
|
|
29
35
|
include Ansible::Config
|
|
30
36
|
include Ansible::Methods
|
data/lib/ansible/config.rb
CHANGED
|
@@ -1,53 +1,55 @@
|
|
|
1
|
-
module Ansible
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
module Ansible
|
|
2
|
+
module Config
|
|
3
|
+
PATH = 'lib/ansible/'
|
|
4
|
+
# IP_OR_HOSTNAME = /((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})$|^((([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]))\n/
|
|
5
|
+
SKIP_HOSTVARS = %w(ansible_version inventory_dir inventory_file inventory_hostname inventory_hostname_short group_names groups omit playbook_dir)
|
|
6
|
+
VERSION = `ansible --version`.split("\n").first.split.last rescue nil # nil when Ansible not installed
|
|
7
|
+
|
|
8
|
+
DefaultConfig = Struct.new(:env, :extra_vars, :params) do
|
|
9
|
+
def initialize
|
|
10
|
+
self.env = {
|
|
11
|
+
'ANSIBLE_FORCE_COLOR' => 'True',
|
|
12
|
+
'ANSIBLE_HOST_KEY_CHECKING' => 'False'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
self.params = {
|
|
16
|
+
debug: false
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
# options
|
|
20
|
+
self.extra_vars = {
|
|
21
|
+
# skip creation of .retry files
|
|
22
|
+
'retry_files_enabled' => 'False'
|
|
23
|
+
}
|
|
24
|
+
# TODO support --ssh-common-args, --ssh-extra-args
|
|
25
|
+
# e.g. ansible-playbook --ssh-common-args="-o ServerAliveInterval=60" -i inventory install.yml
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# NB: --extra-vars can also accept JSON string, see http://stackoverflow.com/questions/25617273/pass-array-in-extra-vars-ansible
|
|
29
|
+
def options
|
|
30
|
+
x = extra_vars.each_with_object('--extra-vars=\'') { |kv, a| a << "#{kv.first}=\"#{kv.last}\" " }.strip+'\'' if extra_vars unless extra_vars.empty?
|
|
31
|
+
# can test with configure { |config| config.extra_vars.clear }
|
|
32
|
+
|
|
33
|
+
[x, '--ssh-extra-args=\'-o UserKnownHostsFile=/dev/null\'']*' '
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def to_s(cmd)
|
|
37
|
+
entire_cmd = [env.each_with_object([]) { |kv, a| a << kv*'=' } * ' ', cmd, options]*' '
|
|
38
|
+
puts entire_cmd if params[:debug]
|
|
39
|
+
entire_cmd
|
|
40
|
+
end
|
|
25
41
|
end
|
|
26
42
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# can test with configure { |config| config.extra_vars.clear }
|
|
43
|
+
def configure
|
|
44
|
+
@config ||= DefaultConfig.new
|
|
45
|
+
yield(@config) if block_given?
|
|
31
46
|
|
|
32
|
-
|
|
47
|
+
# allow chaining if block given
|
|
48
|
+
block_given? ? self : @config
|
|
33
49
|
end
|
|
34
50
|
|
|
35
|
-
def
|
|
36
|
-
|
|
37
|
-
puts entire_cmd if params[:debug]
|
|
38
|
-
entire_cmd
|
|
51
|
+
def config
|
|
52
|
+
@config || configure
|
|
39
53
|
end
|
|
40
54
|
end
|
|
41
|
-
|
|
42
|
-
def configure
|
|
43
|
-
@config ||= DefaultConfig.new
|
|
44
|
-
yield(@config) if block_given?
|
|
45
|
-
|
|
46
|
-
# allow chaining if block given
|
|
47
|
-
block_given? ? self : @config
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def config
|
|
51
|
-
@config || configure
|
|
52
|
-
end
|
|
53
55
|
end
|
data/lib/ansible/output.rb
CHANGED
|
@@ -1,47 +1,50 @@
|
|
|
1
1
|
require 'strscan'
|
|
2
2
|
require 'erb'
|
|
3
3
|
|
|
4
|
-
module Ansible
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
module Ansible
|
|
5
|
+
module Output
|
|
6
|
+
COLOR = {
|
|
7
|
+
'1' => 'font-weight: bold',
|
|
8
|
+
'30' => 'color: black',
|
|
9
|
+
'31' => 'color: red',
|
|
10
|
+
'32' => 'color: green',
|
|
11
|
+
'33' => 'color: yellow',
|
|
12
|
+
'34' => 'color: blue',
|
|
13
|
+
'35' => 'color: magenta',
|
|
14
|
+
'36' => 'color: cyan',
|
|
15
|
+
'37' => 'color: white',
|
|
16
|
+
'90' => 'color: grey'
|
|
17
|
+
}
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
def self.to_html(line, stream='')
|
|
20
|
+
s = StringScanner.new(ERB::Util.h line)
|
|
21
|
+
while(!s.eos?)
|
|
22
|
+
if s.scan(/\e\[([0-1])?[;]?(3[0-7]|90|1)m/)
|
|
23
|
+
bold, colour = s[1], s[2]
|
|
24
|
+
styles = []
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
styles << COLOR[bold] if bold.to_i == 1
|
|
27
|
+
styles << COLOR[colour]
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
span =
|
|
30
|
+
# in case of invalid colours, although this may be impossible
|
|
31
|
+
if styles.compact.empty?
|
|
32
|
+
%{<span>}
|
|
33
|
+
else
|
|
34
|
+
%{<span style="#{styles*'; '};">}
|
|
35
|
+
end
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if s.scan(/\e\[0m/)
|
|
37
|
+
stream << span
|
|
38
|
+
elsif s.scan(/\e\[0m/)
|
|
38
39
|
stream << %{</span>}
|
|
40
|
+
elsif s.scan(/\e\[[^0]*m/)
|
|
41
|
+
stream << '<span>'
|
|
39
42
|
else
|
|
40
43
|
stream << s.scan(/./m)
|
|
41
44
|
end
|
|
42
45
|
end
|
|
43
|
-
end
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
stream
|
|
48
|
+
end
|
|
46
49
|
end
|
|
47
50
|
end
|
data/lib/ansible/playbook.rb
CHANGED
data/lib/ansible/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ansible-wrapper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
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-
|
|
11
|
+
date: 2019-09-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: json
|
|
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: bundler
|
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -96,9 +110,9 @@ files:
|
|
|
96
110
|
- LICENSE.txt
|
|
97
111
|
- README.md
|
|
98
112
|
- Rakefile
|
|
99
|
-
- ansible-wrapper-0.1.2.gem
|
|
100
113
|
- ansible-wrapper.gemspec
|
|
101
114
|
- bin/console
|
|
115
|
+
- bin/rake
|
|
102
116
|
- bin/setup
|
|
103
117
|
- examples/streaming/Gemfile
|
|
104
118
|
- examples/streaming/Gemfile.lock
|
data/ansible-wrapper-0.1.2.gem
DELETED
|
Binary file
|