-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwomm
executable file
·178 lines (109 loc) · 3.79 KB
/
womm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/usr/bin/perl
require 5.14.0;
use strict; # http://perldoc.perl.org/strict.html
use Carp; # http://perldoc.perl.org/Carp.html
use Cwd; # http://perldoc.perl.org/Cwd.html
use Getopt::Long; # http://perldoc.perl.org/Getopt/Long.html
use Pod::Usage; # http://perldoc.perl.org/Pod/Usage.html
use File::chdir;
use File::Basename;
our %self = (
name => 'womm',
desc => 'Works On My Machine',
web => 'https://github.com/lakruzz/MacAsCode',
issues => 'https://github.com/lakruzz/MacAsCode/issues',
zip => 'https://github.com/lakruzz/MacAsCode/archive/master.zip',
home => '~/GitHub/Lakruzz/MacAsCode',
);
($self{filename},$self{path},$self{suffix}) = fileparse(Cwd::abs_path($0));
use lib "$self{path}..";
use modules::cmd;
our %params = (
update => 0,
install => 1,
playbook => './macascode.yml',
manuscript => '',
gist => '',
verbose => 0,
keep => 0,
cache => './gist'
);
undef $params{manuscript};
undef $params{gist};
GetOptions(
(
"update!" => \$params{update},
"install!" => \$params{install},
"playbook=s" => \$params{playbook},
"manuscript=s" => \$params{manuscript},
"gist=s" => \$params{gist},
"verbose!" => \$params{verbose},
"keep!" => \$params{keep},
"cache" => \$params{cache},
"help" => sub { pod2usage(-exitval => 0, -verbose => 2) }
)
) || pod2usage(-exitval => 1, -verbose => 0);
# Required parameters
(defined($params{manuscript}) ) || pod2usage(-exitval => 1, -verbose => 0);
our $cmd = cmd->new();
$params{update} && do{
$cmd->exec(command => "git pull",
verbose => $params{verbose})
};
$cmd->exec(
command => "ansible-playbook $params{playbook} --extra-vars 'manuscript=$params{manuscript}'",
system => 1,
verbose => $params{verbose}
);
=pod
=head1 NAME
womm - Works On My Machine
Installs anything that Ansible supports - Using simple manuscripts.
=head1 SYNOPSIS
B< C<< womm --manuscript yaml-file [--[no-]update] [--[no-]install] [--playbook yaml-file] [--gist gist-id] [--[no-]verbose] [--[no-]keep] [--cache dir] >> >
B< C<< womm --help >> >
B<Example>
womm --manuscript marcommachine.yml
Will run the default playbook using the marcommachine.yml manuscript
=head1 OPTIONS
The following switches exists and can all be overridden.
=over 8
=item B< C<< --manuscript yaml-file >> >
Where C<yaml-file> is the name of the manuscript to run.
This is a required parameter.
=item B< C<< --[no-]update >> >
Determins wether or not to update (C<git pull>) the repo before execution.
Default is C<--no-update>
=item B< C<< --[no-]install >> >
Will install womm and the dependencies on your machine - if they are not
already installed.
Default is C<--install>
=item B< C<< --playbook playbook >> >
Use this setting to run a different ansible playbook than the default.
The playbook will habe to be in the same folder as the (C<womm>) script
Default is C<./macascode.yml>
=item B< C<< --gist gist_id >> >
Run the manuscript in the specified gist
=item B< C<< --[no-]verbose >> >
Will run in verbose mode.
Default is C<--no-verbose>
=item B< C<< --[no-]keep >> >
Determins wether or not to keep files pulled from gist locally after
the execution or not.
Default is C<--no-keep>
=item B< C<< --cache dir >> >
Specifies the dir to use for pulling files from gists.
Default is C<./gist>
=item B< C<< --help >> >
Prints the manual page.
=back
=head1 DESCRIPTION
B<Copyright>
L<Lars Kruse, 2017|http://github.com/lakruzz>
B<License>
L<GPLv3|https://www.gnu.org/licenses/gpl-3.0.en.html>
B<Repository>
L<lakruzz/MacAsCode|http://github.com/lakruzz/MacAsCode>
B<Support>
L<Use the issue system|http://github.com/lakruzz/MacAsCode/issues> in the repo.
=cut