Giter VIP home page Giter VIP logo

voxpupuli / puppet-alternatives Goto Github PK

View Code? Open in Web Editor NEW
25.0 48.0 36.0 293 KB

Manage Debian alternatives links

Home Page: https://forge.puppet.com/puppet/alternatives

License: Apache License 2.0

Ruby 100.00%
linux-puppet-module puppet hacktoberfest ubuntu-puppet-module centos-puppet-module debian-puppet-module oraclelinux-puppet-module redhat-puppet-module scientific-puppet-module sles-puppet-module

puppet-alternatives's Introduction

puppet-alternatives

Build Status Code Coverage Puppet Forge Puppet Forge - downloads Puppet Forge - endorsement Puppet Forge - scores

Manage alternatives symlinks.

Synopsis

Using puppet resource to inspect alternatives

root@master:~# puppet resource alternatives
alternatives { 'aptitude':
  path => '/usr/bin/aptitude-curses',
}
alternatives { 'awk':
  path => '/usr/bin/mawk',
}
alternatives { 'builtins.7.gz':
  path => '/usr/share/man/man7/bash-builtins.7.gz',
}
alternatives { 'c++':
  path => '/usr/bin/g++',
}
alternatives { 'c89':
  path => '/usr/bin/c89-gcc',
}
alternatives { 'c99':
  path => '/usr/bin/c99-gcc',
}
alternatives { 'cc':
  path => '/usr/bin/gcc',
}

Using puppet resource to update an alternative

root@master:~# puppet resource alternatives editor
alternatives { 'editor':
  path => '/bin/nano',
}
root@master:~# puppet resource alternatives editor path=/usr/bin/vim.tiny
notice: /Alternatives[editor]/path: path changed '/bin/nano' to '/usr/bin/vim.tiny'
alternatives { 'editor':
  path => '/usr/bin/vim.tiny',
}

Using the alternatives resource in a manifest:

class ruby_193 {

  package { 'ruby1.9.3':
    ensure => present,
  }

  # Will also update gem, irb, rdoc, rake, etc.
  alternatives { 'ruby':
    path    => '/usr/bin/ruby1.9.3',
    require => Package['ruby1.9.3'],
  }
}

include ruby_193

Creating a new alternative entry:

alternative_entry { '/usr/bin/gcc-4.4':
  ensure   => present,
  altlink  => '/usr/bin/gcc',
  altname  => 'gcc',
  priority => 10,
  require  => Package['gcc-4.4-multilib'],
}

On RedHat, configuring an alternative using a family instead of a full path:

alternatives { 'java':
  path    => 'java-1.8.0-openjdk.x86_64',
  require => Package['java-1.8.0-openjdk'],
}

This module should work on any Debian and RHEL based distribution.

Contact

puppet-alternatives's People

Contributors

adrienthebo avatar alexjfisher avatar bastelfreak avatar dhollinger avatar dhoppe avatar diranged avatar ekohl avatar flipez avatar fraenki avatar hunner avatar igalic avatar jhoblitt avatar jsosic avatar juniorsysadmin avatar jyaworski avatar maxadamo avatar mmoll avatar nibalizer avatar pseiler avatar root-expert avatar rswarts avatar sandra-thieme avatar smortex avatar stkerr avatar tragiccode avatar trevor-vaughan avatar treydock avatar vfoucault avatar vinzent avatar zilchms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

puppet-alternatives's Issues

Could not evaluate: undefined method `[]' for nil:NilClass

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: AIO 6 & 7
  • Distribution: Almalinux 9
  • Module version: 4.2.0

How to reproduce (e.g Puppet code you use)

        package { 'python3': }
        -> alternatives { 'python':
          path => '/usr/bin/python3',
        }

What are you seeing

The above code snippet works fine on EL8 under beaker but is producing an error on EL9.

Info: Applying configuration version '1675111504'
Debug: /Stage[main]/Main/Package[python3]/before: before to Alternatives[python]
Debug: Prefetching dnf resources for package
Debug: Executing: '/usr/bin/rpm --version'
Debug: Executing '/usr/bin/rpm -qa --nosignature --nodigest --qf '%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n' | sort'
Debug: Facter: resolving fact with user_query: osfamily
Debug: Facter: Searching fact: osfamily in file: osfamily.rb
Debug: Facter: Searching fact: osfamily in core facts and external facts
Debug: Facter: Loading all internal facts
Debug: Facter: List of resolvable facts: [#<Facter::SearchedFact:0x000000000428ce50 @name="osfamily", @fact_class=Facts::Rhel::Os::Family, @user_query="osfamily", @type=:legacy, @file=nil>]
Debug: Facter: Loading external facts
Debug: Facter: fact "osfamily" has resolved to: RedHat
Debug: Facter: resolving fact with user_query: osfamily
Debug: Facter: Searching fact: osfamily in file: osfamily.rb
Debug: Facter: Searching fact: osfamily in core facts and external facts
Debug: Facter: Loading all internal facts
Debug: Facter: List of resolvable facts: [#<Facter::SearchedFact:0x000000000421fe40 @name="osfamily", @fact_class=Facts::Rhel::Os::Family, @user_query="osfamily", @type=:legacy, @file=nil>]
Debug: Facter: Loading external facts
Debug: Facter: fact "osfamily" has resolved to: RedHat
Debug: Executing: '/usr/sbin/alternatives --display libnssckbi.so.x86_64'
Debug: Executing: '/usr/sbin/alternatives --display soelim'
Error: /Stage[main]/Main/Alternatives[python]: Could not evaluate: undefined method `[]' for nil:NilClass
/etc/puppetlabs/code/environments/production/modules/alternatives/lib/puppet/provider/alternatives/chkconfig.rb:53:in `path'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/property.rb:468:in `retrieve'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:1112:in `block in retrieve'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:1107:in `each'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:1107:in `retrieve'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:1130:in `retrieve_resource'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction/resource_harness.rb:307:in `from_resource'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction/resource_harness.rb:20:in `evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:267:in `apply'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:288:in `eval_resource'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:191:in `call'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:191:in `block (2 levels) in evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:567:in `block in thinmark'
/opt/puppetlabs/puppet/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:566:in `thinmark'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:191:in `block in evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/graph/relationship_graph.rb:122:in `traverse'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:178:in `evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:238:in `block (2 levels) in apply'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:567:in `block in thinmark'
/opt/puppetlabs/puppet/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:566:in `thinmark'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:237:in `block in apply'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/log.rb:165:in `with_destination'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction/report.rb:151:in `as_logging_destination'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:236:in `apply'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:286:in `block (2 levels) in apply_catalog'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:567:in `block in thinmark'
/opt/puppetlabs/puppet/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:566:in `thinmark'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:285:in `block in apply_catalog'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:245:in `block in benchmark'
/opt/puppetlabs/puppet/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:244:in `benchmark'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:284:in `apply_catalog'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:500:in `run_internal'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:339:in `run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/apply.rb:361:in `apply_catalog'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/apply.rb:273:in `block in main'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/context.rb:62:in `override'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb:289:in `override'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/apply.rb:212:in `main'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/apply.rb:182:in `run_command'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:421:in `block in run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:756:in `exit_on_fail'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:421:in `run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:143:in `run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:77:in `execute'
/opt/puppetlabs/puppet/bin/puppet:5:in `<main>'
Debug: Class[Main]: Resource is being skipped, unscheduling all events
Debug: Stage[main]: Resource is being skipped, unscheduling all events
Debug: Finishing transaction 12240
Debug: Storing state
Debug: Pruned old state cache entries in 0.00 seconds
Debug: Stored state in 0.01 seconds
Notice: Applied catalog in 0.10 seconds

seting multiple alternatives to the same path

Affected Puppet, Ruby, OS and module versions/distributions

  • Module version: 1.0.1

How to reproduce (e.g Puppet code you use)

In trying to follow Neovim's instalation instructions to point vi, vim, and editor to the same binary (/usr/bin/nvim):

# install nvim as alternatives for various things…
Alternative_entry {
  ensure   => present,
  priority => 60,
  require  => Package[neovim],
}

# currently puppet/alternatives can only configure one laternative per path
alternative_entry { 'nvim as vim':
  name     => '/usr/bin/nvim',
  altlink  => '/usr/bin/vim',
  altname  => 'vim',
}
alternative_entry { 'nvim as vi':
  name     => '/usr/bin/nvim',
  altlink  => '/usr/bin/vi',
  altname  => 'vi',
}
alternative_entry { 'nvim as editor':
  name     => '/usr/bin/nvim',
  altlink  => '/usr/bin/editor',
  altname  => 'editor',
}

Alternatives {
  require => Package[neovim],
}
alternatives { 'vim':
  path => '/usr/bin/nvim',
}
alternatives { 'vi':
  path => '/usr/bin/nvim',
}
alternatives { 'editor':
  path => '/usr/bin/nvim',
}

What are you seeing

Error: Evaluation Error: Error while evaluating a Resource Statement, Cannot alias Alternative_entry[nvim as vi] to ["/usr/bin/nvim"] at /etc/puppetlabs/code/environments/production/manifests/sinix.pp:78; resource ["Alternative_entry", "/usr/bin/nvim"] already declared at /etc/puppetlabs/code/environments/production/manifests/sinix.pp:73 at /etc/puppetlabs/code/environments/production/manifests/sinix.pp:78:1 on node sinix.home

What behaviour did you expect instead

I'd expect it to work… there are a lot of programs which have different behaviour, depending on how they are called.

Support slave links

Ubuntu update-alternatives support slave links for commands items, like:

        update-alternatives \
          --install /usr/sbin/ip6tables ip6tables /usr/sbin/ip6tables-legacy 10 \
          --slave /usr/sbin/ip6tables-restore ip6tables-restore /usr/sbin/ip6tables-legacy-restore \
          --slave /usr/sbin/ip6tables-save ip6tables-save /usr/sbin/ip6tables-legacy-save

it would be nice if alternative_entry support this too.

Upload newer version to the forge

The version in the forge (0.1.1) causes this error

Error: /Stage[main]/Main/Alternatives[java]: Could not evaluate: wrong number of arguments(0 for 1)

But the version on master branch works without any problem. I have no idea if it has any problem, but in any case I believe it is a good idea upload current version, to make easier to install a working module.

alternative_entry keying to the wrong parameter?

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: PE 2016.1.2
  • Ruby: 2.1.8
  • Distribution: OL6
  • Module version: 0.3.0

How to reproduce (e.g Puppet code you use)

We have an Java RPM which installs oracle java. The RPM comes with an alternatives configuration that creats the following alternative_entry (described in puppet)

alternative_entry { '/usr/lib/jvm/java-1.8.0-oracle.x86_64':
  ensure   => 'present',
  altlink  => '/usr/lib/jvm/java-oracle',
  altname  => 'java_sdk_oracle',
  priority => '180092',
}

We also have openjdkl and oracle java-1.9 intalled on the system. What I know want to achive is a new alternatives enty which provides me a master link /usr/lib/jvm/java-1.8.0. So I added the following to my manifest:

alternative_entry { '/usr/lib/jvm/java-1.8.0-oracle.x86_64':
  ensure   => 'present',
  altlink  => '/usr/lib/jvm/java-1.8.0',
  altname  => 'java_1.8.0'
  priority => '10',
}

What are you seeing

When I run puppet with the manifest I get:

Notice: /Stage[main]/Main/Alternative_entry[/usr/lib/jvm/java-1.8.0-oracle.x86_64]/altname: altname changed 'java_sdk_1.8.0' to 'java_1.8.0'
Notice: /Stage[main]/Main/Alternative_entry[/usr/lib/jvm/java-1.8.0-oracle.x86_64]/priority: priority changed '180092' to '10'
Notice: Applied catalog in 1.46 seconds

So first of all... pupept thought he changed only some values of an already existing entry.
What I see on the system is the expected behaivour:

Pupept called alternatives --install and created a new config in /var/lib/alternatives with the following content:

cat /var/lib/alternatives/java_1.8.0
auto
/usr/lib/jvm/java-1.8.0

/usr/lib/jvm/java-1.8.0-oracle.x86_64
10

alternatives created the master link I was expecting:

[root@dev-sys0-sis-v01 ~]# ls -lisa /usr/lib/jvm/java-1.8.0
4613 0 lrwxrwxrwx 1 root root 28 Aug 16 18:18 /usr/lib/jvm/java-1.8.0 -> /etc/alternatives/java_1.8.0
[root@dev-sys0-sis-v01 ~]# ls -lisa /etc/alternatives/java_1.8.0
269939 0 lrwxrwxrwx 1 root root 37 Aug 16 18:18 /etc/alternatives/java_1.8.0 -> /usr/lib/jvm/java-1.8.0-oracle.x86_64

But after that, on every subsequent run, I run into idempotency issues:
On every pupept run I get:

puppet apply test.2pp
Notice: Compiled catalog for dev-sys0-sis-v01.sf-rz.de in environment production in 0.08 seconds
Notice: /Stage[main]/Main/Alternative_entry[/usr/lib/jvm/java-1.8.0-oracle.x86_64]/altname: altname changed 'java_sdk_1.8.0' to 'java_1.8.0'
Notice: /Stage[main]/Main/Alternative_entry[/usr/lib/jvm/java-1.8.0-oracle.x86_64]/priority: priority changed '180092' to '10'
Notice: Applied catalog in 1.38 seconds

When I do a püppet resource alternative_enty I see my entry with the curretn value:

alternative_entry { '/usr/lib/jvm/java-1.8.0-oracle.x86_64':
  ensure   => 'present',
  altlink  => '/usr/lib/jvm/java-1.8.0',
  altname  => 'java_1.8.0',
  priority => '10',
}

What I don't see anymore is the enty that manages the meta link for 'java_sdk_oracle'.

same goes for other entrys that are provided by the system. If I count the total entrys I get from "puppet resource alternative_enty" and the entrys that are available in /var/lib/alternatives, I can see that puppet is missing a lot of entrys.

What behaviour did you expect instead

I would expect the alternative_enty to be idempotent. And A puppet resource alternative_entry should display all alternative groups that are actually configured and not just one for every Path that is configured inside of the entry.

Output log

Any additional information you'd like to impart

What I've seen and discoverd so far, I think the issues I'm seeing is related to ressource keying. alternative_entry uses the path as key, but a path is not a unique value in the sense of alternatives itself. It should use either altlink or altname as key, or am I missing somithing here?

Regards

Raskil

Debian 6 with Ruby 1.8.7 broken

Just switches over from saz' module version, and it seems like there is a new Rubyism that is not supported on 1.8.7.

Fix or de-support Debian 6?

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 3.8.2
  • Ruby: 1.8.7 (2010-08-16 patchlevel 302)
  • Distribution: Debian GNU/Linux 6.0.10 (squeeze)
  • Module version: 1.0.1

How to reproduce (e.g Puppet code you use)

While loading types on the system.

What are you seeing

$ puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Loading facts
Error: Could not autoload puppet/type/alternatives: /var/lib/puppet/lib/puppet/type/alternatives.rb:4: syntax error, unexpected ':', expecting ')'
  newparam(:name, isnamevar: true) do
                            ^
/var/lib/puppet/lib/puppet/type/alternatives.rb:16: syntax error, unexpected ':', expecting ')'
  newproperty(:mode, required_features: [:mode]) do
                                       ^
/var/lib/puppet/lib/puppet/type/alternatives.rb:16: syntax error, unexpected ')', expecting $end
  newproperty(:mode, required_features: [:mode]) do
                                                ^
Error: Could not retrieve catalog from remote server: Could not intern from text/pson: Could not autoload puppet/type/alternatives: /var/lib/puppet/lib/puppet/type/alternatives.rb:4: syntax error, unexpected ':', expecting ')'
  newparam(:name, isnamevar: true) do
                            ^
/var/lib/puppet/lib/puppet/type/alternatives.rb:16: syntax error, unexpected ':', expecting ')'
  newproperty(:mode, required_features: [:mode]) do
                                       ^
/var/lib/puppet/lib/puppet/type/alternatives.rb:16: syntax error, unexpected ')', expecting $end
  newproperty(:mode, required_features: [:mode]) do
                                                ^
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

Could not determine auto or manual mode

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 5.5
  • Ruby:
  • Distribution: CentOS Linux release 7.5.1804 (Core)
  • Module version: 2.0.1

How to reproduce (e.g Puppet code you use)

puppet resource alternatives java

What are you seeing

puppet resource alternatives java
Error: Could not run: Could not determine if Alternativesjava is in auto or manual mode

What behaviour did you expect instead

puppet resource alternatives java
alternatives { 'java':
mode => 'auto',
path => '/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/jre/bin/java',
}

Output of /sbin/alternatives
  /sbin/alternatives --display java
java - status is auto.
 link currently points to /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/jre/bin/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/jre/bin/java - family java-1.8.0-openjdk.x86_64 priority 1800161
 slave jre: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/jre
 slave jre_exports: /usr/lib/jvm-exports/jre-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64
 [...]
 slave policytool.1.gz: /usr/share/man/man1/policytool-java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64.1.gz
 slave unpack200.1.gz: /usr/share/man/man1/unpack200-java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64.1.gz
Current `best' version is /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/jre/bin/java.

Any additional information you'd like to impart

Tested for CentOS 6 and 7

Fix in lib/puppet/provider/alternatives/rpm.rb:

@@ -53,9 +53,9 @@
     output = update('--display', @resource.value(:name))
     first = output.split("\n").first
 
-    if first =~ %r{auto mode}
+    if first =~ %r{status is auto}
       'auto'
-    elsif first =~ %r{manual mode}
+    elsif first =~ %r{status is manual}
       'manual'
     else
       raise Puppet::Error, "Could not determine if #{self} is in auto or manual mode"

Using a full path for path is not always desirable.

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 4.9
  • Ruby:
  • Distribution: CentOS 7
  • Module version: 0.3.0

Old version of module I know but looks to to be the same in 2.0.0

How to reproduce (e.g Puppet code you use)

alternatives{'java':
    path => 'java-1.8.0-openjdk',
}

What are you seeing

Rejected because java-1.8.0-openjdk is not fully qualified path

What behaviour did you expect instead

Should wiork.

Particualarly on CentOS 7

# alternatives --config java

There is 4 program that provides 'java'.


  Selection    Command
-----------------------------------------------
   1           java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.161-2.6.12.0.el7_4.x86_64/jre/bin/java)
*+ 2           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre/bin/java)
   3           /usr/lib/jvm/jre-1.8.0-oracle.x86_64/bin/java
   4           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java

while using

alternatives{'java':
    path => '/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre/bin/java',
}

does work it is a pain since as the package is updated to the new version this hard coded
version must be updated.

The following command does work.

alternatives  --set java java-1.8.0-openjdk.x86_64

does work but this is currently not possible via the alternatives puppet type

Any additional information you'd like to impart

Maybe a new paramater is the way to go.

Would be nice if `set` would also `install` the alternative if needed.

I had to do this my self which I think should really be offloaded to the mode:

        # install our alternative so it can be selected
        exec { "add $alt alternative":
                command => "update-alternatives --verbose --install $path $alt $mine 50",
                unless  => "update-alternatives --list $alt | grep -q $mine",
        } ->

        # update alternatives so conf points to my new folder above
        alternatives { $alt:
                path => $mine,
        }

check debian support

this module once listed debian 7 in the metadata.json. We removed it because it's EOL. We need to check if recent debian versions work and add them back.

Missing provider for AWS Linux

If no provider is given the Puppet execution fails with the following message:

err: Could not find a suitable provider for alternatives

If the rpm provider is specified the Puppet execution fails with the following message:

Provider rpm is not functional on this host

No new version on Puppet Forge since 2019

Hi,
There is no new versin since 03.03.2019 (v3.0.0)
Would it be possible to publish a new version on Puppet Forge ?
I am particularely interested by the fact this modules now officially supports Puppet 7
Cheers

How does one set alternative entry back to 'auto' mode?

When I first set up the alternative_entry, mode is set to 'auto' by default. Any subsequent change of the path forced mode to be manual. only deleting and recreating the entry (absent && present) makes it auto again.

Is there a better way?

Warnings when using Module

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 7.26.0
  • Ruby: 2.7.8
  • Distribution: Debian Bullseye
  • Module version: 4.2.0 and 5.0.0

What are you seeing

alternatives/rpm.rb:20: warning: already initialized constant ALT_RPM_QUERY_CURRENT_REGEX
alternatives/chkconfig.rb:22: warning: previous definition of ALT_RPM_QUERY_CURRENT_REGEX was here

alternative_entry/rpm.rb:56: warning: already initialized constant ALT_RPM_QUERY_REGEX
alternative_entry/chkconfig.rb:50: warning: previous definition of ALT_RPM_QUERY_REGEX was here

What behaviour did you expect instead

No warnings when using this module

Could not determine mode after upgrade to 4.1.0

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 7.16.0
  • Ruby: 2.7
  • Distribution: CentOS 7
  • Module version: 4.1.0

How to reproduce (e.g Puppet code you use)

Upgrade from older module version to 4.1.0.

What are you seeing

Error: /Stage[main]/Uv_java/Alternatives[java]: Could not evaluate: Could not determine if Alternatives[java](provider=chkconfig) is in auto or manual mode

What behaviour did you expect instead

Correctly determine mode.

Output log

Error: /Stage[main]/Uv_java/Alternatives[java]: Could not evaluate: Could not determine if Alternatives[java](provider=chkconfig) is in auto or manual mode

Any additional information you'd like to impart

Issue is in chkconfig provider. In ruby case statement multiple expressions are seperated ,.
I will try to send a PR today fixing this issue (it's my first one).

Error: Could not autoload puppet/provider/alternatives/chkconfig

I have an issue with the last version of puppet module alternatives. I can't fix this issue after the last changes in puppet module alternatives. the error is as below :

Error: Could not autoload puppet/provider/alternatives/chkconfig: /etc/puppetlabs/code/environments/production/modules/alternatives/lib/puppet/provider/alternatives/chkconfig.rb:36: syntax error, unexpected keyword_rescue, expecting keyword_end
==> rescue StandardError
==>            ^
==>/etc/puppetlabs/code/environments/production/modules/alternatives/lib/puppet/provider/alternatives/chkconfig.rb:80: syntax error, unexpected keyword_end, expecting end-of-input
==>Error: Could not autoload puppet/type/alternatives: Could not autoload puppet/provider/alternatives/chkconfig: /etc/puppetlabs/code/environments/production/modules/alternatives/lib/puppet/provider/alternatives/chkconfig.rb:36: syntax error, unexpected keyword_rescue, expecting keyword_end
==> rescue StandardError
==>           ^
==> /etc/puppetlabs/code/environments/production/modules/alternatives/lib/puppet/provider/alternatives/chkconfig.rb:80: syntax error, unexpected keyword_end, expecting end-of-input
==>  Error: Evaluation Error: Error while evaluating a Type-Name, Could not autoload puppet/type/alternatives: Could not autoload puppet/provider/alternatives/chkconfig: /etc/puppetlabs/code/environments/production/modules/alternatives/lib/puppet/provider/alternatives/chkconfig.rb:36: syntax error, unexpected keyword_rescue, expecting keyword_end

Can someone know how to solve this issue ? i tried to solve it with the last version of alternatives 4.1.0 and the previous one 4.0.0 but the error still exist. puppet agent version 5.5.22.

plugin sync error?

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet:puppet-3.8.6-2.el6.noarch
  • Ruby:ruby-1.8.7.374-4.el6_6.x86_64
  • Distribution:Scientific Linux 6
  • Module version:1.0.1

How to reproduce (e.g Puppet code you use)

  alternative_entry { $alt_path:
    ensure   => 'present',
    altlink  => "/usr/bin/${alt_bin}",
    altname  => $alt_bin,
    priority => 1,
    require  => Package[$pkgs],
  }

What are you seeing

Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not autoload puppet/type/alternative_entry: /var/lib/puppet/lib/puppet/type/alternative_entry.rb:4: syntax error, unexpected ':', expecting ')'
  newparam(:name, isnamevar: true) do
                            ^
/var/lib/puppet/lib/puppet/type/alternative_entry.rb:35: syntax error, unexpected kEND, expecting $end
Error: Could not retrieve catalog from remote server: Could not intern from text/pson: Could not autoload puppet/type/alternative_entry: /var/lib/puppet/lib/puppet/type/alternative_entry.rb:4: syntax error, unexpected ':', expecting ')'
  newparam(:name, isnamevar: true) do
                            ^
/var/lib/puppet/lib/puppet/type/alternative_entry.rb:35: syntax error, unexpected kEND, expecting $end
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

What behavior did you expect instead

No errors

Output log

Error: Could not autoload puppet/type/alternative_entry: /var/lib/puppet/lib/puppet/type/alternative_entry.rb:4: syntax error, unexpected ':', expecting ')'
  newparam(:name, isnamevar: true) do
                            ^
/var/lib/puppet/lib/puppet/type/alternative_entry.rb:35: syntax error, unexpected kEND, expecting $end
Error: Could not retrieve catalog from remote server: Could not intern from text/pson: Could not autoload puppet/type/alternative_entry: /var/lib/puppet/lib/puppet/type/alternative_entry.rb:4: syntax error, unexpected ':', expecting ')'
  newparam(:name, isnamevar: true) do
                            ^
/var/lib/puppet/lib/puppet/type/alternative_entry.rb:35: syntax error, unexpected kEND, expecting $end
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
# puppet resource alternatives
Error: Could not autoload puppet/type/alternatives: /var/lib/puppet/lib/puppet/type/alternatives.rb:4: syntax error, unexpected ':', expecting ')'
  newparam(:name, isnamevar: true) do
                            ^
/var/lib/puppet/lib/puppet/type/alternatives.rb:16: syntax error, unexpected ':', expecting ')'
  newproperty(:mode, required_features: [:mode]) do
                                       ^
/var/lib/puppet/lib/puppet/type/alternatives.rb:16: syntax error, unexpected ')', expecting $end
  newproperty(:mode, required_features: [:mode]) do
                                                ^
Error: Could not run: Could not autoload puppet/type/alternatives: /var/lib/puppet/lib/puppet/type/alternatives.rb:4: syntax error, unexpected ':', expecting ')'
  newparam(:name, isnamevar: true) do
                            ^
/var/lib/puppet/lib/puppet/type/alternatives.rb:16: syntax error, unexpected ':', expecting ')'
  newproperty(:mode, required_features: [:mode]) do
                                       ^
/var/lib/puppet/lib/puppet/type/alternatives.rb:16: syntax error, unexpected ')', expecting $end
  newproperty(:mode, required_features: [:mode]) do
                                                ^

Any additional information you'd like to impart

Edited to provide more output and formatting

missing alternatives is not added - it breaks instead

This:
alternatives { 'java': path => "/usr/java/jre1.8.0-101/bin/java" }
Gives me:
Could not evaluate: Execution of '/sbin/alternatives --display java' returned 2: failed to read link /usr/bin/java: No such file or directory

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 3.8.2
  • Ruby: 2.0.0
  • Distribution: CentOS 7
  • Module version: Git HEAD as of today

validate if alternatives are available

the problem is I have 12.04 machines and Ubuntu 14.04 LTS machines. 12.04 has alternatives for Ruby and 14.04 does not. not sure how to do this but to make it OS independent but can you check if there are alternatives first and then just continue if not available..

right now it dumps out. Might not be the best idea but I don't like the idea of putting a condition around the alternatives to handle the OS differences.

Adding new alternative_entry fails

You can't have more than one alternative_entry or create new alternative_entry if one was added manually as provider tries to remove this alternative.

Example:

  alternative_entry { '/etc/hadoop/conf.one:
    ensure   => present,
    altlink  => '/etc/hadoop/conf',
    altname  => 'hadoop-conf',
    priority => 99,
  }

Will work only if no /var/lib/alternatives/hadoop-conf

And eve we have no such entry if we try to add one more alternative entry:

  alternative_entry { '/etc/hadoop/conf.empty':
    ensure   => present,
    altlink  => '/etc/hadoop/conf',
    altname  => 'hadoop-conf',
    priority => 10,
  }
Notice: /Stage[main]/Wg::Dwh::Jenkins/Alternative_entry[/etc/hadoop/conf.one]/altlink: defined 'altlink' as '/etc/hadoop/conf'
Notice: /Stage[main]/Wg::Dwh::Jenkins/Alternative_entry[/etc/hadoop/conf.one]/altname: defined 'altname' as 'hadoop-conf'
Notice: /Stage[main]/Wg::Dwh::Jenkins/Alternative_entry[/etc/hadoop/conf.one]/priority: defined 'priority' as '99'
Error: Execution of '/usr/sbin/alternatives --remove hadoop-conf /etc/hadoop/conf.empty' returned 2: /etc/hadoop/conf.empty has not been configured as an alternative for hadoop-conf
Error: /Stage[main]//Alternative_entry[/etc/hadoop/conf.empty]/altlink: change from absent to /etc/hadoop/conf failed: Execution of '/usr/sbin/alternatives --remove hadoop-conf /etc/hadoop/conf.empty' returned 2: /etc/hadoop/conf.empty has not been configured as an alternative for hadoop-conf

manual install

sorry for coming with this weird request, but i am on Ubuntu 12.04 and there is only puppet 2.7.11 as newest version and the command puppet-module is introduced in 2.7.13 :(

how can i install it manually and will it work with such an old version?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.