voxpupuli / puppet-bareos

Puppet Module to manage bareos
https://forge.puppetlabs.com/project0/bareos
Apache License 2.0
13 stars 36 forks source link

[ISSUE] With run_script syntax of the module #135

Closed Orest-Worhacz closed 1 year ago

Orest-Worhacz commented 1 year ago

Affected Puppet, Ruby, OS and module versions/distributions

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

::bareos::director::job { 'weekly_backup_of_somehost':
  client                => 'somehost-fd',
  file_set              => 'fileset_for_somehost',
  schedule              => 'WeeklyJobs',
  priority              => 17,
  storage               => 'File',
  write_bootstrap       => '/var/lib/bareos/%c.bsr',
  job_defs              => 'SomeJobsDefs',
  run_script            => {
    'Console'         => '".bvfs_update jobid=%i jobtype=b"',
    'Runs When'       => 'After',
    'Runs On Client'  => 'No',
    'Runs on Failure' => 'No',
  },
  client_run_before_job => {
    'Fail Job On Error' => 'Yes',
    'Command'           => '/usr/local/bin/mksnap.sh before_backup',
  },
  client_run_after_job  => {
    'Fail Job On Error' => 'No',
    'Command'           => '/usr/local/bin/mksnap.sh after_backup',
  },

What are you seeing

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, Value need to be an string (file: /etc/puppetlabs/code/environments/production/modules_external/bareos/manifests/director/job.pp, line: 728, column: 18) (file: /etc/puppetlabs/code/environments/production/modules/its_bareos/manifests/jobs.pp, line: 493) on node bareos-puppet.tld

What behavior did you expect instead

Module would produce somewhat following code:

Job {
  JobDefs ="SomeJobsDefs"
  Storage = File
  Client = somehost-fd
  FileSet = "fileset_for_somehost"
  Schedule = "WeeklyJobs"
  Name = "weekly_backup_of_somehost"
  Write Bootstrap = "/var/lib/bareos/somehost-fd.bsr"
  Run Script {
    RunsWhen = Before
    FailJobOnError = Yes
    Command = "/usr/local/bin/mksnap.sh before_backup"
  }
  Run Script {
    RunsWhen = After
    FailJobOnError = No
    Command = "/usr/local/bin/mksnap.sh after_backup"
  }
  Run Script {
      Console = ".bvfs_update jobid=%i jobtype=b"
      Runs When = After
      Runs On Client' = No
      Runs on Failure = No
}

Output log

Log attached in what I am seeing

Any additional information you'd like to impart

I tried many combinations of the run_script but without success. How to proceed? Line 493 in jobs.pp is just the main resource with name: ::bareos::director::job { 'weekly_backup_of_somehost':

I am also trying to follow: https://docs.bareos.org/Configuration/Director.html#config-Dir_Job_RunScript But the documentation is unclear to me.

Orest-Worhacz commented 1 year ago

Now I see. https://github.com/voxpupuli/puppet-bareos/blob/0.4.0/manifests/director/job.pp#L147 Is of type runscrupt_short not runscript. Placing just command there works.

Could it be simply extended by replacing in code the type of runscript_short to change it to runscript?

Orest-Worhacz commented 1 year ago

No it's defined in Bareos itself not the module. Closing as solved.