knife-clc-chef-server 0.1.0 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +0 -8
- data/lib/chef/knife/{client_run.rb → provision.rb} +23 -8
- data/lib/clc_chef_server.rb +28 -11
- data/lib/clc_chef_server/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4e86c5562cbe1bdfd540be428333864df3b5a2e
|
4
|
+
data.tar.gz: 6b4ce1e3a07ad2a9c0cb1b294d26aab73f37ae1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6972cc8d5a608ab0fb7d01efca456975cda0f273901f142dccf663a41c426e5958d32f9c3729e5dd646417ef181f48ad9602437394565d724cb96f480e2e25d
|
7
|
+
data.tar.gz: 0649cdd39f962c8034a84c5646972016661d48c0f7194d83b26bca928b546af6c19ead52315816a6a7e0f29bad4ea1d88ab525d782463d60b1ce47f451ff6f6d
|
data/Rakefile
CHANGED
@@ -1,10 +1,2 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
|
3
|
-
module Bundler
|
4
|
-
class GemHelper
|
5
|
-
def rubygem_push(path)
|
6
|
-
gems = Dir.glob(File.join(File.dirname(__FILE__), 'pkg', 'knife-clc-chef-server-*.gem'))
|
7
|
-
system("gem push '#{gems[0]}' --host http://172.22.10.137:8081/artifactory/api/gems/localgems -k clc_api_key")
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
@@ -2,9 +2,9 @@ require 'chef/knife'
|
|
2
2
|
require 'clc_chef_server'
|
3
3
|
|
4
4
|
module KnifeClcServer
|
5
|
-
class
|
5
|
+
class Provision < Chef::Knife
|
6
6
|
|
7
|
-
banner "knife
|
7
|
+
banner "knife provision CLUSTERS -E ENVIRONMENT"
|
8
8
|
|
9
9
|
option :node,
|
10
10
|
:short => "-n NODE",
|
@@ -12,11 +12,6 @@ module KnifeClcServer
|
|
12
12
|
:description => "chef node to run (QA3T3NPROVISIONER01 is the default)",
|
13
13
|
:default => "QA3T3NPROVISIONER01"
|
14
14
|
|
15
|
-
option :clusters,
|
16
|
-
:short => "-C CLUSTERS",
|
17
|
-
:long => "--clusters CLUSTERS",
|
18
|
-
:description => "comma delimited list of clusters to provision (Defaults to all clusters)"
|
19
|
-
|
20
15
|
option :ssh_user,
|
21
16
|
:short => "-x SSH_USER",
|
22
17
|
:long => "--ssh_user SSH_USER",
|
@@ -29,8 +24,19 @@ module KnifeClcServer
|
|
29
24
|
:description => "ssh password used to login to node - defaults to 'Password123'",
|
30
25
|
:default => "Password123"
|
31
26
|
|
27
|
+
option :no_converge,
|
28
|
+
:long => "--no_converge",
|
29
|
+
:description => "do not converge the node. Just create it.",
|
30
|
+
:default => false
|
31
|
+
|
32
32
|
def run
|
33
33
|
if @name_args.length < 1
|
34
|
+
show_usage
|
35
|
+
ui.error("You must specify one or more clusters to provision")
|
36
|
+
exit 1
|
37
|
+
end
|
38
|
+
|
39
|
+
if config[:environment].nil?
|
34
40
|
show_usage
|
35
41
|
ui.error("You must specify an environment to target")
|
36
42
|
exit 1
|
@@ -39,7 +45,16 @@ module KnifeClcServer
|
|
39
45
|
server_path = URI(Chef::Config[:chef_server_url]).path
|
40
46
|
org = server_path[server_path.rindex('/')+1..-1]
|
41
47
|
|
42
|
-
ClcChefServer.client_run(
|
48
|
+
ClcChefServer.client_run(
|
49
|
+
org,
|
50
|
+
config[:node],
|
51
|
+
@name_args[0],
|
52
|
+
config[:environment],
|
53
|
+
config[:ssh_user],
|
54
|
+
config[:ssh_password],
|
55
|
+
config[:no_converge] ? false : true,
|
56
|
+
ui
|
57
|
+
)
|
43
58
|
end
|
44
59
|
end
|
45
60
|
end
|
data/lib/clc_chef_server.rb
CHANGED
@@ -4,12 +4,12 @@ require "clc_chef_server/version"
|
|
4
4
|
|
5
5
|
module ClcChefServer
|
6
6
|
class << self
|
7
|
-
TMP_DIR = '/tmp/clc_chef_server
|
7
|
+
TMP_DIR = '/tmp/clc_chef_server'
|
8
8
|
|
9
9
|
def create_sandbox(organization, ui = nil)
|
10
10
|
repo = Chef::Config.find_chef_repo_path(Dir.pwd)
|
11
11
|
chef_server = URI(Chef::Config[:chef_server_url]).host
|
12
|
-
Chef::Config[:cookbook_path] = TMP_DIR
|
12
|
+
Chef::Config[:cookbook_path] = File.join(TMP_DIR, "cookbooks")
|
13
13
|
|
14
14
|
%w[clc_library chef_server chef-vault chef-client cron logrotate newrelic].each do |cb|
|
15
15
|
download_cookbook(cb, ui)
|
@@ -30,26 +30,43 @@ module ClcChefServer
|
|
30
30
|
shell(command)
|
31
31
|
end
|
32
32
|
|
33
|
-
def client_run(organization, node, clusters, environment, ssh_user, ssh_password)
|
33
|
+
def client_run(organization, node, clusters, environment, ssh_user, ssh_password, converge, ui)
|
34
|
+
require 'chef/knife/ssh'
|
34
35
|
repo = Chef::Config.find_chef_repo_path(Dir.pwd)
|
35
|
-
|
36
|
-
|
37
|
-
out = `knife search 'name:#{node}' -c #{knife_path} -a metal.location.ipaddress`
|
36
|
+
ui.info "Searching chef server for node #{node}..."
|
37
|
+
out = `knife search 'name:#{node}' -a metal.location.ipaddress -c #{Chef::Config[:config_file]}`
|
38
38
|
ip=out[/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/]
|
39
|
+
|
40
|
+
if ip
|
41
|
+
ui.info ip
|
42
|
+
else
|
43
|
+
ui.error "Unable to find an ip."
|
44
|
+
end
|
45
|
+
|
39
46
|
if system("ssh-keygen -F #{ip} -f ~/.ssh/known_hosts > /dev/null")
|
40
47
|
system("ssh-keygen -f ~/.ssh/known_hosts -R #{ip} > /dev/null")
|
41
48
|
end
|
42
49
|
|
43
50
|
command = <<-EOS
|
44
|
-
|
51
|
+
echo "{
|
45
52
|
\\"provisioner\\": {
|
46
|
-
|
53
|
+
\\"clusters\\": \\"#{clusters}\\",
|
54
|
+
\\"converge\\": #{converge}
|
47
55
|
}
|
48
|
-
}
|
56
|
+
}" | chef-client -E #{environment} \\
|
49
57
|
-l info \\
|
50
|
-
-j /dev/stdin
|
58
|
+
-j /dev/stdin
|
51
59
|
EOS
|
52
|
-
|
60
|
+
|
61
|
+
Chef::Knife::Ssh.load_deps
|
62
|
+
knife = Chef::Knife::Ssh.new
|
63
|
+
knife.config[:attribute] = 'ipaddress'
|
64
|
+
knife.config[:ssh_user] = ssh_user
|
65
|
+
knife.config[:ssh_password_ng] = ssh_password
|
66
|
+
knife.config[:config_file] = Chef::Config[:config_file]
|
67
|
+
knife.name_args = ["name:#{node}", command]
|
68
|
+
|
69
|
+
knife.run
|
53
70
|
end
|
54
71
|
|
55
72
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-clc-chef-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CenturyLink Cloud
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -51,7 +51,7 @@ files:
|
|
51
51
|
- README.md
|
52
52
|
- Rakefile
|
53
53
|
- knife-clc-chef-server.gemspec
|
54
|
-
- lib/chef/knife/
|
54
|
+
- lib/chef/knife/provision.rb
|
55
55
|
- lib/chef/knife/server_sandbox.rb
|
56
56
|
- lib/clc_chef_server.rb
|
57
57
|
- lib/clc_chef_server/version.rb
|