Ask Your Question
1

referencing variables inside exec command

asked 2015-05-20 19:15:03 -0500

johntest gravatar image

updated 2015-05-20 19:27:31 -0500

GregLarkin gravatar image

I have tried a few different methods but not able to successfully reference variables inside exec command in same class. How can I do this correctly please? Thanks.

class zabbixha_post (
  $zabclusterip     = '192.168.5.23',
  $zabclustermask     = '24',
  ) {

   exec { 'create-ip':
     command => '/usr/sbin/pcs resource create ClusterIP ocf:heartbeat:IPaddr2 ip=<%=scope.lookupvar('zabbixha_post::zabclusterip') %>  cidr_netmask=<%=scope.lookupvar('zabbixha_post::zabclustermask') %> op monitor interval=5s',
   }

}
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-05-20 19:28:30 -0500

GregLarkin gravatar image

Simply refer to them with their name, e.g. ${zabclusterip}, but also make sure to change the single quotes around your command to double quotes so variable interpolation works.

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

1 follower

Stats

Asked: 2015-05-20 19:15:03 -0500

Seen: 1,734 times

Last updated: May 20 '15