Skip to content

Support repeatable "node_json" and "node_yaml" options #351

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

Merged
merged 3 commits into from
May 23, 2022

Conversation

ineu
Copy link

@ineu ineu commented May 22, 2022

Thor supports two ways to pass mutiple values to a flag: via the :array type or via the "repeatable" option. This PR adds the latter.
It allows to pass multiple node_yaml and node_json files that will all be read and applied to a node.

The logic is as follows:

  • Hashes are merged
  • Scalars and arrays are overwritten

A common use case for this feature is applying vars to a group of nodes (compare to Ansible's group_vars and host_vars).

Example:

  itamae ssh --node-json vars/global.json --node-yaml group.yml --node-yaml node-1.yml recipes.rb

Like this:
  itamae ssh --node-yaml foo.yaml --node-yaml bar.yml recipes.rb
Explicit unlink is not needed for Tempfile in tests anyway
@sue445 sue445 requested review from sue445 and unasuke May 22, 2022 22:48
Copy link
Member

@unasuke unasuke left a comment

Choose a reason for hiding this comment

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

I think it's good. After merging this, we should increment minor version, don't we? @sue445

Copy link
Member

@sue445 sue445 left a comment

Choose a reason for hiding this comment

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

@ineu repeatable option is available since thor v1.0.0+.
https://github.com/rails/thor/releases/tag/v1.0.0

Could you add >= 1.0.0 to https://github.com/itamae-kitchen/itamae/blob/v1.12.6/itamae.gemspec#L29 ?

e.g.

spec.add_runtime_dependency "thor", ">= 1.0.0"

Other changes are LGTM

@ineu
Copy link
Author

ineu commented May 23, 2022

Good point, I'll fix it.

Btw, should Ruby 2.3 still be supported? It has been deprecated for 6 years by now: https://endoflife.date/ruby
It's the default version in Ubuntu 16.04 LTS, but 18.04 LTS has 2.5

@unasuke
Copy link
Member

unasuke commented May 23, 2022

@ineu It's a sharp and interesting question for us.
Usually, no one uses ruby 2.3 now. But in the world of infrastructure as code, it's not surprising to use outdated instances like running ruby 2.3. Actually, specinfra which is the backend library of itamae, supports ruby 2.1.
And, Itamae has not specificated its support versions of ruby before now. If dropping support of eol-ed ruby, we should release a new major version.

related #292

@sue445 sue445 self-requested a review May 23, 2022 22:54
Copy link
Member

@sue445 sue445 left a comment

Choose a reason for hiding this comment

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

LGTM!

@sue445 sue445 merged commit 3859c35 into itamae-kitchen:master May 23, 2022
@ineu ineu deleted the feature/multiple-var-files branch May 24, 2022 09:06
@sue445
Copy link
Member

sue445 commented May 24, 2022

I published v1.13.0 🚀

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.

4 participants