You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i had an issue with priority.
When i use two update actions without specifying the priority in attributes, chef always update my entries.
hostsfile_entry '192.168.1.2' do
hostname 'server01.weeta.lab'
aliases ['server01', 'server01.test.lab']
comment 'Update by Chef'
action :update
end
hostsfile_entry '192.168.1.3' do
hostname 'server02.weeta.lab'
aliases ['server02', 'server02.test.lab']
comment 'Update by Chef'
action :update
end
After some investigations, i found when priority is not defined in attributes, options[:priority] is nil. Calculated priority of an ipv4 ip (60) is replaced by 0 due to -e.priority.to_i in manipulator unique_entries method. So the updated entry is always moved to the end.
When you only have one entry in your recipe, it's OK but when you have 2 or more entries without static priority, the first one is moved to the end then the second one is moved to the end. It happens each time the chef client is executed.
I resolved my issue by modifying the code like this:
--- entry.rb.orig 2017-08-23 02:34:23.000000000 +0200
+++ entry.rb 2017-11-27 18:51:18.854049200 +0100
@@ -127,8 +127,12 @@
# @param [Integer] new_priority
# the new priority to set
def priority=(new_priority)
- @calculated_priority = false
- @priority = new_priority
+ if new_priority.nil?
+ @priority = calculated_priority
+ else
+ @calculated_priority = false
+ @priority = new_priority
+ end
end
# The line representation of this entry.
Rgds
Stéphane Olivier
The text was updated successfully, but these errors were encountered:
WeetA34
changed the title
update entry without priority in options result to priority 0
update entry without priority set in attributes results to priority 0
Nov 27, 2017
Hello
i had an issue with priority.
When i use two update actions without specifying the priority in attributes, chef always update my entries.
After some investigations, i found when priority is not defined in attributes, options[:priority] is nil. Calculated priority of an ipv4 ip (60) is replaced by 0 due to -e.priority.to_i in manipulator unique_entries method. So the updated entry is always moved to the end.
When you only have one entry in your recipe, it's OK but when you have 2 or more entries without static priority, the first one is moved to the end then the second one is moved to the end. It happens each time the chef client is executed.
I resolved my issue by modifying the code like this:
Rgds
Stéphane Olivier
The text was updated successfully, but these errors were encountered: