unidad 0.0.1.beta2 → 0.0.1.beta3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a8d6bb8bfb697da6937982cf1b572c55dd23b13
4
- data.tar.gz: 74cf84eea25316cb288b6fc68168f7927f08410d
3
+ metadata.gz: 08d1f8141269514c7d44d53b5d768e48849a210d
4
+ data.tar.gz: 52d48d7e06b198cc661c510f732c000922c3ef38
5
5
  SHA512:
6
- metadata.gz: 32f1404897c68c1a15e1c0f0c97091786d584be707f4be3cd1dc13d1e7f9f3579633bde1706608b493937b6c9dfdb96531aa9e5091c2eff0662b4e6336dbcbdb
7
- data.tar.gz: cb4819b82900e6dadfe5e175bf1c5f5eda68bbaeab8c2c7cabefda933db208b42796869f93fee3f5fd882616da7f6f221603a8fea44ed4dfd9c5dbd848fbff72
6
+ metadata.gz: 35b482f34d7b6fa81e28124a256d6552c098692a1097eb55d38f38640cf2a0ad4ad5f4f4b03fd2b93e8050a5e56ff9247f54ecbbffab85e330100da61d75c0dd
7
+ data.tar.gz: faf792535c4603546078ac6841d720635c353f98714c50d296c55ae391d7f563e301d6e56e52c521a1b8438c55d5cc44f88ce0dba753b6f8833583a7a329847d
data/.rubocop.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  AllCops:
2
2
  RunRailsCops: false
3
3
  Exclude:
4
+ - lib/util/match_method_macros.rb
4
5
  - spec/test_app/**
5
6
  - bin/**
6
7
 
data/config/unidad.yml CHANGED
@@ -21,3 +21,6 @@ unidad:
21
21
  failure: "*[ERROR]* *%{username}* failed to complete running playbook `%{playbook}` from `%{branch}` of `%{repository}`"
22
22
  options:
23
23
  <<: *default_options
24
+ galaxy:
25
+ commands:
26
+ - "ansible-galaxy install -r %{requirements_file}"
@@ -0,0 +1,17 @@
1
+ module Unidad
2
+ module Cli
3
+ module Ansible
4
+ class Base < Unidad::Cli::NamespacedGroup
5
+ class_option :ansible_path, :default => 'ansible',
6
+ :type => :string,
7
+ :desc => 'The relative path to your ansible playbooks. (optional)'
8
+
9
+ private
10
+
11
+ def ansible_path
12
+ Unidad.root.join(options[:ansible_path])
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Unidad
2
+ module Cli
3
+ module Ansible
4
+ class Galaxy < Unidad::Cli::Ansible::Base
5
+ argument :requirements_file, :desc => 'The YAML file containing requirements to install',
6
+ :type => :string,
7
+ :required => true
8
+
9
+ def run_galaxy
10
+ Unidad::CommandBuilder.all(:galaxy, :requirements_file => ansible_path.join(requirements_file)).each do |command|
11
+ say_status :run, command
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,9 +1,7 @@
1
1
  module Unidad
2
2
  module Cli
3
3
  module Ansible
4
- class Playbook < Thor::Group
5
- include Thor::Actions
6
-
4
+ class Playbook < Unidad::Cli::Ansible::Base
7
5
  argument :hosts_file, :desc => 'The hosts file to use when running the playbook',
8
6
  :type => :string,
9
7
  :required => true
@@ -11,24 +9,18 @@ module Unidad
11
9
  :type => :string,
12
10
  :required => true
13
11
 
14
- class_option :ansible_path, :default => 'ansible',
15
- :type => :string,
16
- :desc => 'The path to your ansible playbooks. (optional, defaults to ./ansible)',
17
- :banner => '--ansible_path my_playbooks'
18
-
19
12
  class_option :vault_password, :type => :string,
20
- :desc => 'The Ansible vault password required to run your playbook. (optional)',
21
- :banner => '--vault_password S3CR3T!!!'
13
+ :desc => 'The Ansible vault password required to run your playbook. (optional)'
14
+
22
15
  def before
23
16
  messenger.on(:before)
24
17
  end
25
18
 
26
19
  def ask_for_vault_password
27
- unless password_file_exists?
28
- vault_password = options.fetch(:vault_password, ask('What is your Ansible vault password?', :echo => false))
29
- puts
30
- create_file password_file_path, vault_password
31
- end
20
+ return if password_file_exists?
21
+ vault_password = options.fetch(:vault_password, ask('What is your Ansible vault password?', :echo => false))
22
+ puts
23
+ create_file password_file_path, vault_password
32
24
  end
33
25
 
34
26
  def run_playbook
@@ -57,11 +49,7 @@ module Unidad
57
49
  end
58
50
 
59
51
  def password_file_exists?
60
- File.exists?(password_file_path)
61
- end
62
-
63
- def ansible_path
64
- Unidad.root.join(options[:ansible_path])
52
+ File.exist?(password_file_path)
65
53
  end
66
54
 
67
55
  def command_options
@@ -0,0 +1,13 @@
1
+ module Unidad
2
+ module Cli
3
+ class NamespacedGroup < Thor::Group
4
+ include Thor::Actions
5
+
6
+ # The banner for this class. You can customize it if you are invoking the
7
+ # thor class by another ways which is not the Thor::Runner.
8
+ def self.banner
9
+ "#{basename} #{name.split('::').last.downcase} #{arguments.collect(&:usage).compact.join(' ')}"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -4,14 +4,18 @@ require 'thor/group'
4
4
 
5
5
  Dotenv.load
6
6
 
7
+ require 'unidad/cli/namespaced_group'
7
8
  require 'unidad/cli/deploy'
9
+ require 'unidad/cli/ansible/base'
8
10
  require 'unidad/cli/ansible/playbook'
11
+ require 'unidad/cli/ansible/galaxy'
9
12
 
10
13
  module Unidad
11
14
  module Cli
12
15
  class Root < Thor
13
16
  register Unidad::Cli::Deploy, 'deploy', 'deploy [ENVIRONMENT]', 'Deploy your application to the specified environment.'
14
17
  register Unidad::Cli::Ansible::Playbook, 'playbook', 'playbook [HOSTS_FILE] [PLAYBOOK]', 'Run an Ansible playbook.'
18
+ register Unidad::Cli::Ansible::Galaxy, 'galaxy', 'galaxy [REQUIREMENTS_FILE]', 'Install Ansible dependencies via Galaxy.'
15
19
  end
16
20
  end
17
21
  end
@@ -10,7 +10,7 @@ module Unidad
10
10
 
11
11
  match_method(/\A(.*)=/) do |name, *args|
12
12
  option = name.to_s.gsub('=', '').to_sym
13
- self.options[option] = args[0]
13
+ options[option] = args[0]
14
14
  end
15
15
 
16
16
  def initialize(command)
@@ -1,3 +1,3 @@
1
1
  module Unidad
2
- VERSION = '0.0.1.beta2'
2
+ VERSION = '0.0.1.beta3'
3
3
  end
@@ -1,3 +1,5 @@
1
+ # Credit: Avdi Grimm
2
+ # https://gist.github.com/avdi/1440084
1
3
  module MatchMethodMacros
2
4
  def match_method(matcher, &method_body)
3
5
  mod = Module.new do
@@ -18,4 +20,4 @@ module MatchMethodMacros
18
20
  end
19
21
  include mod
20
22
  end
21
- end
23
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.beta2
4
+ version: 0.0.1.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - PJ Kelly
@@ -215,8 +215,11 @@ files:
215
215
  - config/unidad.yml
216
216
  - lib/unidad.rb
217
217
  - lib/unidad/cli.rb
218
+ - lib/unidad/cli/ansible/base.rb
219
+ - lib/unidad/cli/ansible/galaxy.rb
218
220
  - lib/unidad/cli/ansible/playbook.rb
219
221
  - lib/unidad/cli/deploy.rb
222
+ - lib/unidad/cli/namespaced_group.rb
220
223
  - lib/unidad/cli/root.rb
221
224
  - lib/unidad/command_builder.rb
222
225
  - lib/unidad/messenger.rb