I think, problems was resolved:
Exec with this "onlyif":
onlyif => "test `/root/test-new.sh ${veid} ${vetarif}` = 0 "
Run only if $veid=302:
Dec 15 19:12:19 vz-test puppetd[16426]: Starting catalog run
Dec 15 19:12:45 vz-test puppetd[16426]: (//Node[vz-test.local]/
Mod_class_ovzconfigs::Mod_def_ovzbackup[ovzserver_backup]/Cron
[incremental_backup]/weekday) defined 'weekday' as '*'
Dec 15 19:12:46 vz-test puppetd[16426]: (//Node[vz-test.local]/
Mod_class_ovzconfigs::Mod_def_veadm[customer2.vps.local]/Exec[vecfg-
applyset_customer2.vps.local]/returns) executed successfully
Dec 15 19:12:46 vz-test puppetd[16426]: Finished catalog run in 27.27
seconds
onlyif => "test `/root/test-new.sh ${veid} ${vetarif}` = 0 "
[r...@vz-test conf]# cat /root/test-new.sh
#!/bin/bash
if [[ $1 = 302 ]]
then echo 0
else echo 1
fi
Thank you for answer.
For another puppet users, who find this topic: try to use binary file
test for test with your custom scripts :))
On 15 дек, 11:12, sHaggY_caT <[email protected]> wrote:
> Hi John,
>
> Thank you for answer.
>
> > For debugging your manifests, you could try using
>
> > unless => "/bin/true"
>
> > or
>
> > unless => "/bin/false"
>
> > to take that test script out of the picture.
>
> Script, in "command" work fine.
>
> > Speaking of the test script, are you sure your nodes are getting and
> > using the correct version?
>
> It's use one version, without differents of number:
>
> [shaggy...@puppet ~]$ rpm -qa | grep puppet
> puppet-server-0.24.8-1.el5.1
> puppet-0.24.8-1.el5.1
> [shaggy...@puppet ~]$
>
> [r...@vz-test conf]# rpm -qa | grep puppet
> puppet-0.24.8-1.el5.1
> [r...@vz-test conf]#
>
> > As far as I know, Exec executes its command(s) directly, not via a
> > shell, so I would be surprised if that did what you expect,
> > independent of the "unless". That is, "if" is a keyword in the sh
> > language, not an executable program (not on any system I'm familiar
> > with, anyway), so I would expect that Exec to fail every time it runs.
>
> OK, i think you true. Do you have means, how use bash script inside
> "onlyif"/"unless"?
> I try use script in command line:
>
> [r...@vz-test conf]# test "/usr/sbin/rc.test-parametrs-changed.sh
> check_settings 301 10.0.5.31 yes vps256M 10.0.5.52"
> [r...@vz-test conf]# echo $?
> 0
> [r...@vz-test conf]# /usr/sbin/rc.test-parametrs-changed.sh
> check_settings 301 10.0.5.31 yes vps256M 10.0.5.52
> [r...@vz-test conf]# echo $?
> 1
> [r...@vz-test conf]#
>
> but, bash exec(system command) return 0:
>
> [r...@vz-test conf]# bash /usr/sbin/rc.test-parametrs-changed.sh
> check_settings 301 10.0.5.31 yes vps756M 10.0.5.52
> [r...@vz-test conf]# echo $?
> 0
> [r...@vz-test conf]#
>
> but "unless" inside puppet exec run exec:
>
> exec { "vecfg-applyset_${name}":
> command => "if [[ ( -d /vz/private/${veid} ) && ( -f /etc/
> sysconfig/vz-scripts/${veid}.conf) && \
> ( $(/usr/sbin/rc.test-parametrs-changed.sh check_settings ${veid}
> ${veip} ${vetarif} ${vedns} ; echo $?) -eq 1)]] ; \
> then vzctl set ${veid} --hostname ${vehostname} --ipadd ${veip}
> --nameserver ${vedns} --save; \
> vzctl set ${veid} --applyconfig ${vetarif} --save; fi",
> path => ["/usr/bin", "/usr/sbin"],
> unless => "bash /usr/sbin/rc.test-parametrs-changed.sh
> check_settings ${veid} ${veip} ${vetarif} ${vedns}",
> }
>
> If/else inside "command" works, as i test (i use if/else inside
> command, becouse unless/onlyif does'nt work for me):
>
> [r...@vz-test conf]# cat ~/tmp_2 | grep -v _off
> Dec 15 13:41:05 vz-test puppetd[23387]: Starting catalog run
> Dec 15 13:41:06 vz-test puppetd[23387]: (//Node[vz-test.local]/
> Mod_class_ovzconfigs::Mod_def_veadm[customer2.vps.local]/Exec[vecfg-
> applyset_customer2.vps.local]/returns) executed successfully
> Dec 15 13:41:16 vz-test puppetd[23387]: (//Node[vz-test.local]/
> Mod_class_ovzconfigs::Mod_def_ovzbackup[ovzserver_backup]/Cron
> [incremental_backup]/weekday) defined 'weekday' as '*'
> Dec 15 13:43:07 vz-test puppetd[23387]: (//Node[vz-test.local]/
> Mod_class_ovzconfigs::Mod_def_veadm[customer1.vps.local]/Exec[vecfg-
> applyset_customer1.vps.local]/returns) executed successfully
> Dec 15 13:43:14 vz-test puppetd[23387]: (//Node[vz-test.local]/
> Mod_class_ovzconfigs::Mod_def_veadm[customer4.vps.local]/Exec[vecfg-
> applyset_customer4.vps.local]/returns) executed successfully
> Dec 15 13:43:29 vz-test puppetd[23387]: Finished catalog run in 143.67
> seconds
>
>
>
> > You can have the puppetmaster distribute
> > it, but you may need to set up a require for it to make sure its
> > downloaded first. (It's not clear from the docs whether Puppet will
> > autorequire it from the "unless" parameter.) You'll also want to make
> > sure its ownership and permissions are set appropriately.
>
> > John
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.