Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deploy task #400

Merged
merged 3 commits into from
Jan 30, 2018
Merged

Add deploy task #400

merged 3 commits into from
Jan 30, 2018

Conversation

binford2k
Copy link
Member

@binford2k binford2k commented Dec 7, 2017

#puppethack This is a pretty basic and not very clever task to orchestrate r10k
deployments. I'd like to add more at some point, but this seems like an
ok MVP.

tasks/deploy.rb Outdated
if modules
list = modules.join(',')
messages << "Deploying modules #{list}."
`/opt/puppetlabs/bin/r10k deploy module #{list}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we rely on a proper PATH variable here? Otherwise we need a solution to set the path or something similar. This will fail on systems where r10k isn't installed into puppet.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a solid answer for that, but relying on $PATH seemed to work for me, so I took out the fully qualified path.

@bastelfreak
Copy link
Member

Puppet tasks \o/

"description": "Trigger an r10k deployment.",
"puppet_task_version": 1,
"parameters": {
"environment": {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It kind of seems stupid to have singular and plural forms of these arguments.

"parameters": {
"environment": {
"description": "The environment to deploy.",
"type": "String"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there are simple regexes for module and environment names we should probably use them to validate either in the metadata types or the task script itself to prevent shell injections.

Since there are two options here these should probably be optional.

something like
Optional[Pattern[/\A[a-z0-9_]+\Z/]]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're going to do that, I am pretty sure you cannot start or end with an underscore, not sure about leading digits. I don't know where the official restriction description/regex is located, though.

tasks/deploy.rb Outdated
if environments
environments.each do |env|
messages << "Deploying environment #{env}."
`/opt/puppetlabs/bin/r10k deploy environment #{env} --puppetfile`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My recollection of r10k is that it will be hard to debug failures without capturing stderr. I could be wrong though

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r10k is hard to debug anyway. My thought was that if it failed, you'd attempt a manual deploy for troubleshooting.

tasks/deploy.rb Outdated
if environments
environments.each do |env|
messages << "Deploying environment #{env}."
`/opt/puppetlabs/bin/r10k deploy environment #{env} --puppetfile`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worthwhile to allow an optional path parameter, for those who do things their own way.

@bastelfreak
Copy link
Member

👍 for the last commit message

This is a pretty basic and not very clever task to orchestrate r10k
deployments. I'd like to add more at some point, but this seems like
an ok MVP. #puppethack
tasks/deploy.rb Outdated
exitstatus += status.exitstatus
end

puts({ 'messages' => messages }.to_json)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the exit status be returned in the json as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm. There's not a precedent for it, but I do think that's probably a good idea. Maybe even a more structured output instead of just a list of messages and a status. Lemme think on it.

'status' => exitstatus.zero?,
'messages' => messages,
'warnings' => warnings,
'errors' => errors
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dhollinger dhollinger merged commit 805947a into voxpupuli:master Jan 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants