ansible-powerplay 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.semver +1 -1
- data/README.org +26 -1
- data/RELEASE_NOTES.org +13 -12
- data/ansible-powerplay.gemspec +3 -3
- data/lib/ansible-powerplay/cli.rb +23 -7
- data/lib/ansible-powerplay/powerplay.rb +42 -38
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69f3a4daf0204e14ee2ef52d7c6aac60b3d8d381
|
4
|
+
data.tar.gz: 7c137de2f93e486edf904d3725a5c7df2d8678cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90c32a85c428d6ed98860b4ed0944c256bc9bcc0b34e8ac3ec6c40074cada8934b4e62b9dddb2504943978c6ab8b434b22a616c106f1cd15bedf1127ddfce7f1
|
7
|
+
data.tar.gz: ad6a6e5bb2d66a78d5c3bd735f0a9f7f7a3599f2d2ee8b093d29bdd557b7a5a23a1d840c72e4919f1c1d3711d7d3233923025636355562f2207db305a2cf32d4
|
data/.semver
CHANGED
data/README.org
CHANGED
@@ -84,7 +84,7 @@
|
|
84
84
|
|
85
85
|
** Use
|
86
86
|
Basically, cd to the root of your Ansible directory,
|
87
|
-
and a .play file (see the example at: [[https://github.com/flajann2/ansible-powerplay/blob/master/examples/
|
87
|
+
and a .play file (see the example at: [[https://github.com/flajann2/ansible-powerplay/blob/master/examples/stack.play][stack.play]].)
|
88
88
|
|
89
89
|
You can place a config clause either globally,
|
90
90
|
inside of playbooks, inside of groups, and the
|
@@ -203,6 +203,31 @@ Options:
|
|
203
203
|
shall be adding many more subcommands and options as our needs demands.
|
204
204
|
If you like to see something here, please submit it as an issue on Github.
|
205
205
|
|
206
|
+
And for an example of play help, (note that this may not be up-to-date, so
|
207
|
+
please run 'powerplay help play' on your installe version!)
|
208
|
+
#+BEGIN_SRC doc
|
209
|
+
powerplay help play
|
210
|
+
Usage:
|
211
|
+
powerplay play [script] -p, --play, --power, --play=[NAME[ NAME2...]|all]
|
212
|
+
|
213
|
+
Options:
|
214
|
+
-m, [--tmux=[WINDOWNUMBERopt]] # Send output to all tmux panes in the current window, or the numeric window specified.
|
215
|
+
-p, --play, --power, --play=[NAME[ NAME2...]|all] # Which PowerPlay playbooks (as opposed to Ansible playbooks) to specifically execute.
|
216
|
+
-g, [--group=[NAME[ NAME2...]|all]] # Which groups to execute.
|
217
|
+
# Default: [:all]
|
218
|
+
-c, [--congroups], [--no-congroups] # Run the groups themselves concurrently
|
219
|
+
-b, [--book=[NAME[ NAME2...]|all]] # Which books to execute.
|
220
|
+
# Default: [:all]
|
221
|
+
-u, [--dryrun], [--no-dryrun] # Dry run, do not actually execute.
|
222
|
+
-x, --extra-vars, [--extra=<BOOKNAME|all>:"key1a=value1a key2a=value2a... " [BOOKNAME2:"key1b=value1b key2b=value2b... "]] # Pass custom parameters directly to playbooks. You may either pass parameters to all playbooks or specific ones.
|
223
|
+
-v, [--verbose=[1|2|3]]
|
224
|
+
# Default: 0
|
225
|
+
|
226
|
+
Description:
|
227
|
+
Plays a PowerPlay script. The entries in the script, as specified inside of a group, are run in parallel by default.
|
228
|
+
#+END_SRC
|
229
|
+
|
230
|
+
|
206
231
|
*** Example .play Script
|
207
232
|
To play around with the example .play script,
|
208
233
|
Clone the [[https://github.com/flajann2/ansible-powerplay][Ansible Powerplay]] project locally:
|
data/RELEASE_NOTES.org
CHANGED
@@ -7,18 +7,19 @@
|
|
7
7
|
major number. Of course, you can read all about it here.
|
8
8
|
|
9
9
|
** Release Notes
|
10
|
-
| Release | Feature / Bug | Description
|
11
|
-
|
12
|
-
| v0.2.
|
13
|
-
| v0.
|
14
|
-
| v0.1.
|
15
|
-
| v0.1.
|
16
|
-
| v0.1.
|
17
|
-
| v0.0
|
18
|
-
|
|
19
|
-
| | --tmux | Now
|
20
|
-
| | --
|
21
|
-
| | --
|
10
|
+
| Release | Feature / Bug | Description | Date |
|
11
|
+
|---------+----------------------------------+------------------------------------------------------------------------------------+------------|
|
12
|
+
| v0.2.1 | --extra-vars | A way of passing extra vars to the Ansible playbooks. Please see the documentation | 2016-03-01 |
|
13
|
+
| v0.2.0 | powerplay play (behavior change) | If script is not given, now defaults to 'stack.play' in the current directory. | 2016-02-29 |
|
14
|
+
| v0.1.3 | --tmux | Better handling at distributing the panes. | 2016-02-26 |
|
15
|
+
| v0.1.2 | --tmux. --no-tmux | Default output now goes to current tty | 2016-02-23 |
|
16
|
+
| v0.1.1 | --book, --group, --play | Minor bug with the array handling | 2016-02-22 |
|
17
|
+
| v0.1.0 | --book, --group, --play | Now each can take multiple specifications | 2016-02-22 |
|
18
|
+
| v0.0.8 | Creation of these Release Notes | About bloody time. The prior releases were all mostly bug fixes, and so... | 2016-02-20 |
|
19
|
+
| | --tmux | Now you can optionally specify the window number | |
|
20
|
+
| | --tmux | Now checks to ensure it does not dump to its own pane | |
|
21
|
+
| | --book | You can select an individual playbook to run | |
|
22
|
+
| | --group | You can select an individual group to run | |
|
22
23
|
|
23
24
|
** Known Outstanding Issues
|
24
25
|
Bugs and missing features that needs to be addressed. As they are,
|
data/ansible-powerplay.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: ansible-powerplay 0.2.
|
5
|
+
# stub: ansible-powerplay 0.2.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "ansible-powerplay"
|
9
|
-
s.version = "0.2.
|
9
|
+
s.version = "0.2.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Fred Mitchell"]
|
14
|
-
s.date = "2016-
|
14
|
+
s.date = "2016-03-01"
|
15
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
16
|
s.email = "fred.mitchell@gmx.de"
|
17
17
|
s.executables = ["powerplay"]
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'ansible-powerplay'
|
2
3
|
|
3
4
|
include Powerplay::DSL
|
@@ -16,14 +17,21 @@ module Powerplay
|
|
16
17
|
if [script] is not given, it defaults to 'stack.play'
|
17
18
|
in the current directory.
|
18
19
|
LONGDESC
|
19
|
-
option :tmux, type: :numeric,
|
20
|
-
|
21
|
-
option :
|
22
|
-
|
23
|
-
option :
|
24
|
-
|
20
|
+
option :tmux, type: :numeric, aliases: '-m', banner: "[WINDOWNUMBERopt]", lazy_default: 0,
|
21
|
+
desc: ' Send output to all tmux panes in the current window, or the numeric window specified.'
|
22
|
+
option :play, type: :array, aliases: ['-p', '--play', '--power'], banner: "[NAME[ NAME2...]|all]", required: true,
|
23
|
+
desc: 'Which PowerPlay playbooks (as opposed to Ansible playbooks) to specifically execute.'
|
24
|
+
option :group, type: :array, aliases: '-g', banner: "[NAME[ NAME2...]|all]", default: [:all],
|
25
|
+
desc: ' Which groups to execute.'
|
26
|
+
option :congroups, type: :boolean, aliases: '-c', desc: "Run the groups themselves concurrently"
|
27
|
+
option :book, type: :array, aliases: '-b', banner: "[NAME[ NAME2...]|all]", default: [:all],
|
28
|
+
desc: 'Which books to execute.'
|
29
|
+
option :dryrun, type: :boolean, aliases: '-u', desc: "Dry run, do not actually execute."
|
30
|
+
option :extra, type: :array, aliases: ['-x', '--extra-vars'],
|
31
|
+
banner: %(<BOOKNAME|all>:"key1a=value1a key2a=value2a... " [BOOKNAME2:"key1b=value1b key2b=value2b... "]), default: [],
|
32
|
+
desc: 'Pass custom parameters directly to playbooks. You may either pass parameters to all playbooks or specific ones.'
|
25
33
|
def play(script = 'stack.play')
|
26
|
-
DSL::_global[:options] = options
|
34
|
+
DSL::_global[:options] = massage options
|
27
35
|
puts "script %s " % [script] if DSL::_global[:options][:verbose] >= 1
|
28
36
|
load script, true
|
29
37
|
pp DSL::_global if DSL::_verbosity >= 3
|
@@ -34,6 +42,14 @@ module Powerplay
|
|
34
42
|
def ttys
|
35
43
|
puts Play::Tmux::pane_ptys
|
36
44
|
end
|
45
|
+
|
46
|
+
no_commands do
|
47
|
+
def massage(options)
|
48
|
+
opt = Thor::CoreExt::HashWithIndifferentAccess.new options
|
49
|
+
opt[:extra] = Thor::CoreExt::HashWithIndifferentAccess.new opt[:extra].map{ |s| s.split(':', 2)}.to_h
|
50
|
+
opt
|
51
|
+
end
|
52
|
+
end
|
37
53
|
end
|
38
54
|
end
|
39
55
|
end
|
@@ -6,7 +6,7 @@ CRITICAL = Mutex.new
|
|
6
6
|
module Powerplay
|
7
7
|
module Play
|
8
8
|
def self.clopts
|
9
|
-
@
|
9
|
+
@clopts ||= Thor::CoreExt::HashWithIndifferentAccess.new DSL::_global[:options]
|
10
10
|
end
|
11
11
|
|
12
12
|
module Tmux
|
@@ -68,52 +68,56 @@ module Powerplay
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
def self.run_book(book, bucher, book_threads, errors)
|
72
|
+
dryrun = Play::clopts[:dryrun]
|
73
|
+
extra = Play::clopts[:extra]
|
74
|
+
tty ||= Tmux.grab_a_tty
|
75
|
+
puts " tty == #{tty} (#{Tmux.pane_ttys.last})" unless DSL::_verbosity < 2
|
76
|
+
if bucher.first == :all or bucher.member?(book.type)
|
77
|
+
puts " BOOK #{book.type}"
|
78
|
+
inv = if book.config.member? :inventory
|
79
|
+
"-i #{book.config[:inventory].first}"
|
80
|
+
else
|
81
|
+
''
|
82
|
+
end
|
83
|
+
xxv = [extra[book.type], extra[:all]].compact.join(' ')
|
84
|
+
apcmd = %|#{PLAYBOOK} #{OPTS} #{inv} #{book.config[:playbook_directory].first}/#{book.yaml} --extra-vars "#{book.aparams} #{xxv}" >#{tty}|
|
85
|
+
book_threads << Thread.new {
|
86
|
+
std, status = Open3.capture2e apcmd
|
87
|
+
errors << [book.yaml, apcmd, std] unless status.success?
|
88
|
+
} unless dryrun
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
71
92
|
def self.power_run
|
72
93
|
bucher = Play::clopts[:book].map{ |b| b.to_sym }
|
73
|
-
dryrun = Play::clopts[:dryrun]
|
74
94
|
congroups = Play::clopts[:congroups]
|
75
95
|
playbooks do |pname, playbook|
|
76
|
-
|
96
|
+
group_threads = []
|
77
97
|
puts "PLAYBOOK #{pname} (group=#{Play::clopts[:group]}) -->"
|
78
98
|
groups playbook do |group|
|
79
99
|
tg = nil
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
errors << [book.yaml, apcmd, std] unless status.success?
|
98
|
-
} unless dryrun
|
99
|
-
end
|
100
|
-
end
|
101
|
-
thrbooks.each{ |t| t.join }
|
102
|
-
unless errors.empty?
|
103
|
-
errors.each do |yaml, cmd, txt|
|
104
|
-
puts '=' * 30
|
105
|
-
puts ('*' * 10) + ' ' + yaml
|
106
|
-
puts txt
|
107
|
-
puts '-' * 30
|
108
|
-
puts cmd
|
109
|
-
end
|
110
|
-
exit 10
|
111
|
-
end
|
112
|
-
})
|
100
|
+
group_threads << (tg = Thread.new {
|
101
|
+
puts " GROUP #{group.type} (book=#{bucher}, cg=#{congroups}) -->"
|
102
|
+
book_threads = []
|
103
|
+
errors = []
|
104
|
+
group.books.each { |book| run_book(book, bucher, book_threads, errors) }
|
105
|
+
book_threads.each{ |t| t.join }
|
106
|
+
unless errors.empty?
|
107
|
+
errors.each do |yaml, cmd, txt|
|
108
|
+
puts '=' * 30
|
109
|
+
puts ('*' * 10) + ' ' + yaml
|
110
|
+
puts txt
|
111
|
+
puts '-' * 30
|
112
|
+
puts cmd
|
113
|
+
end
|
114
|
+
exit 10
|
115
|
+
end
|
116
|
+
})
|
113
117
|
# Always wait here unless we're concurrent
|
114
|
-
|
118
|
+
group_threads.join unless congroups
|
115
119
|
end
|
116
|
-
|
120
|
+
group_threads.each{ |t| t.join }
|
117
121
|
end
|
118
122
|
end
|
119
123
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ansible-powerplay
|
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
|
- Fred Mitchell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|