chef 0.9.8 → 0.9.10.rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/README.rdoc +1 -1
  2. data/distro/common/man/man8/knife.8 +89 -79
  3. data/distro/common/markdown/knife.mkd +7 -0
  4. data/distro/debian/etc/default/chef-server +3 -0
  5. data/distro/debian/etc/default/chef-server-webui +3 -0
  6. data/distro/debian/etc/default/chef-solr +3 -0
  7. data/distro/debian/etc/default/chef-solr-indexer +3 -0
  8. data/distro/debian/etc/init.d/chef-server +3 -1
  9. data/distro/debian/etc/init.d/chef-server-webui +3 -1
  10. data/distro/redhat/etc/init.d/chef-client +1 -1
  11. data/lib/chef/application.rb +2 -0
  12. data/lib/chef/application/client.rb +5 -3
  13. data/lib/chef/application/knife.rb +16 -5
  14. data/lib/chef/application/solo.rb +0 -1
  15. data/lib/chef/checksum.rb +65 -1
  16. data/lib/chef/checksum_cache.rb +173 -0
  17. data/lib/chef/client.rb +84 -121
  18. data/lib/chef/cookbook/remote_file_vendor.rb +10 -3
  19. data/lib/chef/cookbook/syntax_check.rb +2 -2
  20. data/lib/chef/cookbook_loader.rb +2 -0
  21. data/lib/chef/cookbook_site_streaming_uploader.rb +29 -0
  22. data/lib/chef/cookbook_uploader.rb +8 -7
  23. data/lib/chef/cookbook_version.rb +155 -114
  24. data/lib/chef/exceptions.rb +5 -0
  25. data/lib/chef/handler.rb +43 -0
  26. data/lib/chef/index_queue/consumer.rb +1 -1
  27. data/lib/chef/index_queue/indexable.rb +1 -1
  28. data/lib/chef/knife.rb +18 -5
  29. data/lib/chef/knife/bootstrap.rb +2 -2
  30. data/lib/chef/knife/bootstrap/archlinux-gems.erb +44 -0
  31. data/lib/chef/knife/bootstrap/client-install.vbs +80 -0
  32. data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +2 -2
  33. data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +6 -7
  34. data/lib/chef/knife/bootstrap/windows-gems.erb +34 -0
  35. data/lib/chef/knife/configure_client.rb +4 -2
  36. data/lib/chef/knife/cookbook_metadata.rb +1 -1
  37. data/lib/chef/knife/cookbook_site_share.rb +2 -1
  38. data/lib/chef/knife/cookbook_site_vendor.rb +6 -0
  39. data/lib/chef/knife/cookbook_test.rb +1 -1
  40. data/lib/chef/knife/ec2_server_create.rb +51 -26
  41. data/lib/chef/knife/exec.rb +52 -0
  42. data/lib/chef/knife/ssh.rb +27 -15
  43. data/lib/chef/knife/status.rb +27 -10
  44. data/lib/chef/knife/windows_bootstrap.rb +154 -0
  45. data/lib/chef/mixin/checksum.rb +2 -2
  46. data/lib/chef/mixin/xml_escape.rb +75 -49
  47. data/lib/chef/node.rb +54 -58
  48. data/lib/chef/node/attribute.rb +61 -53
  49. data/lib/chef/platform.rb +19 -2
  50. data/lib/chef/provider/breakpoint.rb +1 -1
  51. data/lib/chef/provider/cookbook_file.rb +3 -3
  52. data/lib/chef/provider/cron.rb +3 -3
  53. data/lib/chef/provider/cron/solaris.rb +195 -0
  54. data/lib/chef/provider/deploy.rb +3 -3
  55. data/lib/chef/provider/directory.rb +2 -2
  56. data/lib/chef/provider/env.rb +5 -5
  57. data/lib/chef/provider/execute.rb +1 -1
  58. data/lib/chef/provider/file.rb +10 -9
  59. data/lib/chef/provider/git.rb +12 -4
  60. data/lib/chef/provider/group.rb +5 -5
  61. data/lib/chef/provider/http_request.rb +25 -9
  62. data/lib/chef/provider/ifconfig.rb +2 -2
  63. data/lib/chef/provider/link.rb +11 -6
  64. data/lib/chef/provider/log.rb +1 -0
  65. data/lib/chef/provider/mdadm.rb +3 -3
  66. data/lib/chef/provider/mount.rb +5 -5
  67. data/lib/chef/provider/mount/mount.rb +1 -1
  68. data/lib/chef/provider/ohai.rb +41 -0
  69. data/lib/chef/provider/package.rb +5 -5
  70. data/lib/chef/provider/package/yum-dump.py +5 -2
  71. data/lib/chef/provider/remote_directory.rb +11 -5
  72. data/lib/chef/provider/remote_file.rb +2 -2
  73. data/lib/chef/provider/route.rb +154 -133
  74. data/lib/chef/provider/ruby_block.rb +1 -1
  75. data/lib/chef/provider/service.rb +6 -6
  76. data/lib/chef/provider/subversion.rb +12 -9
  77. data/lib/chef/provider/template.rb +2 -2
  78. data/lib/chef/provider/user.rb +7 -7
  79. data/lib/chef/provider/user/useradd.rb +15 -1
  80. data/lib/chef/providers.rb +2 -0
  81. data/lib/chef/resource.rb +164 -58
  82. data/lib/chef/resource/http_request.rb +9 -0
  83. data/lib/chef/resource/ohai.rb +40 -0
  84. data/lib/chef/resource/remote_directory.rb +10 -1
  85. data/lib/chef/resource/rpm_package.rb +34 -0
  86. data/lib/chef/resource_collection.rb +3 -2
  87. data/lib/chef/resources.rb +2 -0
  88. data/lib/chef/rest.rb +13 -7
  89. data/lib/chef/rest/auth_credentials.rb +1 -1
  90. data/lib/chef/rest/rest_request.rb +3 -1
  91. data/lib/chef/runner.rb +31 -55
  92. data/lib/chef/shef/shef_session.rb +1 -1
  93. data/lib/chef/util/windows/net_use.rb +1 -1
  94. data/lib/chef/version.rb +1 -1
  95. data/lib/chef/webui_user.rb +0 -1
  96. metadata +38 -19
  97. data/lib/chef/cache.rb +0 -61
  98. data/lib/chef/cache/checksum.rb +0 -91
@@ -113,7 +113,7 @@ class Chef
113
113
  if @current_resource.mounted and @new_resource.supports[:remount]
114
114
  shell_out!("mount -o remount #{@new_resource.mount_point}")
115
115
 
116
- @new_resource.updated = true
116
+ @new_resource.updated_by_last_action(true)
117
117
  Chef::Log.info("Remounted #{@new_resource.mount_point}")
118
118
  elsif @current_resource.mounted
119
119
  umount_fs
@@ -0,0 +1,41 @@
1
+ #
2
+ # Author:: Michael Leianrtas (<mleinartas@gmail.com>)
3
+ # Copyright:: Copyright (c) 2010 Michael Leinartas
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'ohai'
20
+
21
+ class Chef
22
+ class Provider
23
+ class Ohai < Chef::Provider
24
+
25
+ def load_current_resource
26
+ true
27
+ end
28
+
29
+ def action_reload
30
+ ohai = ::Ohai::System.new
31
+ if @new_resource.plugin
32
+ ohai.require_plugin @new_resource.plugin
33
+ else
34
+ ohai.all_plugins
35
+ end
36
+
37
+ node.automatic_attrs.merge! ohai.data
38
+ end
39
+ end
40
+ end
41
+ end
@@ -59,7 +59,7 @@ class Chef
59
59
 
60
60
  status = install_package(@new_resource.package_name, install_version)
61
61
  if status
62
- @new_resource.updated = true
62
+ @new_resource.updated_by_last_action(true)
63
63
  end
64
64
  end
65
65
 
@@ -69,7 +69,7 @@ class Chef
69
69
  Chef::Log.info("Upgrading #{@new_resource} version from #{orig_version} to #{candidate_version}")
70
70
  status = upgrade_package(@new_resource.package_name, candidate_version)
71
71
  if status
72
- @new_resource.updated = true
72
+ @new_resource.updated_by_last_action(true)
73
73
  end
74
74
  end
75
75
  end
@@ -78,7 +78,7 @@ class Chef
78
78
  if removing_package?
79
79
  Chef::Log.info("Removing #{@new_resource}")
80
80
  remove_package(@current_resource.package_name, @new_resource.version)
81
- @new_resource.updated = true
81
+ @new_resource.updated_by_last_action(true)
82
82
  else
83
83
  end
84
84
  end
@@ -99,7 +99,7 @@ class Chef
99
99
  if removing_package?
100
100
  Chef::Log.info("Purging #{@new_resource}")
101
101
  purge_package(@current_resource.package_name, @new_resource.version)
102
- @new_resource.updated = true
102
+ @new_resource.updated_by_last_action(true)
103
103
  end
104
104
  end
105
105
 
@@ -128,7 +128,7 @@ class Chef
128
128
  Chef::Log.debug("Fetching preseed file to #{resource.path}")
129
129
  resource.run_action('create')
130
130
 
131
- if resource.updated?
131
+ if resource.updated_by_last_action?
132
132
  resource.path
133
133
  else
134
134
  false
@@ -60,8 +60,11 @@ try:
60
60
  # Yum assumes it can update the cache directory. Disable this for non root
61
61
  # users.
62
62
  y.conf.cache = os.geteuid() != 0
63
-
64
- # Spin up to lock_timeout.
63
+
64
+ # Override any setting in yum.conf - we only care about the newest
65
+ y.conf.showdupesfromrepos = False
66
+
67
+ # Spin up to lock_timeout.
65
68
  countdown = lock_timeout
66
69
  while True:
67
70
  try:
@@ -50,7 +50,9 @@ class Chef
50
50
  end
51
51
 
52
52
  def action_create_if_missing
53
- raise Chef::Exceptions::UnsupportedAction, "Remote Directories do not support create_if_missing."
53
+ # if this action is called, ignore the existing overwrite flag
54
+ @new_resource.overwrite = false
55
+ action_create
54
56
  end
55
57
 
56
58
  protected
@@ -95,8 +97,12 @@ class Chef
95
97
  ensure_directory_exists(::File.dirname(full_path))
96
98
 
97
99
  file_to_fetch = cookbook_file_resource(full_path, cookbook_file_relative_path)
98
- file_to_fetch.run_action(:create)
99
- @new_resource.updated = true if file_to_fetch.updated?
100
+ if @new_resource.overwrite
101
+ file_to_fetch.run_action(:create)
102
+ else
103
+ file_to_fetch.run_action(:create_if_missing)
104
+ end
105
+ @new_resource.updated_by_last_action(true) if file_to_fetch.updated?
100
106
  end
101
107
 
102
108
  def cookbook_file_resource(target_path, relative_source_path)
@@ -115,7 +121,7 @@ class Chef
115
121
  unless ::File.directory?(path)
116
122
  directory_to_create = resource_for_directory(path)
117
123
  directory_to_create.run_action(:create)
118
- @new_resource.updated = true if directory_to_create.updated?
124
+ @new_resource.updated_by_last_action(true) if directory_to_create.updated?
119
125
  end
120
126
  end
121
127
 
@@ -131,4 +137,4 @@ class Chef
131
137
 
132
138
  end
133
139
  end
134
- end
140
+ end
@@ -47,13 +47,13 @@ class Chef
47
47
  backup_new_resource
48
48
  Chef::Log.debug "copying remote file from origin #{raw_file.path} to destination #{@new_resource.path}"
49
49
  FileUtils.cp raw_file.path, @new_resource.path
50
- @new_resource.updated = true
50
+ @new_resource.updated_by_last_action(true)
51
51
  end
52
52
  end
53
53
  end
54
54
  enforce_ownership_and_permissions
55
55
 
56
- @new_resource.updated
56
+ @new_resource.updated_by_last_action(true)
57
57
  end
58
58
 
59
59
  def action_create_if_missing
@@ -6,9 +6,9 @@
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
- #
9
+ #
10
10
  # http://www.apache.org/licenses/LICENSE-2.0
11
- #
11
+ #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
14
14
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,150 +25,171 @@ class Chef::Provider::Route < Chef::Provider
25
25
  include Chef::Mixin::Command
26
26
 
27
27
  attr_accessor :is_running
28
-
29
- MASK = {
30
- '0.0.0.0' => '0',
31
- '128.0.0.0' => '1',
32
- '192.0.0.0' => '2',
33
- '224.0.0.0' => '3',
34
- '240.0.0.0' => '4',
35
- '248.0.0.0' => '5',
36
- '252.0.0.0' => '6',
37
- '254.0.0.0' => '7',
38
- '255.0.0.0' => '8',
39
- '255.128.0.0' => '9',
40
- '255.192.0.0' => '10',
41
- '255.224.0.0' => '11',
42
- '255.240.0.0' => '12',
43
- '255.248.0.0' => '13',
44
- '255.252.0.0' => '14',
45
- '255.254.0.0' => '15',
46
- '255.255.0.0' => '16',
47
- '255.255.128.0' => '17',
48
- '255.255.192.0' => '18',
49
- '255.255.224.0' => '19',
50
- '255.255.240.0' => '20',
51
- '255.255.248.0' => '21',
52
- '255.255.252.0' => '22',
53
- '255.255.254.0' => '23',
54
- '255.255.255.0' => '24',
55
- '255.255.255.128' => '25',
56
- '255.255.255.192' => '26',
57
- '255.255.255.224' => '27',
58
- '255.255.255.240' => '28',
59
- '255.255.255.248' => '29',
60
- '255.255.255.252' => '30',
61
- '255.255.255.254' => '31',
62
- '255.255.255.255' => '32'
63
- }
28
+
29
+ MASK = {'0.0.0.0' => '0',
30
+ '128.0.0.0' => '1',
31
+ '192.0.0.0' => '2',
32
+ '224.0.0.0' => '3',
33
+ '240.0.0.0' => '4',
34
+ '248.0.0.0' => '5',
35
+ '252.0.0.0' => '6',
36
+ '254.0.0.0' => '7',
37
+ '255.0.0.0' => '8',
38
+ '255.128.0.0' => '9',
39
+ '255.192.0.0' => '10',
40
+ '255.224.0.0' => '11',
41
+ '255.240.0.0' => '12',
42
+ '255.248.0.0' => '13',
43
+ '255.252.0.0' => '14',
44
+ '255.254.0.0' => '15',
45
+ '255.255.0.0' => '16',
46
+ '255.255.128.0' => '17',
47
+ '255.255.192.0' => '18',
48
+ '255.255.224.0' => '19',
49
+ '255.255.240.0' => '20',
50
+ '255.255.248.0' => '21',
51
+ '255.255.252.0' => '22',
52
+ '255.255.254.0' => '23',
53
+ '255.255.255.0' => '24',
54
+ '255.255.255.128' => '25',
55
+ '255.255.255.192' => '26',
56
+ '255.255.255.224' => '27',
57
+ '255.255.255.240' => '28',
58
+ '255.255.255.248' => '29',
59
+ '255.255.255.252' => '30',
60
+ '255.255.255.254' => '31',
61
+ '255.255.255.255' => '32' }
64
62
 
65
63
  def load_current_resource
66
- is_running = nil
67
-
68
- Chef::Log.debug("Configuring Route #{@new_resource.name}")
69
-
70
- # cidr or quad dot mask
71
- if @new_resource.netmask
72
- new_ip = IPAddr.new("#{@new_resource.target}/#{@new_resource.netmask}")
73
- else
74
- new_ip = IPAddr.new(@new_resource.target)
75
- end
76
-
77
- # pull routes from proc
78
- if node[:os] == "linux"
79
- route_file = ::File.open("/proc/net/route", "r")
80
- while (line = route_file.gets)
81
- # proc layout
82
- iface,destination,gateway,flags,refcnt,use,metric,mask,mtu,window,irtt = line.split
83
-
84
- # need to convert packed adresses int quad dot
85
- # the addrs are reversed hex packed decimal addrs. so this unwraps them. tho you could
86
- # do this without ipaddr using unpack. ipaddr has no htoa method.
87
- #
88
- destination = IPAddr.new(destination.scan(/../).reverse.to_s.hex, Socket::AF_INET).to_s
89
- gateway = IPAddr.new(gateway.scan(/../).reverse.to_s.hex, Socket::AF_INET).to_s
90
- mask = IPAddr.new(mask.scan(/../).reverse.to_s.hex, Socket::AF_INET).to_s
91
- Chef::Log.debug( "System has route: dest=#{destination} mask=#{mask} gw=#{gateway}")
92
-
93
- # check if what were trying to configure is already there
94
- # use an ipaddr object with ip/mask this way we can have
95
- # a new resource be in cidr format (i don't feel like
96
- # expanding bitmask by hand.
97
- #
98
- running_ip = IPAddr.new("#{destination}/#{mask}")
99
- Chef::Log.debug( "new ip: #{new_ip.inspect} running ip: #{running_ip.inspect} ")
100
- is_running = true if running_ip == new_ip
101
- end
102
- route_file.close
64
+ is_running = nil
65
+
66
+ Chef::Log.debug("Configuring Route #{@new_resource.name}")
67
+
68
+ # cidr or quad dot mask
69
+ if @new_resource.netmask
70
+ new_ip = IPAddr.new("#{@new_resource.target}/#{@new_resource.netmask}")
71
+ else
72
+ new_ip = IPAddr.new(@new_resource.target)
73
+ end
74
+
75
+ # pull routes from proc
76
+ if node[:os] == "linux"
77
+ route_file = ::File.open("/proc/net/route", "r")
78
+ while (line = route_file.gets)
79
+ # proc layout
80
+ iface,destination,gateway,flags,refcnt,use,metric,mask,mtu,window,irtt = line.split
81
+
82
+ # need to convert packed adresses int quad dot
83
+ # the addrs are reversed hex packed decimal addrs. so this unwraps them. tho you could
84
+ # do this without ipaddr using unpack. ipaddr has no htoa method.
85
+ #
86
+ destination = IPAddr.new(destination.scan(/../).reverse.to_s.hex, Socket::AF_INET).to_s
87
+ gateway = IPAddr.new(gateway.scan(/../).reverse.to_s.hex, Socket::AF_INET).to_s
88
+ mask = IPAddr.new(mask.scan(/../).reverse.to_s.hex, Socket::AF_INET).to_s
89
+ Chef::Log.debug( "System has route: dest=#{destination} mask=#{mask} gw=#{gateway}")
90
+
91
+ # check if what were trying to configure is already there
92
+ # use an ipaddr object with ip/mask this way we can have
93
+ # a new resource be in cidr format (i don't feel like
94
+ # expanding bitmask by hand.
95
+ #
96
+ running_ip = IPAddr.new("#{destination}/#{mask}")
97
+ Chef::Log.debug( "new ip: #{new_ip.inspect} running ip: #{running_ip.inspect} ")
98
+ is_running = true if running_ip == new_ip
103
99
  end
100
+ route_file.close
101
+ end
104
102
  end
105
103
 
106
104
  def action_add
107
- # check to see if load_current_resource found the route
108
- if is_running
109
- Chef::Log.debug("Route #{@new_resource.name} already active ")
110
- else
111
- command = "ip route replace #{@new_resource.target}"
112
- command << "/#{MASK[@new_resource.netmask.to_s]}" if @new_resource.netmask
113
- command << " via #{@new_resource.gateway} "
114
- command << " dev #{@new_resource.device} " if @new_resource.device
115
-
116
- Chef::Log.info("Adding route: #{command} ")
117
- run_command( :command => command )
118
- @new_resource.updated = true
119
- end
120
-
121
- #for now we always write the file (ugly but its what it is)
122
- generate_config
105
+ # check to see if load_current_resource found the route
106
+ if is_running
107
+ Chef::Log.debug("Route #{@new_resource.name} already active ")
108
+ else
109
+ command = generate_command(:add)
110
+
111
+ Chef::Log.info("Adding route: #{command} ")
112
+ run_command( :command => command )
113
+ @new_resource.updated_by_last_action(true)
114
+ end
123
115
 
116
+ #for now we always write the file (ugly but its what it is)
117
+ generate_config
124
118
  end
125
119
 
126
120
  def action_delete
127
- if is_running
128
- command = "ip route delete #{@new_resource.target}"
129
- command << "/#{MASK[@new_resource.netmask.to_s]}" if @new_resource.netmask
130
- command << " via #{@new_resource.gateway} "
131
-
132
- Chef::Log.info("Removing route: #{command}")
133
- run_command( :command => command )
134
- @new_resource.updated = true
135
- else
136
- Chef::Log.debug("Route #{@new_resource.name} does not exist")
137
- end
121
+ if is_running
122
+ command = generate_command(:delete)
123
+
124
+ Chef::Log.info("Removing route: #{command}")
125
+ run_command( :command => command )
126
+ @new_resource.updated_by_last_action(true)
127
+ else
128
+ Chef::Log.debug("Route #{@new_resource.name} does not exist")
129
+ end
138
130
  end
139
131
 
140
132
  def generate_config
141
- conf = Hash.new
142
- case node[:platform]
143
- when ("centos" || "redhat" || "fedora")
144
- # walk the collection
145
- @collection.each do |resource|
146
- if resource.is_a? Chef::Resource::Route
147
- # default to eth0
148
- if resource.device
149
- dev = resource.device
150
- else
151
- dev = "eth0"
152
- end
153
-
154
- conf[dev] = String.new if conf[dev].nil?
155
- if resource.action == :add
156
- conf[dev] << "#{resource.target}"
157
- conf[dev] << "/#{resource.netmask}" if resource.netmask
158
- conf[dev] << " via #{resource.gateway}\n"
159
- else
160
- # need to do this for the case when the last route on an int
161
- # is removed
162
- conf[dev] = ""
163
- end
164
- end
133
+ conf = Hash.new
134
+ case node[:platform]
135
+ when ("centos" || "redhat" || "fedora")
136
+ # walk the collection
137
+ run_context.resource_collection.each do |resource|
138
+ if resource.is_a? Chef::Resource::Route
139
+ # default to eth0
140
+ if resource.device
141
+ dev = resource.device
142
+ else
143
+ dev = "eth0"
144
+ end
145
+
146
+ conf[dev] = String.new if conf[dev].nil?
147
+ if resource.action == :add
148
+ conf[dev] = config_file_contents(:add, :target => resource.target, :netmask => resource.netmask, :gateway => resource.gateway)
149
+ else
150
+ # need to do this for the case when the last route on an int
151
+ # is removed
152
+ conf[dev] = config_file_contents(:delete)
165
153
  end
166
- conf.each do |k, v|
167
- network_file = ::File.new("/etc/sysconfig/network-scripts/route-#{k}", "w")
168
- network_file.puts(conf[k])
169
- Chef::Log.debug("writing route.#{k}\n#{conf[k]}")
170
- network_file.close
171
- end
154
+ end
172
155
  end
173
- end
156
+ conf.each do |k, v|
157
+ network_file = ::File.new("/etc/sysconfig/network-scripts/route-#{k}", "w")
158
+ network_file.puts(conf[k])
159
+ Chef::Log.debug("writing route.#{k}\n#{conf[k]}")
160
+ network_file.close
161
+ end
162
+ end
163
+ end
164
+
165
+ def generate_command(action)
166
+ common_route_items = ''
167
+ common_route_items << "/#{MASK[@new_resource.netmask.to_s]}" if @new_resource.netmask
168
+ common_route_items << " via #{@new_resource.gateway} " if @new_resource.gateway
169
+
170
+ case action
171
+ when :add
172
+ command = "ip route replace #{@new_resource.target}"
173
+ command << common_route_items
174
+ command << " dev #{@new_resource.device} " if @new_resource.device
175
+ when :delete
176
+ command = "ip route delete #{@new_resource.target}"
177
+ command << common_route_items
178
+ end
179
+
180
+ return command
181
+ end
182
+
183
+ def config_file_contents(action, options={})
184
+ content = ''
185
+ case action
186
+ when :add
187
+ content << "#{options[:target]}"
188
+ content << "/#{options[:netmask]}" if options[:netmask]
189
+ content << " via #{options[:gateway]}" if options[:gateway]
190
+ content << "\n"
191
+ end
192
+
193
+ return content
194
+ end
174
195
  end