abiquo-chef-agent 2.0.10 → 2.0.11

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: d5b4e63ac7b335b7e41addf06ca461b159c95d16
4
- data.tar.gz: 5e50daf80b113985c4d8cc053688a3d173e43f71
3
+ metadata.gz: fd798c59832708256e7e44281b18d8dd1651ebe6
4
+ data.tar.gz: b3c7d71208b35cde739215e7889f3f61d06f57c0
5
5
  SHA512:
6
- metadata.gz: 56628feb8938783520400aa7b9a2e8e0fb984aded2f318ad129293bcd3444e1b1588b1614391147448b826259dd8264e5e721d1d19a41cf93c79115b8bbbbeff
7
- data.tar.gz: bf6971dc4de33aa0d66d413360803322e7799143f3461a9ad4eff02c3fb4c4ea56f9a36610402ad7195d0c1bea739e9729879d8bc70bffc7af03faf2e795c36b
6
+ metadata.gz: f1d0a8216934f8a02febbe5ebc6dbe799c75c9454e0f2378eab3e890ffd604b3f728d9fb5b451007162a1644a86bff6d432a530b4f542556337e739a19ee9dd6
7
+ data.tar.gz: 2d1f18cacef4dfb0322bb985528c8c1fe23795ff4d5f951cf0ba35a1a87af16a05ebad92ff4efa47bb4a7c8e43c7d36223955454fc82668a6b11230b4e945b0b
data/Rakefile CHANGED
@@ -18,6 +18,16 @@ require './lib/abiquo-chef-agent.rb'
18
18
  require 'rdoc/task'
19
19
  require 'rspec/core/rake_task'
20
20
 
21
+ desc "Build gem"
22
+ task :build do
23
+ system "gem build abiquo-chef-agent.gemspec"
24
+ end
25
+
26
+ desc "Release to rubygems"
27
+ task :release => :build do
28
+ system "gem push abiquo-chef-agent-#{Abiquo::Chef::VERSION}"
29
+ end
30
+
21
31
  RSpec::Core::RakeTask.new(:spec)
22
32
 
23
33
  Rake::RDocTask.new do |rdoc|
@@ -1,6 +1,6 @@
1
1
  lib = File.expand_path('../lib', __FILE__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'abiquo-chef-agent.rb'
3
+ require 'version.rb'
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.version = Abiquo::Chef::VERSION
@@ -78,7 +78,7 @@ end
78
78
  log "Parsing leases file"
79
79
  leases = Util.parse_leases_file
80
80
  if not leases
81
- log "Leases file not found or invalid. Current leases search path ['/var/lib/dhcp3', '/var/lib/dhcp', '/var/lib/dhclient'].", :error
81
+ log "Leases file not found or invalid. Current leases search path ['/var/lib/dhcp3', '/var/lib/dhcp', '/var/lib/dhclient', '/var/lib/NetworkManager'].", :error
82
82
  exit 1
83
83
  else
84
84
  log "Leases found #{leases.inspect}"
@@ -14,7 +14,7 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- AGENT_GEM_VERSION=2.0.10
17
+ AGENT_GEM_VERSION=2.0.11
18
18
 
19
19
  if [[ ${UID} -ne 0 ]]; then
20
20
  echo "${0} must be run as root"
@@ -28,7 +28,7 @@ echo "Installing Chef..."
28
28
  curl -L https://www.opscode.com/chef/install.sh | bash
29
29
 
30
30
  echo "Installing the Abiquo Chef Agent gem..."
31
- /opt/chef/embedded/bin/gem install abiquo-chef-agent -v ${AGENT_CHEF_VERSION}
31
+ /opt/chef/embedded/bin/gem install abiquo-chef-agent -v ${AGENT_GEM_VERSION}
32
32
 
33
33
  ln -s /opt/chef/embedded/bin/abiquo-chef-run /usr/bin
34
34
  cat > /etc/init.d/abiquo-chef-run << 'EOF'
@@ -0,0 +1,66 @@
1
+ #!/bin/bash
2
+
3
+ # Copyright (C) 2008 Abiquo Holdings S.L.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ AGENT_GEM_VERSION=2.0.11
18
+
19
+ if [[ ${UID} -ne 0 ]]; then
20
+ echo "${0} must be run as root"
21
+ exit 1
22
+ fi
23
+
24
+ echo "Preparing the system..."
25
+ yum --assumeyes install ntp gcc-c++ libstdc++-devel
26
+
27
+ echo "Installing Chef..."
28
+ curl -L https://www.opscode.com/chef/install.sh | bash
29
+
30
+ echo "Installing the Abiquo Chef Agent gem..."
31
+ /opt/chef/embedded/bin/gem install abiquo-chef-agent -v ${AGENT_GEM_VERSION}
32
+
33
+ ln -s /opt/chef/embedded/bin/abiquo-chef-run /usr/bin
34
+ cat > /lib/systemd/system/abiquo-chef-agent.service << 'EOF'
35
+ [Unit]
36
+ Description=Abiquo Chef Agent
37
+ After=network.target
38
+
39
+ [Service]
40
+ ExecStart=/usr/bin/abiquo-chef-run
41
+
42
+ [Install]
43
+ WantedBy=multi-user.target
44
+ EOF
45
+
46
+ systemctl enable abiquo-chef-agent
47
+
48
+ echo "Configuring DHCP..."
49
+ read -r -d '' DHCP << 'EOF'
50
+ option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
51
+
52
+ send host-name "<hostname>";
53
+ request subnet-mask, broadcast-address, time-offset, routers,
54
+ domain-name, domain-name-servers, domain-search, host-name,
55
+ netbios-name-servers, netbios-scope, interface-mtu,
56
+ rfc3442-classless-static-routes, ntp-servers, vendor-encapsulated-options;
57
+ EOF
58
+
59
+ echo "${DHCP}" >/etc/dhcp/dhclient.conf
60
+
61
+ IFACES=`ip link show | grep ^[0-9]: | grep -iv loopback | cut -d: -f2 | tr -d ' '`
62
+ for IFACE in ${IFACES}; do
63
+ echo "${DHCP}" >/etc/dhcp/dhclient-${IFACE}.conf
64
+ done
65
+
66
+ echo "Done!"
@@ -14,7 +14,7 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- AGENT_GEM_VERSION=2.0.10
17
+ AGENT_GEM_VERSION=2.0.11
18
18
 
19
19
  if [[ `id -u` -ne 0 ]]; then
20
20
  echo "${0} must be run with sudo"
@@ -14,7 +14,7 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- AGENT_GEM_VERSION=2.0.10
17
+ AGENT_GEM_VERSION=2.0.11
18
18
 
19
19
  if [[ `id -u` -ne 0 ]]; then
20
20
  echo "${0} must be run with sudo"
@@ -18,9 +18,6 @@ require 'time'
18
18
 
19
19
  module Abiquo
20
20
  module Chef
21
-
22
- VERSION = '2.0.10'
23
-
24
21
  class Config
25
22
  def self.chef_config_dir
26
23
  '/etc/chef'
@@ -109,11 +106,11 @@ module Abiquo
109
106
  #
110
107
  # Tries to find the right leases file
111
108
  #
112
- def self.find_leases_file(search_dirs = ['/var/lib/dhcp3', '/var/lib/dhcp', '/var/lib/dhclient'])
109
+ def self.find_leases_file(search_dirs = ['/var/lib/dhcp3', '/var/lib/dhcp', '/var/lib/dhclient', '/var/lib/NetworkManager'])
113
110
  leases = []
114
111
  search_dirs.each do |d|
115
112
  Dir["#{d}/*"].each do |f|
116
- next if f !~ /leases$/
113
+ next if f !~ /lease(s)?$/
117
114
  leases << f
118
115
  end
119
116
  end
@@ -132,7 +129,7 @@ module Abiquo
132
129
  # :abiquo_api_token => token
133
130
  # }
134
131
  #
135
- def self.parse_leases_file(search_dirs = ['/var/lib/dhcp3', '/var/lib/dhcp', '/var/lib/dhclient'])
132
+ def self.parse_leases_file(search_dirs = ['/var/lib/dhcp3', '/var/lib/dhcp', '/var/lib/dhclient', '/var/lib/NetworkManager'])
136
133
  files = find_leases_file(search_dirs)
137
134
  leases = []
138
135
  files.each do |file|
@@ -0,0 +1,5 @@
1
+ module Abiquo
2
+ module Chef
3
+ VERSION = '2.0.11'
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ lease {
2
+ interface "ens3";
3
+ fixed-address 10.60.13.10;
4
+ option subnet-mask 255.255.255.0;
5
+ option routers 10.60.13.1;
6
+ option dhcp-lease-time 60000;
7
+ option dhcp-message-type 5;
8
+ option domain-name-servers 10.60.13.1,8.8.8.8;
9
+ option dhcp-server-identifier 10.60.20.30;
10
+ option broadcast-address 10.60.13.255;
11
+ option vendor-encapsulated-options "http://10.60.20.30:8009/api/cloud/virtualdatacenters/46/virtualappliances/4717/virtualmachines/11851/config/bootstrap@@6Z9u+gUh95DDwTmQbbYKZA==";
12
+ option domain-name "bcn.abiquo.com.";
13
+ renew 1 2015/11/30 17:28:04;
14
+ rebind 2 2015/12/01 00:22:59;
15
+ expire 2 2015/12/01 02:27:59;
16
+ }
@@ -27,7 +27,7 @@ describe Util do
27
27
  end
28
28
 
29
29
  it 'should return latest lease' do
30
- expect(@leases[:renew]).to eql(Time.parse('2012-11-18 05:48:45 +0100'))
30
+ expect(@leases[:renew]).to eql(Time.parse('2015/11/30 17:28:04 +0100'))
31
31
  end
32
32
 
33
33
  it 'should have a valid token' do
@@ -38,7 +38,7 @@ describe Util do
38
38
 
39
39
  describe 'find_leases_file' do
40
40
  it 'should find a lease file' do
41
- expect(Util.find_leases_file([data_dir + "dhclient/"])).to have(1).item
41
+ expect(Util.find_leases_file([data_dir + "dhclient/"])).to have(2).item
42
42
  end
43
43
 
44
44
  it 'should return an empty list' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abiquo-chef-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.10
4
+ version: 2.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salvador Girones
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-11-27 00:00:00.000000000 Z
14
+ date: 2015-11-30 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
@@ -111,10 +111,12 @@ files:
111
111
  - Rakefile
112
112
  - abiquo-chef-agent.gemspec
113
113
  - bin/abiquo-chef-run
114
- - install/install-centos.sh
114
+ - install/install-centos-6.sh
115
+ - install/install-centos-7.sh
115
116
  - install/install-ubuntu-systemd.sh
116
117
  - install/install-ubuntu-upstart.sh
117
118
  - lib/abiquo-chef-agent.rb
119
+ - lib/version.rb
118
120
  - spec/data/bootstrap.xml
119
121
  - spec/data/bootstrap_empty_cert.xml
120
122
  - spec/data/bootstrap_empty_chef.xml
@@ -129,6 +131,7 @@ files:
129
131
  - spec/data/bootstrap_missing_server_url.xml
130
132
  - spec/data/bootstrap_missing_validation.xml
131
133
  - spec/data/bootstrap_no_attributes.xml
134
+ - spec/data/dhclient/dhclient-130c4fe6-30b8-4540-8563-a14e03b683c1-ens3.lease
132
135
  - spec/data/dhclient/dhclient.leases
133
136
  - spec/data/invalid_bootstrap.xml
134
137
  - spec/spec_helper.rb
@@ -174,6 +177,7 @@ test_files:
174
177
  - spec/data/bootstrap_missing_server_url.xml
175
178
  - spec/data/bootstrap_missing_validation.xml
176
179
  - spec/data/bootstrap_no_attributes.xml
180
+ - spec/data/dhclient/dhclient-130c4fe6-30b8-4540-8563-a14e03b683c1-ens3.lease
177
181
  - spec/data/dhclient/dhclient.leases
178
182
  - spec/data/invalid_bootstrap.xml
179
183
  - spec/spec_helper.rb