ansible-powerplay 0.2.4 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.semver +3 -3
- data/Gemfile +20 -19
- data/Gemfile.lock +28 -21
- data/README.org +275 -57
- data/RELEASE_NOTES.org +35 -26
- data/SCRATCHPAD.org +6 -0
- data/ansible-powerplay.gemspec +21 -10
- data/bin/powerplay +1 -0
- data/bin/pp +11 -0
- data/examples/playbooks/dat.yml +15 -0
- data/examples/playbooks/elasticseach.yml +15 -0
- data/examples/playbooks/first.yml +15 -0
- data/examples/playbooks/nat.yml +15 -0
- data/examples/playbooks/rabbitmq.yml +15 -0
- data/examples/playbooks/rat.yml +15 -0
- data/examples/playbooks/second.yml +15 -0
- data/lib/ansible-powerplay.rb +10 -0
- data/lib/ansible-powerplay/cli.rb +36 -2
- data/lib/ansible-powerplay/dsl.rb +75 -11
- data/lib/ansible-powerplay/powerplay.rb +77 -42
- metadata +35 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 774d2836732139cdc48afb423c32079076007d70
|
4
|
+
data.tar.gz: 4b66ed12f74c487132733f5d78508b2876507636
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83a5d5075693f7360c9f607f82d5d665955a99d3ecaf00417e789f2a0e572736e436b24801d73b92a1e19427b6d8a538cefdb43a49d257e52c3ddf083ae228b7
|
7
|
+
data.tar.gz: 7141efb2e5ce770b50e71e246aa9d75df2ea0e4f5f80952836bd551cf1eb0c3794926ded3ea760ff1750f52fefcf7aa22842a9b33ab5c0b1cc4c8a989e3a2788
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.1
|
data/.semver
CHANGED
data/Gemfile
CHANGED
@@ -1,25 +1,26 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem 'thor',
|
4
|
-
gem '
|
5
|
-
gem '
|
6
|
-
gem '
|
7
|
-
gem '
|
3
|
+
gem 'thor', '~> 0'
|
4
|
+
gem 'term-ansicolor', '~> 1'
|
5
|
+
gem 'colorize', '~> 0'
|
6
|
+
gem 'semver', '~> 1'
|
7
|
+
gem 'queue_ding', '~> 0'
|
8
|
+
gem 'concurrent-ruby', '~> 1', require: 'concurrent'
|
8
9
|
|
9
10
|
group :development do
|
10
|
-
gem
|
11
|
-
gem
|
12
|
-
gem
|
13
|
-
gem
|
14
|
-
gem
|
15
|
-
gem
|
16
|
-
gem 'guard',
|
17
|
-
gem 'guard-rspec',
|
11
|
+
gem 'rspec', '~> 2'
|
12
|
+
gem 'yard', '~> 0'
|
13
|
+
gem 'rdoc', '~> 3'
|
14
|
+
gem 'bundler', '~> 1'
|
15
|
+
gem 'juwelier', '~> 2'
|
16
|
+
gem 'simplecov', '>= 0'
|
17
|
+
gem 'guard', '~> 2'
|
18
|
+
gem 'guard-rspec', '~> 1'
|
18
19
|
|
19
|
-
gem 'pry',
|
20
|
-
gem 'pry-byebug',
|
21
|
-
gem 'pry-doc',
|
22
|
-
gem 'pry-remote',
|
23
|
-
gem 'pry-rescue',
|
20
|
+
gem 'pry', '~> 0'
|
21
|
+
gem 'pry-byebug', '~> 3'
|
22
|
+
gem 'pry-doc', '~> 0'
|
23
|
+
gem 'pry-remote', '~> 0'
|
24
|
+
gem 'pry-rescue', '~> 1'
|
24
25
|
gem 'pry-stack_explorer', '~> 0'
|
25
26
|
end
|
data/Gemfile.lock
CHANGED
@@ -2,13 +2,14 @@ GEM
|
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
4
|
addressable (2.4.0)
|
5
|
+
aquarium (0.5.1)
|
5
6
|
binding_of_caller (0.7.2)
|
6
7
|
debug_inspector (>= 0.0.1)
|
7
8
|
builder (3.2.2)
|
8
|
-
byebug (
|
9
|
+
byebug (9.0.5)
|
9
10
|
coderay (1.1.1)
|
10
11
|
colorize (0.7.7)
|
11
|
-
concurrent-ruby (1.0.
|
12
|
+
concurrent-ruby (1.0.2)
|
12
13
|
debug_inspector (0.0.2)
|
13
14
|
descendants_tracker (0.0.4)
|
14
15
|
thread_safe (~> 0.3, >= 0.3.1)
|
@@ -19,16 +20,15 @@ GEM
|
|
19
20
|
ffi (1.9.10)
|
20
21
|
formatador (0.2.5)
|
21
22
|
git (1.3.0)
|
22
|
-
github_api (0.
|
23
|
+
github_api (0.14.0)
|
23
24
|
addressable (~> 2.4.0)
|
24
25
|
descendants_tracker (~> 0.0.4)
|
25
26
|
faraday (~> 0.8, < 0.10)
|
26
27
|
hashie (>= 3.4)
|
27
|
-
multi_json (>= 1.7.5, < 2.0)
|
28
28
|
oauth2
|
29
|
-
guard (2.
|
29
|
+
guard (2.14.0)
|
30
30
|
formatador (>= 0.2.4)
|
31
|
-
listen (>= 2.7,
|
31
|
+
listen (>= 2.7, < 4.0)
|
32
32
|
lumberjack (~> 1.0)
|
33
33
|
nenv (~> 0.1)
|
34
34
|
notiffany (~> 0.0)
|
@@ -37,11 +37,11 @@ GEM
|
|
37
37
|
thor (>= 0.18.1)
|
38
38
|
guard-rspec (1.2.2)
|
39
39
|
guard (>= 1.1)
|
40
|
-
hashie (3.4.
|
40
|
+
hashie (3.4.4)
|
41
41
|
highline (1.7.8)
|
42
42
|
interception (0.5)
|
43
43
|
json (1.8.3)
|
44
|
-
juwelier (2.1.
|
44
|
+
juwelier (2.1.2)
|
45
45
|
builder
|
46
46
|
bundler (>= 1.0)
|
47
47
|
git (>= 1.2.5)
|
@@ -50,20 +50,22 @@ GEM
|
|
50
50
|
nokogiri (>= 1.5.10)
|
51
51
|
rake
|
52
52
|
rdoc
|
53
|
+
semver
|
53
54
|
jwt (1.5.1)
|
54
|
-
listen (3.
|
55
|
-
rb-fsevent (>= 0.9.
|
56
|
-
rb-inotify (>= 0.9.7)
|
55
|
+
listen (3.1.5)
|
56
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
57
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
58
|
+
ruby_dep (~> 1.2)
|
57
59
|
lumberjack (1.0.10)
|
58
60
|
method_source (0.8.2)
|
59
61
|
mini_portile2 (2.0.0)
|
60
|
-
multi_json (1.
|
62
|
+
multi_json (1.12.1)
|
61
63
|
multi_xml (0.5.5)
|
62
64
|
multipart-post (2.0.0)
|
63
65
|
nenv (0.3.0)
|
64
66
|
nokogiri (1.6.7.2)
|
65
67
|
mini_portile2 (~> 2.0.0.rc2)
|
66
|
-
notiffany (0.0
|
68
|
+
notiffany (0.1.0)
|
67
69
|
nenv (~> 0.1)
|
68
70
|
shellany (~> 0.0)
|
69
71
|
oauth2 (1.1.0)
|
@@ -76,8 +78,8 @@ GEM
|
|
76
78
|
coderay (~> 1.1.0)
|
77
79
|
method_source (~> 0.8.1)
|
78
80
|
slop (~> 3.4)
|
79
|
-
pry-byebug (3.
|
80
|
-
byebug (~>
|
81
|
+
pry-byebug (3.4.0)
|
82
|
+
byebug (~> 9.0)
|
81
83
|
pry (~> 0.10)
|
82
84
|
pry-doc (0.8.0)
|
83
85
|
pry (~> 0.9)
|
@@ -85,14 +87,17 @@ GEM
|
|
85
87
|
pry-remote (0.1.8)
|
86
88
|
pry (~> 0.9)
|
87
89
|
slop (~> 3.0)
|
88
|
-
pry-rescue (1.4.
|
90
|
+
pry-rescue (1.4.4)
|
89
91
|
interception (>= 0.5)
|
90
92
|
pry
|
91
93
|
pry-stack_explorer (0.4.9.2)
|
92
94
|
binding_of_caller (>= 0.7)
|
93
95
|
pry (>= 0.9.11)
|
96
|
+
queue_ding (0.1.2)
|
97
|
+
aquarium (~> 0)
|
98
|
+
semver (~> 1)
|
94
99
|
rack (1.6.4)
|
95
|
-
rake (11.1.
|
100
|
+
rake (11.1.2)
|
96
101
|
rb-fsevent (0.9.7)
|
97
102
|
rb-inotify (0.9.7)
|
98
103
|
ffi (>= 0.5.0)
|
@@ -106,6 +111,7 @@ GEM
|
|
106
111
|
rspec-expectations (2.99.2)
|
107
112
|
diff-lcs (>= 1.1.3, < 2.0)
|
108
113
|
rspec-mocks (2.99.4)
|
114
|
+
ruby_dep (1.3.1)
|
109
115
|
semver (1.0.1)
|
110
116
|
shellany (0.0.1)
|
111
117
|
simplecov (0.11.2)
|
@@ -118,7 +124,7 @@ GEM
|
|
118
124
|
tins (~> 1.0)
|
119
125
|
thor (0.19.1)
|
120
126
|
thread_safe (0.3.5)
|
121
|
-
tins (1.
|
127
|
+
tins (1.10.2)
|
122
128
|
yard (0.8.7.6)
|
123
129
|
|
124
130
|
PLATFORMS
|
@@ -127,7 +133,7 @@ PLATFORMS
|
|
127
133
|
DEPENDENCIES
|
128
134
|
bundler (~> 1)
|
129
135
|
colorize (~> 0)
|
130
|
-
concurrent-ruby
|
136
|
+
concurrent-ruby (~> 1)
|
131
137
|
guard (~> 2)
|
132
138
|
guard-rspec (~> 1)
|
133
139
|
juwelier (~> 2)
|
@@ -137,13 +143,14 @@ DEPENDENCIES
|
|
137
143
|
pry-remote (~> 0)
|
138
144
|
pry-rescue (~> 1)
|
139
145
|
pry-stack_explorer (~> 0)
|
146
|
+
queue_ding (~> 0)
|
140
147
|
rdoc (~> 3)
|
141
148
|
rspec (~> 2)
|
142
149
|
semver (~> 1)
|
143
150
|
simplecov
|
144
|
-
term-ansicolor
|
151
|
+
term-ansicolor (~> 1)
|
145
152
|
thor (~> 0)
|
146
153
|
yard (~> 0)
|
147
154
|
|
148
155
|
BUNDLED WITH
|
149
|
-
1.
|
156
|
+
1.12.5
|
data/README.org
CHANGED
@@ -1,25 +1,29 @@
|
|
1
1
|
* Ansible Powerplay
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
and
|
21
|
-
|
22
|
-
|
3
|
+
#+ATTR_HTML: title="Join the chat at https://gitter.im/flajann2/ansible-powerplay"
|
4
|
+
[[https://gitter.im/flajann2/ansible-powerplay?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge][file:https://badges.gitter.im/flajann2/ansible-powerplay.svg]]
|
5
|
+
|
6
|
+
Powerplay allows you to run multiple Ansible
|
7
|
+
playbooks in parallel. Depending on how you organize
|
8
|
+
your playbooks, this can be a solid win. I basically
|
9
|
+
before this had been doing a playbook with multiple
|
10
|
+
includes for other playbooks representing different
|
11
|
+
servers in our stack. Playbook launching of playbooks
|
12
|
+
is slow and very serial.
|
13
|
+
|
14
|
+
Basically, the playbooks are all contained, so no
|
15
|
+
interdependencies. And in my case, running in the
|
16
|
+
cloud, so no reason why they can't be running in
|
17
|
+
parallel
|
18
|
+
|
19
|
+
Powerplay allows you to specify vars common to all
|
20
|
+
playbooks, and also vars specific to some playbooks
|
21
|
+
so by which you can make your setup very DRY.
|
22
|
+
|
23
|
+
All the Ansible playbooks are executed in seperate
|
24
|
+
processes, and thus avoiding a number of the "side
|
25
|
+
effects" you would normally encounter with running
|
26
|
+
multiple playbooks with Ansible includes.
|
23
27
|
|
24
28
|
For example, here is Powerplay integrated with tmux:
|
25
29
|
#+CAPTION: Powerplay writing to tmux panes, one pane per playbook.
|
@@ -27,49 +31,106 @@
|
|
27
31
|
[[./examples/powerplay_screenshot.jpeg]]
|
28
32
|
|
29
33
|
** Release Notes
|
30
|
-
Please see [[RELEASE_NOTES.org][Release Notes]]
|
34
|
+
Please see [[RELEASE_NOTES.org][Release Notes]].
|
35
|
+
|
36
|
+
The version 1.x releases have a new DSL
|
37
|
+
which may be slightly incompatable with the older 0.x DSL.
|
38
|
+
There will be a lapse between this release and the
|
39
|
+
documentaiton of the differences.
|
40
|
+
|
41
|
+
Also, the capture of the output from ansible-powerplay is
|
42
|
+
handled a bit more intelligently. If you do not specify the
|
43
|
+
--tmux (or -m) option, all output is now currently captured
|
44
|
+
by powerplay and redumped to the console.
|
45
|
+
|
46
|
+
Because you may still want to see the color from ansible-powerplay,
|
47
|
+
you can alter ansible.cfg and add the following line:
|
48
|
+
|
49
|
+
+ force_color = 1
|
50
|
+
|
31
51
|
** Features and Cavets
|
32
52
|
*** Integration with TMUX
|
33
|
-
When running multiple Ansible Playbooks
|
34
|
-
one would like to be able to see the
|
35
|
-
in a reasonable manner. To faciliate
|
36
|
-
initial realse, we shall make heavy
|
37
|
-
to dump the output.
|
53
|
+
When running multiple Ansible Playbooks
|
54
|
+
concurrently, one would like to be able to see the
|
55
|
+
output of each in a reasonable manner. To faciliate
|
56
|
+
this in this initial realse, we shall make heavy
|
57
|
+
use of TMUX panes to dump the output.
|
38
58
|
|
39
59
|
So basically, you need as many panes as you have
|
40
|
-
concurrent Ansible Playbooks in this initial
|
41
|
-
subsequent releases, Curses will be
|
42
|
-
leveraged to create "tabs" for the
|
43
|
-
streams. We may even do this,
|
60
|
+
concurrent Ansible Playbooks in this initial
|
61
|
+
release. In subsequent releases, Curses will be
|
62
|
+
directly leveraged to create "tabs" for the
|
63
|
+
multiple output streams. We may even do this,
|
64
|
+
still, through TMUX.
|
44
65
|
|
45
|
-
Your input on this is strongly encouarged. We will
|
46
|
-
be supporting Screen at all. Sorry.
|
66
|
+
Your input on this is strongly encouarged. We will
|
67
|
+
not be supporting Screen at all. Sorry.
|
47
68
|
|
48
69
|
** DSL Terminology & Documentation
|
70
|
+
Note that this is the DSL for version 1.x of
|
71
|
+
PowerPlay. For 0.x, please see those tags in
|
72
|
+
GitHub.
|
73
|
+
|
49
74
|
*** DSL
|
50
75
|
The DSL is straightforward as possible,
|
51
76
|
simple and elegant to allow you to write
|
52
77
|
your Powerplays in a DRY manner.
|
78
|
+
|
79
|
+
For examples, please see the following:
|
80
|
+
| [[examples/stack.play][stack.play]] | This is loaded by default, and you must be in your current directory |
|
81
|
+
| [[examples/development.play][development.play]] | This is a fullblown Power Playbook for a hypothetical development stack. |
|
82
|
+
| [[examples/production.play][production.play]] | This is a fullblown Power Playbook for a hypothetical production stack. |
|
83
|
+
| [[examples/playbooks][playbooks]] | Sample Ansible playbooks called by Powerplay. |
|
84
|
+
|
85
|
+
To run the powerplay example:
|
86
|
+
|
87
|
+
1. Install Ansible Powerplay
|
88
|
+
+ gem install ansible-powerplay
|
89
|
+
2. Clone this project locally, then cd into the examples directory
|
90
|
+
+ git clone https://github.com/flajann2/ansible-powerplay.git
|
91
|
+
+ cd ansible-powerplay/examples
|
92
|
+
3. source ansible-paths and run Powerplay
|
93
|
+
+ source ansible-paths.sh
|
94
|
+
+ powerplay play -p development -v2
|
95
|
+
|
96
|
+
Note that I deliberately left a missing "elasticsearch.yml" so you
|
97
|
+
can see how Powerplay handles the errors.
|
98
|
+
|
53
99
|
**** configuration
|
54
100
|
You can intersperse configuration blocks
|
55
101
|
anywhere, and the expected nested scoping
|
56
102
|
will take effect.
|
57
103
|
**** playbooks
|
58
|
-
playbooks are a collection of groups, and
|
59
|
-
|
104
|
+
playbooks are a collection of groups, and a group
|
105
|
+
defaults to async mode for its members.
|
106
|
+
|
107
|
+
Group are normally executed serially. This will
|
60
108
|
allow you to organize your plays in an intelligent
|
61
109
|
manner to deploy and manage resources and assets
|
62
110
|
that may have to be done in a serial manner.
|
63
111
|
**** group
|
64
|
-
A group is a collection of books
|
65
|
-
|
66
|
-
|
112
|
+
A group is a collection of books or other groups
|
113
|
+
that all execute in parallel by default.
|
114
|
+
Books are required to be independent of
|
115
|
+
each other. If they are not, you can set
|
116
|
+
them up to execute serially.
|
117
|
+
|
67
118
|
**** book
|
68
119
|
A book has a direct correspondence to an Ansible
|
69
120
|
playbook, and will execute that Yaml file
|
70
121
|
given the configuration variables as parameters.
|
71
122
|
|
72
123
|
Here is where var inheritance becomes useful.
|
124
|
+
Note that all the configuration variables
|
125
|
+
set at the time the book is called are all
|
126
|
+
passed in as --extra-vars to Ansible Playbook.
|
127
|
+
The Playbook may not need all the vars passed
|
128
|
+
in, but care must be taken that no vars
|
129
|
+
are used in a different manner than expected.
|
130
|
+
We currently have no way of knowing which
|
131
|
+
vars are needed or not, and to specifiy that
|
132
|
+
would make the syntax messy and loose some
|
133
|
+
of the advantages of var inheritance.
|
73
134
|
|
74
135
|
** Installation
|
75
136
|
Easy installation. From command-line:
|
@@ -88,9 +149,9 @@
|
|
88
149
|
|
89
150
|
You can place a config clause either globally,
|
90
151
|
inside of playbooks, inside of groups, and the
|
91
|
-
variable set up this way are inherited to the
|
92
|
-
clauses, thus allowing you to keep your
|
93
|
-
DRYer.
|
152
|
+
variable set up this way are inherited to the
|
153
|
+
inner clauses, thus allowing you to keep your
|
154
|
+
specifications DRYer.
|
94
155
|
|
95
156
|
For example:
|
96
157
|
#+BEGIN_SRC ruby
|
@@ -100,12 +161,12 @@
|
|
100
161
|
end
|
101
162
|
#+END_SRC
|
102
163
|
|
103
|
-
Note that 'playbook_directory' is special, as it
|
104
|
-
you to define the directory all of your
|
105
|
-
can be found. You can also specify
|
106
|
-
you can use the configuration clause,
|
107
|
-
may set up different playbook directories for
|
108
|
-
playbook collections.
|
164
|
+
Note that 'playbook_directory' is special, as it
|
165
|
+
allows you to define the directory all of your
|
166
|
+
Ansible playbooks can be found. You can also specify
|
167
|
+
this anywhere you can use the configuration clause,
|
168
|
+
so you may set up different playbook directories for
|
169
|
+
different playbook collections.
|
109
170
|
|
110
171
|
#+BEGIN_SRC ruby
|
111
172
|
# sṕecific configuration for :development
|
@@ -118,10 +179,12 @@
|
|
118
179
|
end
|
119
180
|
#+END_SRC
|
120
181
|
|
121
|
-
The above shows Ansible variables for my
|
122
|
-
that is geared with work
|
123
|
-
|
124
|
-
|
182
|
+
The above shows Ansible variables for my
|
183
|
+
specialiezd setup that is geared with work
|
184
|
+
with AWS. You are free to specify any
|
185
|
+
variables here, which will be injected into
|
186
|
+
ansible-playbook through the '--extra-vars'
|
187
|
+
parameter.
|
125
188
|
|
126
189
|
Here is a group clause with a single book in it:
|
127
190
|
|
@@ -134,8 +197,8 @@
|
|
134
197
|
end
|
135
198
|
#+END_SRC
|
136
199
|
|
137
|
-
Which issues the following command to Ansible
|
138
|
-
earlier configuration):
|
200
|
+
Which issues the following command to Ansible
|
201
|
+
(based on the earlier configuration):
|
139
202
|
|
140
203
|
#+BEGIN_SRC bash
|
141
204
|
ansible-playbook playbooks/nat.yml \
|
@@ -227,6 +290,23 @@ Description:
|
|
227
290
|
Plays a PowerPlay script. The entries in the script, as specified inside of a group, are run in parallel by default.
|
228
291
|
#+END_SRC
|
229
292
|
|
293
|
+
There is a short-hand 'pp' command you may use
|
294
|
+
that has the 'play' task as the default. So, for
|
295
|
+
example, rather than having to type:
|
296
|
+
|
297
|
+
#+begin_src bash
|
298
|
+
powerplay play -p development ...
|
299
|
+
#+end_src
|
300
|
+
|
301
|
+
You can do instead:
|
302
|
+
|
303
|
+
#+begin_src bash
|
304
|
+
pp -p development ...
|
305
|
+
#+end_src
|
306
|
+
|
307
|
+
In all our examples, we will use the longer
|
308
|
+
'powerplay' command, but you can easily
|
309
|
+
substitute 'pp'.
|
230
310
|
|
231
311
|
*** Example .play Script
|
232
312
|
To play around with the example .play script,
|
@@ -243,10 +323,112 @@ Description:
|
|
243
323
|
scripts or submit them to me as Gist snippets
|
244
324
|
and I will include them if they are good.
|
245
325
|
|
326
|
+
** Concurrency
|
327
|
+
We offer a finely controllable concurency model in
|
328
|
+
the DSL with groups. The short of it is that a group
|
329
|
+
may be marked as :sync or :async. All contents of a
|
330
|
+
:sync group shall be executed serially. All
|
331
|
+
contents of an :async group shall be executed
|
332
|
+
concurrently.
|
333
|
+
|
334
|
+
As you can now nest groups, and that each group is
|
335
|
+
either synchronous or asynchronous, how these
|
336
|
+
interact requires a bit of understanding as to how
|
337
|
+
the sync and async job queing mechanism in PowerPlay
|
338
|
+
actually works.
|
339
|
+
|
340
|
+
*** The Gory Details behind how :sync and :async
|
341
|
+
Internally, we have two job queues, sync_jobs
|
342
|
+
and async_jobs. We also have -- at least
|
343
|
+
conceptually -- two run queues, sync_runs and
|
344
|
+
async_runs, to reflect queues of currenly
|
345
|
+
running jobs, or books. A "job" or a "book"
|
346
|
+
represent an actual Ansible Playbook being
|
347
|
+
run, or waiting to be run.
|
348
|
+
|
349
|
+
| enqueue | deque and run 'queues' |
|
350
|
+
|------------+------------------------|
|
351
|
+
| sync_jobs | sync_runs |
|
352
|
+
| async_jobs | async_runs |
|
353
|
+
|
354
|
+
As well, we have the following queuing
|
355
|
+
rules. Please note that "iff" is the
|
356
|
+
mathematical "iff", meaning "if and only if".
|
357
|
+
|
358
|
+
| rule | details | behavior |
|
359
|
+
|-----------------+-------------+------------------------------------------------------|
|
360
|
+
| enqueue | async job | iff sync_jobs is empty and all sync_runs completed |
|
361
|
+
| | sync job | iff async_jobs is empty and all async_runs completed |
|
362
|
+
| dequeue and run | async queue | grab everything and run it concurrently |
|
363
|
+
| | sync queue | grab one at a time and run it until it completes |
|
364
|
+
|
365
|
+
Note that "dequeue and run" flips back and
|
366
|
+
forth between working on the sync and async
|
367
|
+
queues. Never both simultaneously.
|
368
|
+
|
369
|
+
**** Nested Groups
|
370
|
+
You can appreicate that understanding the
|
371
|
+
behavior and "interaction" of nested queues
|
372
|
+
can get pretty hairy, but just keep in mind
|
373
|
+
the rules above, as your nesting will
|
374
|
+
rigorously adhere to the logic above, even
|
375
|
+
as it descends into the queues. The group
|
376
|
+
designation only directly affects its
|
377
|
+
immediate jobs, or books. It does not
|
378
|
+
directly affect the books in its nested
|
379
|
+
children.
|
380
|
+
|
381
|
+
To ensure that the groups are themselves
|
382
|
+
executed synchronously if the parent
|
383
|
+
group is synchronous, internally we insert
|
384
|
+
:noop book types to ensure the algorithm
|
385
|
+
behaves itself accordingly. Otherwise,
|
386
|
+
two consecutive async groups would appear
|
387
|
+
to come from one async group.
|
388
|
+
|
389
|
+
**** Implemention of the Execution Planning [authoritative]
|
390
|
+
In actuality, what we do at the DSL processing
|
391
|
+
level is decide whether or not a book is a sync
|
392
|
+
book or async book. We generate the actual command
|
393
|
+
line code at that point, and create a pair [:sync,
|
394
|
+
book] or [:async, book] and push that into the
|
395
|
+
planning queue, which is a FIFO queue.
|
396
|
+
|
397
|
+
(Note the the following is conceptual. In
|
398
|
+
actuality, the info is all inside the book
|
399
|
+
object.)
|
400
|
+
|
401
|
+
| book | enqueue to FIFO planning_queue |
|
402
|
+
|-------------+--------------------------------|
|
403
|
+
| sync group | [:sync, bash string] |
|
404
|
+
| async group | [:async, bash string] |
|
405
|
+
| naked | [:sync, bash string] |
|
406
|
+
|
407
|
+
We determine what execution planning a book gets
|
408
|
+
by its immediate grouping. A group's default is
|
409
|
+
:async. Naked books are :sync by default. We do
|
410
|
+
this to be intuitive about how things work in the
|
411
|
+
DSL. You should explicitely have to specify what's
|
412
|
+
going to be async, since that is the "more
|
413
|
+
dangerous" mode.
|
414
|
+
|
415
|
+
| dequeue from FIFO | action |
|
416
|
+
|-----------------------+---------------------------------------------------------------------------------------------------|
|
417
|
+
| [:sync, bash string] | join all entries in async_run_queue, clear that queue, and then execute and join bash string task |
|
418
|
+
| [:async, bash string] | execute and enqueue to async_run_queue |
|
419
|
+
| | |
|
420
|
+
|
421
|
+
This simplifies the algorithm and makes it easier
|
422
|
+
to understand, and should result in a more
|
423
|
+
intuitive grasp on how to write the PowerPlay.
|
424
|
+
|
425
|
+
**** TODO Scenarios
|
426
|
+
|
246
427
|
** Contributing to ansible-powerplay
|
247
|
-
Your parcipitation is welcome, and I will
|
248
|
-
pull requests in a timely
|
249
|
-
pulling an "Atlas"
|
428
|
+
Your parcipitation is welcome, and I will
|
429
|
+
respond to your pull requests in a timely
|
430
|
+
fashion as long as I am not pulling an "Atlas"
|
431
|
+
at my current job! lol
|
250
432
|
|
251
433
|
+ Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
252
434
|
+ Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
@@ -257,5 +439,41 @@ Description:
|
|
257
439
|
+ 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.
|
258
440
|
|
259
441
|
** Copyright
|
260
|
-
Copyright (c) 2016 Fred Mitchell. See
|
261
|
-
further details.
|
442
|
+
Copyright (c) 2016 Fred Mitchell. See
|
443
|
+
LICENSE.txt for further details.
|
444
|
+
|
445
|
+
** The Junkyard
|
446
|
+
This area should be ignored, just a place
|
447
|
+
for me to keep old snippets of code and other
|
448
|
+
notes that will be of relevance to no one else.
|
449
|
+
*** Old execution planning model
|
450
|
+
#+begin_src ruby
|
451
|
+
# old code and will be deleted
|
452
|
+
playbooks do |pname, playbook|
|
453
|
+
group_threads = []
|
454
|
+
puts "PLAYBOOK #{pname} (group=#{Play::clopts[:group]}) -->"
|
455
|
+
groups playbook do |group|
|
456
|
+
tg = nil
|
457
|
+
group_threads << (tg = Thread.new {
|
458
|
+
puts " GROUP #{group.type} (book=#{bucher}, cg=#{congroups}) -->"
|
459
|
+
book_threads = []
|
460
|
+
errors = []
|
461
|
+
group.books.each { |book| get_book_apcmd(book, bucher, book_threads, errors) }
|
462
|
+
book_threads.each{ |t| t.join }
|
463
|
+
unless errors.empty?
|
464
|
+
errors.each do |yaml, cmd, txt|
|
465
|
+
puts '=' * 30
|
466
|
+
puts ('*' * 10) + ' ' + yaml
|
467
|
+
puts txt
|
468
|
+
puts '-' * 30
|
469
|
+
puts cmd
|
470
|
+
end
|
471
|
+
exit 10
|
472
|
+
end
|
473
|
+
})
|
474
|
+
# Always wait here unless we're concurrent
|
475
|
+
group_threads.join unless congroups
|
476
|
+
end
|
477
|
+
group_threads.each{ |t| t.join }
|
478
|
+
end
|
479
|
+
#+end_src
|