chef-cookbooks / iptables

Development repository for Chef Cookbook iptables

Home Page:https://supermarket.chef.io/cookbooks/iptables

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ruby no in /opt/chef/embedded/bin/ruby when calling rebuild-iptables

jorgehv opened this issue · comments

Cookbook version

3.0.1

Chef-client version

12.16.42

Platform Details

Raspbian (Raspberry Pi)

Scenario:

In the raspberry pi, where I had to compile my own version of ruby to install chef-client 12, rebuild-iptables is failing because it cannot find ruby in the address of the generated shebang: #!/opt/chef/embedded/bin/ruby -w
Note that in my env ruby is in /usr/local/bin/ruby

I think it should be better not to have this hard dependency to /opt/chef/embedded/bin. I see you're planning to move rebuild-iptables to a library (this would fix the problem), but meanwhile I would call ruby /usr/sbin/rebuild-iptables instead of plain /usr/sbin/rebuild-iptables

Steps to Reproduce:

Just adding the default recipe to the run_list and other recipe with any iptables rule

Expected Result:

(After I linked /opt/chef/embedded/bin/ruby to /usr/local/bin/ruby I got:

Recipe: iptables::default
  * execute[rebuild-iptables] action run
    - execute /usr/sbin/rebuild-iptables

Running handlers:
Running handlers complete
Chef Client finished...

Actual Result:

Without the link:

Recipe: iptables::default
  * execute[rebuild-iptables] action run
    
    ================================================================================
    Error executing action `run` on resource 'execute[rebuild-iptables]'
    ================================================================================
    
    Errno::ENOENT
    -------------
    No such file or directory - /usr/sbin/rebuild-iptables
    
    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/iptables/recipes/default.rb
    
     24: execute 'rebuild-iptables' do
     25:   command '/usr/sbin/rebuild-iptables'
     26:   action :nothing
     27: end
     28: 
    
    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/iptables/recipes/default.rb:24:in `from_file'
    
    execute("rebuild-iptables") do
      action [:nothing]
      retries 0
      retry_delay 2
      default_guard_interpreter :execute
      command "/usr/sbin/rebuild-iptables"
      backup 5
      returns 0
      declared_type :execute
      cookbook_name "iptables"
      recipe_name "default"
    end
    
    Platform:
    ---------
    armv6l-linux-eabihf
...
# /usr/sbin/rebuild-iptables 
bash: /usr/sbin/rebuild-iptables: /opt/chef/embedded/bin/ruby: bad interpreter: No such file or directory

You can override this attribute if you want to point it to where your system ruby is located.
https://github.com/chef-cookbooks/iptables/blob/master/attributes/default.rb#L41

As Pete said you're going to need to override this. Chef is designed to work with the omnibus install so the out of the box experience is tuned for that.