Resource reference passing in puppet

Posted by paweloque on Server Fault See other posts from Server Fault or by paweloque
Published on 2012-10-26T08:49:58Z Indexed on 2012/10/30 5:05 UTC
Read the original article Hit count: 502

Filed under:
|

Is it possible to pass puppet resource references to other resources? My use-case is to build a jenkins build pipeline with puppet. To chain jenkins jobs into a pipeline I need to pass the successor job to a job. A subset of the definition is:

jobs::build { "Build ${release_name}":
  release           => $release_name,
  jenkins_jobs_path => $jenkins_jobs_path,
   successors        => 'Deploy',
}

jobs::deploy { "Deploy ${release_name}":
  release           => $release_name,
  jenkins_jobs_path => $jenkins_jobs_path,
  successors        => 'Smoke Test',
}

In the def you see that I define the successors by name, i.e. 'Deploy' and in case of the second job 'Smoke Test'. What I'd like to do is to pass a reference to a resource and extract the name from it:

jobs::build { "Build ${release_name}":
  release           => $release_name,
  jenkins_jobs_path => $jenkins_jobs_path,
   successors       => Jobs::Deploy["Deploy ${release_name}"],
}

jobs::deploy { "Deploy ${release_name}":
  release           => $release_name,
  jenkins_jobs_path => $jenkins_jobs_path,
  successors        => Jobs::Smoke_test["Smoke Test ${release_name}"],
}

And then within the jobs::deploy and jobs::build definition I'd access the resource by reference and query for it's type, etc..

Is it possible to achieve this in puppet?

© Server Fault or respective owner

Related posts about puppet

Related posts about reference