Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to use other releases in debian #383

Closed
wants to merge 3 commits into from

Conversation

ajardan
Copy link

@ajardan ajardan commented Sep 14, 2015

This will allow people to use testing release on Debian 7 where Apache HTTPD 2.4 is available.

There are still a lot of servers on Wheezy, and some of them are not that easy to upgrade.

Considering the fact that it is still used, and doesn't have an EOL date yet, we should give an opportunity to those who need this.

Andrian Jardan added 3 commits September 14, 2015 18:07
This will allow people to use testing release on Debian 7 where Apache HTTPD 2.4 is available.
@ajardan
Copy link
Author

ajardan commented Sep 18, 2015

Anyone available to review this and merge please ?

@drpebcak
Copy link
Contributor

You can use default_release in the regular package resource. Why change anything other than adding this line? default_release node['apache']['default_release'] unless node['apache']['default_release'].empty?

@ajardan
Copy link
Author

ajardan commented Sep 18, 2015

When I was testing it, the "package" resource was complaining about it.

I'll check again, maybe I missed something.
On Sep 18, 2015 9:01 PM, "Taylor Price" notifications@github.com wrote:

You can use default_release in the regular package resource. Why change
anything other than adding this line? default_release
node['apache']['default_release'] unless
node['apache']['default_release'].empty?


Reply to this email directly or view it on GitHub
#383 (comment)
.

@drpebcak
Copy link
Contributor

The documentation indicates it should work, so I'd like it if we could figure that out for simplicity's sake.
https://docs.chef.io/resource_package.html

@ajardan
Copy link
Author

ajardan commented Sep 19, 2015

@drpebcak Well, even the description of this attribute says:

https://docs.chef.io/resource_package.html#properties

apt_package resource only. The default release. For example: stable

And I am pretty sure I was getting an error, as that was the first thing I tried to do without luck.

@ajardan
Copy link
Author

ajardan commented Sep 23, 2015

@drpebcak ping ?

@drpebcak
Copy link
Contributor

@ajardan try cc9c492

I didn't receive an error during my light testing. Let me know if you see a problem with this, and please paste the error in the comments here if you get one.

@ajardan
Copy link
Author

ajardan commented Sep 28, 2015

@drpebcak here you go:

-------------
undefined method `default_release' for Chef::Resource::Package

Cookbook Trace:
---------------
  /srv/chef/berks-cookbooks/apache2/recipes/default.rb:22:in `block in from_file'
  /srv/chef/berks-cookbooks/apache2/recipes/default.rb:21:in `from_file'
  /srv/chef/berks-cookbooks/fs-apache2/recipes/default.rb:11:in `from_file'
  /srv/chef/berks-cookbooks/fs-rest-auth/recipes/default.rb:9:in `from_file'
  /srv/chef/berks-cookbooks/fs/recipes/default.rb:15:in `from_file'

Relevant File Content:
----------------------
/srv/chef/berks-cookbooks/apache2/recipes/default.rb:

 15:  # distributed under the License is distributed on an "AS IS" BASIS,
 16:  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 17:  # See the License for the specific language governing permissions and
 18:  # limitations under the License.
 19:  #
 20:  
 21:    package 'apache2' do
 22>>     default_release node['apache']['default_release'] unless node['apache']['default_release'].empty?
 23:      package_name node['apache']['package']
 24:    end
 25:  
 26:  %w(sites-available sites-enabled mods-available mods-enabled conf-available conf-enabled).each do |dir|
 27:    directory "#{node['apache']['dir']}/#{dir}" do
 28:      mode '0755'
 29:      owner 'root'
 30:      group node['apache']['root_group']
 31:    end

@drpebcak
Copy link
Contributor

Try it with my fork? I ran through in test-kitchen and it didn't fail...

@ajardan
Copy link
Author

ajardan commented Sep 28, 2015

@drpebcak Your fork still does the same thing, I don't see any difference. It doesn't matter is it nil, or empty, the package resource still doesn't support "default_release" attribute, which is only supported in apt_package resource even according to the official documentation:

https://www.dropbox.com/s/p8fj86mf93p5lam/Screenshot%202015-09-28%2020.02.15.png?dl=0

Take a look here as well:

https://github.com/chef/chef/blob/master/lib/chef/resource/apt_package.rb

I guess your tests passed because you never set ['apache']['default_release'] to be something other than nil, so the attribute was not applied to the resource because of the if.

@drpebcak
Copy link
Contributor

On Ubuntu at least, the compiled version of the package resource is apt_package
Like this:

Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cookbooks/apache2/recipes/default.rb

            21: package 'apache2' do
            22:   package_name node['apache']['package']
            23:   default_release unless node['apache']['default_release'].nil?

            25:

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cookbooks/apache2/recipes/default.rb:21:in `from_file'

           apt_package("apache2") do
             action :install
             retries 0
             retry_delay 2
             default_guard_interpreter :default
             package_name "apache2"
         version "2.4.16-3"
             timeout 900
             declared_type :package
             cookbook_name :apache2
             recipe_name "default"
           end

version 2.4.16-3 is not from stable, but that is the version chef is installing for me.

What version of Chef are you using @ajardan?

@ajardan
Copy link
Author

ajardan commented Sep 28, 2015

@drpebcak I am using Chef 11.18.12

@drpebcak
Copy link
Contributor

Ah, I get the same error with that old version of chef-client. I'm guessing there was a bug with that version of chef.

https://docs.chef.io/release/11-18/resource_package.html#syntax

Syntax indicates its for apt packages only, but its shown as used with the package resource directly, not just with apt_package.

@ajardan
Copy link
Author

ajardan commented Sep 29, 2015

Well, the comment still says:

default_release String # Apt packages only

I'll try with a newer Chef 11 and see how it goes.
On Sep 29, 2015 12:59 AM, "Taylor Price" notifications@github.com wrote:

Ah, I get the same error with that old version of chef-client. I'm
guessing there was a bug with that version of chef.

https://docs.chef.io/release/11-18/resource_package.html#syntax

Syntax indicates its for apt packages only, but its shown as used with the
package resource directly, not just with apt_package.


Reply to this email directly or view it on GitHub
#383 (comment)
.

@drpebcak
Copy link
Contributor

Right, apt packages only, but it doesn't say 'hey, this only works with the apt_package resource'.

Our test-kitchen suites run with chef 12, so your mileage may vary with chef 11.

@ajardan
Copy link
Author

ajardan commented Sep 29, 2015

@drpebcak you are right, it works fine with Chef 12.4.3 (in terms of the error I mentioned), but there's a problem in your branch. You have
default_release unless node['apache']['default_release'].nil?

And it should be
default_release node['apache']['default_release'] unless node['apache']['default_release'].nil?

Want me to do another pull request, or you will fix your branch and merge ?

@drpebcak
Copy link
Contributor

Ah, that is important. I'll add that to my fork and then merge it.

@ajardan
Copy link
Author

ajardan commented Sep 29, 2015

@drpebcak thanks!

@svanzoest
Copy link
Contributor

Foodcritic now gives me the following:

FC009: Resource attribute not recognised: ./recipes/default.rb:21

@lock
Copy link

lock bot commented Jul 24, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants