Ask Your Question
0

Packages aren't installing on Ubuntu

asked 2016-11-11 10:48:15 -0500

Nizen gravatar image

Good morning, I am trying to manage packages with puppet, and it is working on my RHEL/CentOS, but not my Ubuntu servers, and I cannot figure out why. The code is as follows:

  case $operatingsytem {
    'Ubuntu': {
      Package { ensure => "installed" }
      $system_packages = [
              'nmap',
              'etc...',
              ]
      package { $system_packages:
    }
  }

I'm at a complete loss here. Thanks in advance for any assistance!

edit retag flag offensive close merge delete

Comments

There are no errors, it just simply is not installing the packages.

Nizen gravatar imageNizen ( 2016-11-11 11:02:07 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-11-11 11:16:39 -0500

DarylW gravatar image

updated 2016-11-11 11:16:50 -0500

You are using a case statement without a default option. So what is happening is if $operatingsystem == 'Ubuntu', then you are installing the packages, but other options have a 'no-op' because they don't match.

if you add a default evaluation, you'll see what I'm talking about..

  case $operatingsytem {
    'Ubuntu': {
      Package { ensure => "installed" }
      $system_packages = [
              'nmap',
              'etc...',
              ]
      package { $system_packages:
      }
      default => { fail("Operating system $operatingsystem not supported")}
    } #This was missing in your example
  }

If you run the above, you'll see that on the non-Ubuntu systems, it will fail because it enters the 'default' block (which previously was empty due to not declaring it)

edit flag offensive delete link more

Comments

But it is Ubuntu, and the packages are just not installing.

Nizen gravatar imageNizen ( 2016-11-11 11:17:50 -0500 )edit

Are they already installed, so it's not showing you, or are they not installed on the box at all? on the cli, run (puppet resource package ) and see what status it shows for your packages...

DarylW gravatar imageDarylW ( 2016-11-11 14:38:14 -0500 )edit

No, I can manually install the packages after puppet runs. I fixed it, but I'm still not sure what the problem is. I deleted the CentOS case statements, then ran puppet without them and it worked. Then I readded the CentOS case statement, and it still works. It's working now, so I'll take it.

Nizen gravatar imageNizen ( 2016-11-11 15:39:04 -0500 )edit

I wonder if you had a misplaced pair of { } somewhere, and that was causing your code to not behave as you would have expected. If you have an IDE that supports code reformatting and the prior non-working commit, try formatting the code.

DarylW gravatar imageDarylW ( 2016-11-14 09:21:02 -0500 )edit

I deleted 'RHEL', 'CentOS': { } and it worked fine. I readded the same snippet, and it still worked. I'm not really sure where the issue was, but I never got any errors saying I had an unexpected character. You could be right, it just didn't tell me anything. All is good now, though! Thanks!

Nizen gravatar imageNizen ( 2016-11-14 11:42:47 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-11-11 10:48:15 -0500

Seen: 39 times

Last updated: Nov 11 '16