Hi Valayil, You seem to miss loading the stdin json in your task: https://puppet.com/docs/bolt/latest/writing_tasks.html#no-op-task-example <https://puppet.com/docs/bolt/latest/writing_tasks.html#no-op-task-example> #!/usr/bin/env python
import json import sys params = json.load(sys.stdin) Hth, Martin > On 30. Jun 2020, at 02:58, Valayil Abraham <[email protected]> wrote: > > I have a python task in Puppet. Passing a parameter into the task. Need to > check the parameter in the code. > This what the code check looks like > > if {params['date'] == "yesterday"}: > print("Yesterday") > else: > print("Not Yesterday"} > > The if statement doesn't work when run from Puppet Console. Prints Yesterday > no matter what the parameter is. Not sure why. > > I can get the same thing to work from the command line with the following > > if sys.argv[1] == "yesterday" > print("Yesterday") > else: > print("Not Yesterday"} > > Why do the parameters behave differently in Puppet? Any help in resolving > this would be appreciated. > > > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/puppet-users/236ca31b-018b-4cbd-bf60-7808d1731c04o%40googlegroups.com > > <https://groups.google.com/d/msgid/puppet-users/236ca31b-018b-4cbd-bf60-7808d1731c04o%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/16DDD1C4-593B-415D-94B4-77157E9A9984%40gmail.com.
