Installing Apache on Ubuntu 16.04 using chef


#1

Anyone able to install Apache on Ubuntu 16.04 using chef workstation?
I am stuck with the error: [

No version specified, and no candidate version available for Apache.


#2

Hi, Klauss! Folks will need more information about what you tried to be able to help. What command did you run to try to perform the install? What version of Chef Workstation? Can you share more of the log output?


#3

Absolutely! I have Chef workstation 14.7.17. I was just following the training on the link below:
https://learn.chef.io/modules/learn-the-basics/ubuntu/bring-your-own-system/configure-a-package-and-service#/infrastructure-automation

and got stuck.

I used: #> chef-client --local-mode web-apache.rb where web-apache.rb looks as shown below:

apt_update 'update the apt cache daily' do
frequency 86_400
action: periodic
end
package 'apache2'

Thank you


#4

HI Klauss-

I've verified that this works on an out of the box 16.04 install locally.

root@ubuntu:/tmp# chef-client --local-mode ./test.rb
[2018-12-20T16:07:53-06:00] WARN: No config file found or specified on command line, using command line options.
[2018-12-20T16:07:53-06:00] WARN: No cookbooks directory found at or above current directory.  Assuming /tmp.
Starting Chef Client, version 14.7.17
resolving cookbooks for run list: []
Synchronizing Cookbooks:
Installing Cookbook Gems:
Compiling Cookbooks...
[2018-12-20T16:07:55-06:00] WARN: Node ubuntu has an empty run list.
Converging 2 resources
Recipe: @recipe_files::/tmp/test.rb
  * apt_update[Update the apt cache daily] action periodic (up to date)
  * apt_package[apache2] action install
    - install version 2.4.18-2ubuntu3.9 of package apache2

Running handlers:
Running handlers complete
Chef Client finished, 1/2 resources updated in 09 seconds

That "no candidate version available for Apache" error message would lead me to believe that there is something wrong with the apt repositories on this system, or that they don't exist at all. What is the source of the OS image you are running on? (The official repositories should be there on a default install.) Can you verify that there are repositories configured (look in /etc/apt/sources.list and /etc/apt/sources.list.d/*.list) and that you can reach them?

If that looks good, see if you can install apache2 directly with apt:

sudo apt install apache2

Are there any proxies or anything in play that would prevent the downloading of this package from an apt repo?


#5

Thanks Brad, for your quick reply. Trying your suggestions now. Will post later.


#6

Found nothing in the /etc/apt/sources.list.d - the file /etc/apt/sources.list exists and has a few repos.

And, trying the command listed above to install Apache gives error:
dpkg was interrupted, you must manually run dpkg --configure -a to correct the problem.

What d you think of this? Thx


#7

I ran the dpkg --config.... command and i am now able to install Apache. Thank you so much for your help. Much appreciated.


#8

Awesome. Yep, it certainly sounded repo related. Glad you were able to work through it! Happy holidays!


#9

Happy holidays, Brad!

Thank you, again.