Ask Your Question
0

Variable assignment question

asked 2015-08-13 07:55:53 -0500

kartikv gravatar image

This is still not working: case $operatingsystemmajrelease { '6': { $TOUCH = "/bin/touch"} '7': { $TOUCH = "/usr/bin/touch"} } This does not work either: case $operatingsystemmajrelease { "6": { $TOUCH='/bin/touch' } "7": { $TOUCH='/usr/bin/touch' } default: { fail('Operatingsystemmajrelease case default triggered.')} }

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-08-13 17:44:58 -0500

cm gravatar image

Hello kartikv,

Your first example seem to work for me. Your second example: the default case should be inside the case statement.

It is good to use topscope :: signs when using facts (just to be sure that you are not overwriting their values in another scope)

class tester {

    case $::operatingsystemmajrelease {
        '6': { $TOUCH = '/bin/touch' }
        '7': { $TOUCH = '/usr/bin/touch' }
        default: { fail('Maj release is not supported') }
    }
    notify {"Maj release is ${::operatingsystemmajrelease} and touch located at ${TOUCH}":}
}

cat tester/tests/init.pp

include tester

then: puppet apply --noop tester/tests/init.pp

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2015-08-13 07:55:53 -0500

Seen: 130 times

Last updated: Aug 13 '15