ansible-powerplay 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b9dd462851801b5fa3560bf9b8dd5f08c0d80728
4
+ data.tar.gz: ec3da1aaf3afb7fbff91780979630e703aa9591c
5
+ SHA512:
6
+ metadata.gz: 016606a083317be2b29d41c09c11a229163de64813236f1f047f6d6ae9579ad08295ab58f286dbc4300ddef4cdb4f5fcfcf56666c1efe78f2f4a152cd5c41fac
7
+ data.tar.gz: b7415bda872425c58cb4c022968dd7b33a858d065d42d9693b3a61f9d7bcae3548c7feec1c9a9ce0e579310b8b8dcadf68a5c78fcdd8bb65f878d4e693c623a7
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.0
data/.semver ADDED
@@ -0,0 +1,5 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 0
4
+ :patch: 4
5
+ :special: ''
data/Gemfile ADDED
@@ -0,0 +1,24 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'thor', '~> 0'
4
+ gem 'concurrent-ruby', require: 'concurrent'
5
+ gem 'term-ansicolor'
6
+
7
+ group :development do
8
+ gem "rspec", "~> 2"
9
+ gem "yard", "~> 0"
10
+ gem "rdoc", "~> 3"
11
+ gem "bundler", "~> 1"
12
+ gem "juwelier", "~> 2"
13
+ gem "simplecov", ">= 0"
14
+ gem 'semver', '~> 1'
15
+ gem 'guard', '~> 2'
16
+ gem 'guard-rspec', '~> 1'
17
+
18
+ gem 'pry', '~> 0'
19
+ gem 'pry-byebug', '~> 3'
20
+ gem 'pry-doc', '~> 0'
21
+ gem 'pry-remote', '~> 0'
22
+ gem 'pry-rescue', '~> 1'
23
+ gem 'pry-stack_explorer', '~> 0'
24
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,147 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.4.0)
5
+ binding_of_caller (0.7.2)
6
+ debug_inspector (>= 0.0.1)
7
+ builder (3.2.2)
8
+ byebug (8.2.2)
9
+ coderay (1.1.0)
10
+ concurrent-ruby (1.0.0)
11
+ debug_inspector (0.0.2)
12
+ descendants_tracker (0.0.4)
13
+ thread_safe (~> 0.3, >= 0.3.1)
14
+ diff-lcs (1.2.5)
15
+ docile (1.1.5)
16
+ faraday (0.9.2)
17
+ multipart-post (>= 1.2, < 3)
18
+ ffi (1.9.10)
19
+ formatador (0.2.5)
20
+ git (1.2.9.1)
21
+ github_api (0.13.1)
22
+ addressable (~> 2.4.0)
23
+ descendants_tracker (~> 0.0.4)
24
+ faraday (~> 0.8, < 0.10)
25
+ hashie (>= 3.4)
26
+ multi_json (>= 1.7.5, < 2.0)
27
+ oauth2
28
+ guard (2.13.0)
29
+ formatador (>= 0.2.4)
30
+ listen (>= 2.7, <= 4.0)
31
+ lumberjack (~> 1.0)
32
+ nenv (~> 0.1)
33
+ notiffany (~> 0.0)
34
+ pry (>= 0.9.12)
35
+ shellany (~> 0.0)
36
+ thor (>= 0.18.1)
37
+ guard-rspec (1.2.2)
38
+ guard (>= 1.1)
39
+ hashie (3.4.3)
40
+ highline (1.7.8)
41
+ interception (0.5)
42
+ json (1.8.3)
43
+ juwelier (2.1.0)
44
+ builder
45
+ bundler (>= 1.0)
46
+ git (>= 1.2.5)
47
+ github_api
48
+ highline (>= 1.6.15)
49
+ nokogiri (>= 1.5.10)
50
+ rake
51
+ rdoc
52
+ jwt (1.5.1)
53
+ listen (3.0.6)
54
+ rb-fsevent (>= 0.9.3)
55
+ rb-inotify (>= 0.9.7)
56
+ lumberjack (1.0.10)
57
+ method_source (0.8.2)
58
+ mini_portile2 (2.0.0)
59
+ multi_json (1.11.2)
60
+ multi_xml (0.5.5)
61
+ multipart-post (2.0.0)
62
+ nenv (0.3.0)
63
+ nokogiri (1.6.7.2)
64
+ mini_portile2 (~> 2.0.0.rc2)
65
+ notiffany (0.0.8)
66
+ nenv (~> 0.1)
67
+ shellany (~> 0.0)
68
+ oauth2 (1.1.0)
69
+ faraday (>= 0.8, < 0.10)
70
+ jwt (~> 1.0, < 1.5.2)
71
+ multi_json (~> 1.3)
72
+ multi_xml (~> 0.5)
73
+ rack (>= 1.2, < 3)
74
+ pry (0.10.3)
75
+ coderay (~> 1.1.0)
76
+ method_source (~> 0.8.1)
77
+ slop (~> 3.4)
78
+ pry-byebug (3.3.0)
79
+ byebug (~> 8.0)
80
+ pry (~> 0.10)
81
+ pry-doc (0.8.0)
82
+ pry (~> 0.9)
83
+ yard (~> 0.8)
84
+ pry-remote (0.1.8)
85
+ pry (~> 0.9)
86
+ slop (~> 3.0)
87
+ pry-rescue (1.4.2)
88
+ interception (>= 0.5)
89
+ pry
90
+ pry-stack_explorer (0.4.9.2)
91
+ binding_of_caller (>= 0.7)
92
+ pry (>= 0.9.11)
93
+ rack (1.6.4)
94
+ rake (10.5.0)
95
+ rb-fsevent (0.9.7)
96
+ rb-inotify (0.9.7)
97
+ ffi (>= 0.5.0)
98
+ rdoc (3.12.2)
99
+ json (~> 1.4)
100
+ rspec (2.99.0)
101
+ rspec-core (~> 2.99.0)
102
+ rspec-expectations (~> 2.99.0)
103
+ rspec-mocks (~> 2.99.0)
104
+ rspec-core (2.99.2)
105
+ rspec-expectations (2.99.2)
106
+ diff-lcs (>= 1.1.3, < 2.0)
107
+ rspec-mocks (2.99.4)
108
+ semver (1.0.1)
109
+ shellany (0.0.1)
110
+ simplecov (0.11.2)
111
+ docile (~> 1.1.0)
112
+ json (~> 1.8)
113
+ simplecov-html (~> 0.10.0)
114
+ simplecov-html (0.10.0)
115
+ slop (3.6.0)
116
+ term-ansicolor (1.3.2)
117
+ tins (~> 1.0)
118
+ thor (0.19.1)
119
+ thread_safe (0.3.5)
120
+ tins (1.8.2)
121
+ yard (0.8.7.6)
122
+
123
+ PLATFORMS
124
+ ruby
125
+
126
+ DEPENDENCIES
127
+ bundler (~> 1)
128
+ concurrent-ruby
129
+ guard (~> 2)
130
+ guard-rspec (~> 1)
131
+ juwelier (~> 2)
132
+ pry (~> 0)
133
+ pry-byebug (~> 3)
134
+ pry-doc (~> 0)
135
+ pry-remote (~> 0)
136
+ pry-rescue (~> 1)
137
+ pry-stack_explorer (~> 0)
138
+ rdoc (~> 3)
139
+ rspec (~> 2)
140
+ semver (~> 1)
141
+ simplecov
142
+ term-ansicolor
143
+ thor (~> 0)
144
+ yard (~> 0)
145
+
146
+ BUNDLED WITH
147
+ 1.11.2
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2016 Fred Mitchell
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.org ADDED
@@ -0,0 +1,196 @@
1
+ * Ansible Powerplay
2
+
3
+ Powerplay allows you to run multiple Ansible playbooks in
4
+ parallel. Depending on how you organize your playbooks,
5
+ this can be a solid win. I basically before this had been
6
+ doing a playbook with multiple includes for other playbooks
7
+ representing different servers in our stack. Playbook launching
8
+ of playbooks is slow and very serial.
9
+
10
+ Basically, the playbooks are all contained,
11
+ so no interdependencies. And in my case, running in the
12
+ cloud, so no reason why they can't be running in parallel
13
+
14
+ Powerplay allows you to specify vars common
15
+ to all playbooks, and also vars specific
16
+ to some playbooks so by which you can
17
+ make your setup very DRY.
18
+
19
+ All the Ansible playbooks are executed in seperate processes,
20
+ and thus avoiding a number of the "side effects" you would
21
+ normally encounter with running multiple playbooks with
22
+ Ansible includes.
23
+
24
+ For example, here is Powerplay integrated with tmux:
25
+ #+CAPTION: Powerplay writing to tmux panes, one pane per playbook.
26
+ #+NAME: Powerplay Example
27
+ [[./examples/powerplay_screenshot.jpeg]]
28
+
29
+ ** Features and Cavets
30
+ *** Integration with TMUX
31
+ When running multiple Ansible Playbooks concurrently,
32
+ one would like to be able to see the output of each
33
+ in a reasonable manner. To faciliate this in this
34
+ initial realse, we shall make heavy use of TMUX panes
35
+ to dump the output.
36
+
37
+ So basically, you need as many panes as you have
38
+ concurrent Ansible Playbooks in this initial release. In
39
+ subsequent releases, Curses will be directly
40
+ leveraged to create "tabs" for the multiple output
41
+ streams. We may even do this, still, through TMUX.
42
+
43
+ Your input on this is strongly encouarged. We will not
44
+ be supporting Screen at all. Sorry.
45
+
46
+ ** DSL Terminology & Documentation
47
+ *** DSL
48
+ The DSL is straightforward as possible,
49
+ simple and elegant to allow you to write
50
+ your Powerplays in a DRY manner.
51
+ **** configuration
52
+ You can intersperse configuration blocks
53
+ anywhere, and the expected nested scoping
54
+ will take effect.
55
+ **** playbooks
56
+ playbooks are a collection of groups, and
57
+ each group are normally executed serially. This will
58
+ allow you to organize your plays in an intelligent
59
+ manner to deploy and manage resources and assets
60
+ that may have to be done in a serial manner.
61
+ **** group
62
+ A group is a collection of books that all execute
63
+ in parallel. Books are required to be independent of
64
+ each other.
65
+ **** book
66
+ A book has a direct correspondence to an Ansible
67
+ playbook, and will execute that Yaml file
68
+ given the configuration variables as parameters.
69
+
70
+ Here is where var inheritance becomes useful.
71
+
72
+ ** Installation
73
+ Easy installation. From command-line:
74
+ #+BEGIN_SRC bash
75
+ gem install ansible-powerplay
76
+ #+END_SRC
77
+
78
+ Or from a gemfile:
79
+ #+BEGIN_SRC ruby
80
+ gem 'ansible-powerplay'
81
+ #+END_SRC
82
+
83
+ ** Use
84
+ Basically, cd to the root of your Ansible directory,
85
+ and a .play file (see the example at: [[https://github.com/flajann2/ansible-powerplay/blob/master/examples/test.play][test.play]].
86
+
87
+ You can place a config clause either globally,
88
+ inside of playbooks, inside of groups, and the
89
+ variable set up this way are inherited to the inner
90
+ clauses, thus allowing you to keep your specifications
91
+ DRYer.
92
+
93
+ For example:
94
+ #+BEGIN_SRC ruby
95
+ # This is a global system configuration
96
+ configuration :system do
97
+ playbook_directory "playbooks"
98
+ end
99
+ #+END_SRC
100
+
101
+ Note that 'playbook_directory' is special, as it allows
102
+ you to define the directory all of your Ansible playbooks
103
+ can be found. You can also specify this anywhere
104
+ you can use the configuration clause, so you
105
+ may set up different playbook directories for different
106
+ playbook collections.
107
+
108
+ #+BEGIN_SRC ruby
109
+ # sṕecific configuration for :development
110
+ configuration do
111
+ stack :development
112
+ krell_type "t2.small"
113
+ servers 1
114
+ rolling 3
115
+ krell_disk_size 20
116
+ end
117
+ #+END_SRC
118
+
119
+ The above shows Ansible variables for my specialiezd setup
120
+ that is geared with work with AWS. You are free to specify
121
+ any variables here, which will be injected into
122
+ ansible-playbook through the '--extra-vars' parameter.
123
+
124
+ Here is a group clause with a single book in it:
125
+
126
+ #+BEGIN_SRC ruby
127
+ # Groups are executed serially.
128
+ group :first, "our very first group" do
129
+ # Books within a group are executed in parallel,
130
+ # and therefore must be independent of each other.
131
+ book :nat, "nat.yml"
132
+ end
133
+ #+END_SRC
134
+
135
+ Which issues the following command to Ansible (based on the
136
+ earlier configuration):
137
+
138
+ #+BEGIN_SRC bash
139
+ ansible-playbook playbooks/nat.yml \
140
+ --extra-vars "playbook_directory=playbooks stack=development krell_type=t2.small servers=1 rolling=3 krell_disk_size=20"
141
+ #+END_SRC
142
+
143
+ And if our group had more book entries, as in the second
144
+ example:
145
+
146
+ #+BEGIN_SRC ruby
147
+ group :second, "our second group" do
148
+ book :rabbit, "rabbitmq_cluster.yml" do
149
+ krell_type "t2.medium"
150
+ end
151
+
152
+ book :es_cluster, "elasticsearch_cluster.yml" do
153
+ esver "1.7.4"
154
+ cluster_name :es
155
+ servers 3
156
+ heapsize "2g"
157
+ krell_type "t2.medium"
158
+ krell_disk_size 200
159
+ end
160
+ end
161
+ #+END_SRC
162
+
163
+ Both the :rabbit and :es_cluster books would be executed
164
+ in parallel.
165
+
166
+ *** Example .play Script
167
+ To play around with the example .play script,
168
+ Clone the [[https://github.com/flajann2/ansible-powerplay][Ansible Powerplay]] project locally:
169
+
170
+ #+BEGIN_SRC bash
171
+ git clone git@github.com:flajann2/ansible-powerplay.git
172
+ #+END_SRC
173
+
174
+ and go to the examples directory to find test.play.
175
+
176
+ *** Submitting your example .play scripts
177
+ Please feel free to do pull requests of your
178
+ scripts or submit them to me as Gist snippets
179
+ and I will include them if they are good.
180
+
181
+ ** Contributing to ansible-powerplay
182
+ Your parcipitation is welcome, and I will respond to your
183
+ pull requests in a timely fashion as long as I am not
184
+ pulling an "Atlas" at my current job! lol
185
+
186
+ + Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
187
+ + Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
188
+ + Fork the project.
189
+ + Start a feature/bugfix branch.
190
+ + Commit and push until you are happy with your contribution.
191
+ + Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
192
+ + Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
193
+
194
+ ** Copyright
195
+ Copyright (c) 2016 Fred Mitchell. See LICENSE.txt for
196
+ further details.
data/Rakefile ADDED
@@ -0,0 +1,58 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ require 'semver'
6
+
7
+ def s_version
8
+ SemVer.find.format "%M.%m.%p%s"
9
+ end
10
+
11
+ begin
12
+ Bundler.setup(:default, :development)
13
+ rescue Bundler::BundlerError => e
14
+ $stderr.puts e.message
15
+ $stderr.puts "Run `bundle install` to install missing gems"
16
+ exit e.status_code
17
+ end
18
+ require 'rake'
19
+
20
+ require 'juwelier'
21
+ Juwelier::Tasks.new do |gem|
22
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
23
+ gem.name = "ansible-powerplay"
24
+ gem.homepage = "http://github.com/flajann2/ansible-powerplay"
25
+ gem.license = "MIT"
26
+ gem.summary = %Q{Powerplay enables you to run Ansible playbooks in parallel. }
27
+ gem.description = %Q{Ansible Powerplay, by way of its DSL, allows you to
28
+ specify your Ansible playbooks and their vars, and common
29
+ vars to all, so that you can run your
30
+ indeoendent playbooks in full parallel.}
31
+ gem.email = "fred.mitchell@gmx.de"
32
+ gem.authors = ["Fred Mitchell"]
33
+ gem.version = s_version
34
+ gem.required_ruby_version = '>= 2.0'
35
+
36
+ # Exclusions
37
+ gem.files.exclude 'foo/**/*', 'rdoc/*', 'examples/*', '*.log',
38
+ '.idea/**/*', '.idea/**/.*', '.yardoc/**/*',
39
+ 'Guardfile'
40
+ end
41
+ Juwelier::RubygemsDotOrgTasks.new
42
+
43
+ require 'rspec/core'
44
+ require 'rspec/core/rake_task'
45
+ RSpec::Core::RakeTask.new(:spec) do |spec|
46
+ spec.pattern = FileList['spec/**/*_spec.rb']
47
+ end
48
+
49
+ desc "Code coverage detail"
50
+ task :simplecov do
51
+ ENV['COVERAGE'] = "true"
52
+ Rake::Task['spec'].execute
53
+ end
54
+
55
+ task :default => :spec
56
+
57
+ require 'yard'
58
+ YARD::Rake::YardocTask.new
data/SCRATCHPAD.org ADDED
@@ -0,0 +1,12 @@
1
+ * Personal Notes
2
+ This is my personal scratchpad. Please
3
+ ignore what you see after this point,
4
+ as it is not gauranteed to make sense to you
5
+ or to be kept up to date.
6
+
7
+ ** Tmux commnad to return the ptys and other info
8
+ #+BEGIN_SRC bash
9
+ tmux list-panes -F '#{pane_id} #{pane_tty}'
10
+ tmux list-panes -F '#{pane_id} #{pane_tty} #{pane_right} #{pane_left} #{pane_top} #{pane_bottom}'
11
+ #+END_SRC
12
+
@@ -0,0 +1,111 @@
1
+ # Generated by juwelier
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: ansible-powerplay 0.0.4 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "ansible-powerplay"
9
+ s.version = "0.0.4"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Fred Mitchell"]
14
+ s.date = "2016-02-17"
15
+ s.description = "Ansible Powerplay, by way of its DSL, allows you to\n specify your Ansible playbooks and their vars, and common\n vars to all, so that you can run your\n indeoendent playbooks in full parallel."
16
+ s.email = "fred.mitchell@gmx.de"
17
+ s.executables = ["powerplay"]
18
+ s.extra_rdoc_files = [
19
+ "LICENSE.txt",
20
+ "README.org"
21
+ ]
22
+ s.files = [
23
+ ".document",
24
+ ".rspec",
25
+ ".ruby-version",
26
+ ".semver",
27
+ "Gemfile",
28
+ "Gemfile.lock",
29
+ "LICENSE.txt",
30
+ "README.org",
31
+ "Rakefile",
32
+ "SCRATCHPAD.org",
33
+ "ansible-powerplay.gemspec",
34
+ "bin/powerplay",
35
+ "lib/ansible-powerplay.rb",
36
+ "lib/ansible-powerplay/cli.rb",
37
+ "lib/ansible-powerplay/dsl.rb",
38
+ "lib/ansible-powerplay/powerplay.rb",
39
+ "spec/ansible-powerplay_spec.rb",
40
+ "spec/spec_helper.rb"
41
+ ]
42
+ s.homepage = "http://github.com/flajann2/ansible-powerplay"
43
+ s.licenses = ["MIT"]
44
+ s.required_ruby_version = Gem::Requirement.new(">= 2.0")
45
+ s.rubygems_version = "2.5.1"
46
+ s.summary = "Powerplay enables you to run Ansible playbooks in parallel."
47
+
48
+ if s.respond_to? :specification_version then
49
+ s.specification_version = 4
50
+
51
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
+ s.add_runtime_dependency(%q<thor>, ["~> 0"])
53
+ s.add_runtime_dependency(%q<concurrent-ruby>, [">= 0"])
54
+ s.add_runtime_dependency(%q<term-ansicolor>, [">= 0"])
55
+ s.add_development_dependency(%q<rspec>, ["~> 2"])
56
+ s.add_development_dependency(%q<yard>, ["~> 0"])
57
+ s.add_development_dependency(%q<rdoc>, ["~> 3"])
58
+ s.add_development_dependency(%q<bundler>, ["~> 1"])
59
+ s.add_development_dependency(%q<juwelier>, ["~> 2"])
60
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
61
+ s.add_development_dependency(%q<semver>, ["~> 1"])
62
+ s.add_development_dependency(%q<guard>, ["~> 2"])
63
+ s.add_development_dependency(%q<guard-rspec>, ["~> 1"])
64
+ s.add_development_dependency(%q<pry>, ["~> 0"])
65
+ s.add_development_dependency(%q<pry-byebug>, ["~> 3"])
66
+ s.add_development_dependency(%q<pry-doc>, ["~> 0"])
67
+ s.add_development_dependency(%q<pry-remote>, ["~> 0"])
68
+ s.add_development_dependency(%q<pry-rescue>, ["~> 1"])
69
+ s.add_development_dependency(%q<pry-stack_explorer>, ["~> 0"])
70
+ else
71
+ s.add_dependency(%q<thor>, ["~> 0"])
72
+ s.add_dependency(%q<concurrent-ruby>, [">= 0"])
73
+ s.add_dependency(%q<term-ansicolor>, [">= 0"])
74
+ s.add_dependency(%q<rspec>, ["~> 2"])
75
+ s.add_dependency(%q<yard>, ["~> 0"])
76
+ s.add_dependency(%q<rdoc>, ["~> 3"])
77
+ s.add_dependency(%q<bundler>, ["~> 1"])
78
+ s.add_dependency(%q<juwelier>, ["~> 2"])
79
+ s.add_dependency(%q<simplecov>, [">= 0"])
80
+ s.add_dependency(%q<semver>, ["~> 1"])
81
+ s.add_dependency(%q<guard>, ["~> 2"])
82
+ s.add_dependency(%q<guard-rspec>, ["~> 1"])
83
+ s.add_dependency(%q<pry>, ["~> 0"])
84
+ s.add_dependency(%q<pry-byebug>, ["~> 3"])
85
+ s.add_dependency(%q<pry-doc>, ["~> 0"])
86
+ s.add_dependency(%q<pry-remote>, ["~> 0"])
87
+ s.add_dependency(%q<pry-rescue>, ["~> 1"])
88
+ s.add_dependency(%q<pry-stack_explorer>, ["~> 0"])
89
+ end
90
+ else
91
+ s.add_dependency(%q<thor>, ["~> 0"])
92
+ s.add_dependency(%q<concurrent-ruby>, [">= 0"])
93
+ s.add_dependency(%q<term-ansicolor>, [">= 0"])
94
+ s.add_dependency(%q<rspec>, ["~> 2"])
95
+ s.add_dependency(%q<yard>, ["~> 0"])
96
+ s.add_dependency(%q<rdoc>, ["~> 3"])
97
+ s.add_dependency(%q<bundler>, ["~> 1"])
98
+ s.add_dependency(%q<juwelier>, ["~> 2"])
99
+ s.add_dependency(%q<simplecov>, [">= 0"])
100
+ s.add_dependency(%q<semver>, ["~> 1"])
101
+ s.add_dependency(%q<guard>, ["~> 2"])
102
+ s.add_dependency(%q<guard-rspec>, ["~> 1"])
103
+ s.add_dependency(%q<pry>, ["~> 0"])
104
+ s.add_dependency(%q<pry-byebug>, ["~> 3"])
105
+ s.add_dependency(%q<pry-doc>, ["~> 0"])
106
+ s.add_dependency(%q<pry-remote>, ["~> 0"])
107
+ s.add_dependency(%q<pry-rescue>, ["~> 1"])
108
+ s.add_dependency(%q<pry-stack_explorer>, ["~> 0"])
109
+ end
110
+ end
111
+
data/bin/powerplay ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ PP_PATH = File.expand_path '..', File.dirname(__FILE__)
4
+ PP_EXECUTABLE = File.expand_path 'bin/powerplay', Dir.pwd
5
+
6
+ $:.unshift File.join([PP_PATH, 'lib'])
7
+
8
+ require 'ansible-powerplay/cli'
9
+
10
+ Powerplay::Cli::Main.start
@@ -0,0 +1,6 @@
1
+ require 'thor'
2
+ require 'semver'
3
+ require 'pp'
4
+ require 'open3'
5
+ require_relative 'ansible-powerplay/powerplay'
6
+ require_relative 'ansible-powerplay/dsl'
@@ -0,0 +1,35 @@
1
+ require 'ansible-powerplay'
2
+
3
+ include Powerplay::DSL
4
+
5
+ module Powerplay
6
+ module Cli
7
+ class Main < Thor
8
+ class_option :verbose, type: :numeric, banner: '[1|2|3]', aliases: '-v', default: 0
9
+
10
+ desc 'play <script>', 'Run the powerplay script.'
11
+ long_desc <<-LONGDESC
12
+ Plays a powerscript. The entries in the
13
+ script, as specified, are run in parallel
14
+ by default.
15
+ LONGDESC
16
+ option :tmux, type: :boolean, aliases: '-m', banner: "send output to all tmux panes in the current window"
17
+ option :play, type: :string, banner: "[NAME|all] Which playbook shelf", required: true
18
+ option :group, type: :string, banner: "[NAME|all] Which group to execute", default: "all"
19
+ option :book, type: :string, banner: "[NAME|all] Which book to execute", default: "all"
20
+ option :dryrun, type: :boolean, banner: "Dry run, do not actually execute."
21
+ def play(script)
22
+ DSL::_global[:options] = options
23
+ puts "script %s " % [script] if DSL::_global[:options][:verbose] >= 1
24
+ load script, true
25
+ pp DSL::_global if DSL::_global[:options][:verbose] >= 3
26
+ Play::Ansible::power_run
27
+ end
28
+
29
+ desc 'ttys', 'list all the TMUX ptys on the current window.'
30
+ def ttys
31
+ puts Play::Tmux::pane_ptys
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,112 @@
1
+ # -*- coding: utf-8 -*-
2
+ module Powerplay
3
+ module DSL
4
+ @@config_stack = [{}]
5
+ @@global_config = {}
6
+
7
+ def _bump
8
+ @@config_stack.push @@config_stack.last.clone
9
+ end
10
+
11
+ def _dip
12
+ @@config_stack.pop
13
+ end
14
+
15
+ def _config
16
+ @@config_stack.last
17
+ end
18
+
19
+ def _global
20
+ @@global_config
21
+ end
22
+
23
+ class Dsl
24
+ attr :config, :type, :desc
25
+
26
+ def method_missing(name, *args, &block)
27
+ DSL::_config[name] = args
28
+ end
29
+
30
+ def respond_to?(name, include_private = false)
31
+ true
32
+ end
33
+
34
+ def configuration(type=:vars, desc=nil, &block)
35
+ @config[type] = DslConfiguration.new(type, desc, &block).config
36
+ end
37
+
38
+ def initialize(type, desc, &ignore)
39
+ @type = type
40
+ @desc = desc
41
+ @config = {}
42
+ end
43
+ end
44
+
45
+ class DslConfiguration < Dsl
46
+ def initialize(type, desc, &block)
47
+ super
48
+ instance_eval( &block )
49
+ @config = _config.clone
50
+ end
51
+ end
52
+
53
+ class DslBook < Dsl
54
+ attr :yaml
55
+
56
+ def initialize(type, yaml, desc=nil, &block)
57
+ super(type, desc, &block)
58
+ @yaml = yaml
59
+ _bump
60
+ instance_eval(&block) if block_given?
61
+ @config = _dip
62
+ end
63
+
64
+ # Ansible playbook parameters
65
+ # TODO: there is a bogus playbook_directory param here.
66
+ def aparams
67
+ config.map{ |k,v| "#{k}=#{v.first}"}.join(' ')
68
+ end
69
+ end
70
+
71
+ class DslGroup < Dsl
72
+ attr :books
73
+
74
+ def book(type, yaml, desc=nil, &block)
75
+ @books ||= []
76
+ books << DslBook.new(type, yaml, desc, &block)
77
+ end
78
+
79
+ def initialize(type, desc, &block)
80
+ super
81
+ _bump
82
+ instance_eval &block
83
+ @config = _dip
84
+ end
85
+ end
86
+
87
+ class DslPlaybook < Dsl
88
+ attr :groups
89
+
90
+ def group name, desc=nil, &block
91
+ @groups ||= []
92
+ groups << DslGroup.new(name, desc, &block)
93
+ end
94
+
95
+ def initialize (type, desc, &block)
96
+ super
97
+ _bump
98
+ instance_eval( &block )
99
+ @config = _dip
100
+ end
101
+ end
102
+
103
+ def configuration(type=:vars, desc=nil, &block)
104
+ _global[type] = DslConfiguration.new(type, desc, &block).config
105
+ end
106
+
107
+ def playbooks(type=:vars, desc=nil, &block)
108
+ _global[:playbooks] ||= {}
109
+ _global[:playbooks][type] = DslPlaybook.new type, desc, &block
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,87 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'ansible-powerplay'
3
+
4
+ module Powerplay
5
+ module Play
6
+ DEFOUT = "&1" # default non-tmux output
7
+
8
+ def self.clopts
9
+ @cliots ||= DSL::_global[:options]
10
+ end
11
+
12
+ module Tmux
13
+ # get a list of the ptys
14
+ def self.pane_ptys
15
+ @ptys ||= if Play::clopts[:tmux]
16
+ %x[tmux list-panes -F '\#{pane_tty},']
17
+ .inspect
18
+ .chop
19
+ .split(",")
20
+ .map{ |s| s.strip.sub(/\\n|\"/, '') }
21
+ else
22
+ [Play::DEFOUT]
23
+ end
24
+ end
25
+ end
26
+
27
+ module Ansible
28
+ PLAYBOOK = "ansible-playbook"
29
+ OPTS = ""
30
+
31
+ def self.playbooks
32
+ play = Play::clopts[:play].to_sym
33
+ if play == :all
34
+ DSL::_global[:playbooks].each do |play, group|
35
+ yield play, group
36
+ end
37
+ else
38
+ yield play, DSL::_global[:playbooks][play]
39
+ end
40
+ end
41
+
42
+ # groups are serial
43
+ def self.groups(playbook)
44
+ grp = Play::clopts[:group].to_sym
45
+ playbook.groups.each do |group|
46
+ yield group if grp == :all or grp == group.type
47
+ end
48
+ end
49
+
50
+ def self.power_run
51
+ buch = Play::clopts[:book].to_sym
52
+ dryrun = Play::clopts[:dryrun]
53
+
54
+ playbooks do |pname, playbook|
55
+ puts "PLAYBOOK #{pname} (group=#{Play::clopts[:group]}) -->"
56
+ groups playbook do |group|
57
+ puts " GROUP #{group.type} (book=#{buch}) -->"
58
+ thrs = []
59
+ errors = []
60
+ group.books.zip(Tmux.pane_ptys) do |book, tty|
61
+ tty ||= Tmux.pane_ptys.last
62
+ if buch == :all or book.type == buch
63
+ puts " BOOK #{book.type}"
64
+ apcmd = %|#{PLAYBOOK} #{OPTS} #{book.config[:playbook_directory].first}/#{book.yaml} --extra-vars "#{book.aparams}" >#{tty}|
65
+ thrs << Thread.new {
66
+ std, status = Open3.capture2e apcmd
67
+ errors << [book.yaml, apcmd, std] unless status.success?
68
+ } unless dryrun
69
+ end
70
+ end
71
+ thrs.each{ |t| t.join }
72
+ unless errors.empty?
73
+ errors.each do |yaml, cmd, txt|
74
+ puts '=' * 30
75
+ puts ('*' * 10) + ' ' + yaml
76
+ puts txt
77
+ puts '-' * 30
78
+ puts cmd
79
+ end
80
+ exit 10
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "AnsiblePowerplay" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,29 @@
1
+ require 'simplecov'
2
+
3
+ module SimpleCov::Configuration
4
+ def clean_filters
5
+ @filters = []
6
+ end
7
+ end
8
+
9
+ SimpleCov.configure do
10
+ clean_filters
11
+ load_adapter 'test_frameworks'
12
+ end
13
+
14
+ ENV["COVERAGE"] && SimpleCov.start do
15
+ add_filter "/.rvm/"
16
+ end
17
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
18
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
19
+
20
+ require 'rspec'
21
+ require 'ansible-powerplay'
22
+
23
+ # Requires supporting files with custom matchers and macros, etc,
24
+ # in ./support/ and its subdirectories.
25
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
26
+
27
+ RSpec.configure do |config|
28
+
29
+ end
metadata ADDED
@@ -0,0 +1,320 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ansible-powerplay
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Fred Mitchell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
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'
27
+ - !ruby/object:Gem::Dependency
28
+ name: concurrent-ruby
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: term-ansicolor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rdoc
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: bundler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: juwelier
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2'
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: semver
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1'
153
+ - !ruby/object:Gem::Dependency
154
+ name: guard
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '2'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '2'
167
+ - !ruby/object:Gem::Dependency
168
+ name: guard-rspec
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '1'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '1'
181
+ - !ruby/object:Gem::Dependency
182
+ name: pry
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: pry-byebug
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '3'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '3'
209
+ - !ruby/object:Gem::Dependency
210
+ name: pry-doc
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: pry-remote
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ - !ruby/object:Gem::Dependency
238
+ name: pry-rescue
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: '1'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: '1'
251
+ - !ruby/object:Gem::Dependency
252
+ name: pry-stack_explorer
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: '0'
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "~>"
263
+ - !ruby/object:Gem::Version
264
+ version: '0'
265
+ description: |-
266
+ Ansible Powerplay, by way of its DSL, allows you to
267
+ specify your Ansible playbooks and their vars, and common
268
+ vars to all, so that you can run your
269
+ indeoendent playbooks in full parallel.
270
+ email: fred.mitchell@gmx.de
271
+ executables:
272
+ - powerplay
273
+ extensions: []
274
+ extra_rdoc_files:
275
+ - LICENSE.txt
276
+ - README.org
277
+ files:
278
+ - ".document"
279
+ - ".rspec"
280
+ - ".ruby-version"
281
+ - ".semver"
282
+ - Gemfile
283
+ - Gemfile.lock
284
+ - LICENSE.txt
285
+ - README.org
286
+ - Rakefile
287
+ - SCRATCHPAD.org
288
+ - ansible-powerplay.gemspec
289
+ - bin/powerplay
290
+ - lib/ansible-powerplay.rb
291
+ - lib/ansible-powerplay/cli.rb
292
+ - lib/ansible-powerplay/dsl.rb
293
+ - lib/ansible-powerplay/powerplay.rb
294
+ - spec/ansible-powerplay_spec.rb
295
+ - spec/spec_helper.rb
296
+ homepage: http://github.com/flajann2/ansible-powerplay
297
+ licenses:
298
+ - MIT
299
+ metadata: {}
300
+ post_install_message:
301
+ rdoc_options: []
302
+ require_paths:
303
+ - lib
304
+ required_ruby_version: !ruby/object:Gem::Requirement
305
+ requirements:
306
+ - - ">="
307
+ - !ruby/object:Gem::Version
308
+ version: '2.0'
309
+ required_rubygems_version: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - ">="
312
+ - !ruby/object:Gem::Version
313
+ version: '0'
314
+ requirements: []
315
+ rubyforge_project:
316
+ rubygems_version: 2.5.1
317
+ signing_key:
318
+ specification_version: 4
319
+ summary: Powerplay enables you to run Ansible playbooks in parallel.
320
+ test_files: []