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

Use the new setup script argument types #14313

Merged
merged 1 commit into from
Mar 15, 2017

Conversation

carbonin
Copy link
Member

A change was made to pass options that come to the setup script after a "--" straight through, unaltered to the ansible-playbook command.

This is how we will get access to the --tags and --skip-tags options that we need.

with_inventory_file do |inventory_file_path|
AwesomeSpawn.run!(SETUP_SCRIPT, :params => params.merge(:i => inventory_file_path))
params = [[:e, json_extra_vars], [:i, inventory_file_path]] << "--" << ["--skip-tags=", exclude_tags]
Copy link
Member

@jrafanie jrafanie Mar 14, 2017

Choose a reason for hiding this comment

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

I think this might read easier split out even though you'd get more lines added 😢

params  = []
params << [:e, json_extra_vars]
params << [:i, inventory_file_path]
params << "--"
params << ["--skip-tags=", exclude_tags]

Otherwise, it might be easy to miss the "--"

Also, this way you don't have to see [ and mentally search for the closing ].

@jrafanie
Copy link
Member

A change was made to pass options that come to the setup script after a "--" straight through, unaltered to the ansible-playbook command.

Does this change require a specific version of the setup script? Do we need to worry about which version of the setup script we're going to get?

@carbonin
Copy link
Member Author

@jrafanie No, we should be fine, this is the version that will come with 3.1.2

Copy link
Member

@jrafanie jrafanie left a comment

Choose a reason for hiding this comment

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

LGTM once the minor readability change is made. 👍

Copy link
Member

@jrafanie jrafanie left a comment

Choose a reason for hiding this comment

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

:shipit: if 💚

params << [:e, json_extra_vars]
params << [:i, inventory_file_path]
params << "--"
params << ["--skip-tags=", exclude_tags]
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be done a little cleaner...

params = {
  :e             => json_extra_vars,
  :i             => inventory_file_path,
  "--"           => nil,
  "--skip-tags=" => exclude_tags
}

Might I also recommend long-form tags for e and i for readability?

Copy link
Member Author

Choose a reason for hiding this comment

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

Will this ensure that order is preserved? That's why I moved from hash to array.

Copy link
Member

Choose a reason for hiding this comment

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

Yes

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, just double checked, there are no long form options for -e and -i.

Copy link
Member Author

@carbonin carbonin Mar 14, 2017

Choose a reason for hiding this comment

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

Interesting, so the setup script doesn't take long options, but the ansible-playbook command does. So we could do:

params = {
  "--"         => nil,
  :extra_vars= => json_extra_vars,
  :inventory=  => inventory_file_path,
  :skip_tags=  => exclude_tags
}

Copy link
Member

Choose a reason for hiding this comment

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

It's up to you what you think is preferable.

@@ -228,12 +228,16 @@
it "generates new passwords with no passwords set" do
expect(described_class).to receive(:generate_database_authentication).and_return(double(:userid => "awx", :password => "databasepassword"))
expect(AwesomeSpawn).to receive(:run!) do |script_path, options|
params = options[:params]
inventory_file_contents = File.read(params[:i])
e, i, dashes, skip_tags = options[:params]
Copy link
Member

@Fryguy Fryguy Mar 14, 2017

Choose a reason for hiding this comment

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

Same here...Instead of e and i, can we have full names for readability?

A change was made to pass options that come to the setup script
after a "--" straight through, unaltered to the ansible-playbook
command.

This is how we will get access to the --tags and --skip-tags options
that we need.
@miq-bot
Copy link
Member

miq-bot commented Mar 14, 2017

Checked commit carbonin@b12c8fd with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 0 offenses detected
Everything looks good. 🍰

@carbonin carbonin requested a review from Fryguy March 14, 2017 19:31
Copy link
Member

@gtanzillo gtanzillo left a comment

Choose a reason for hiding this comment

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

👍

@jrafanie
Copy link
Member

Merging, comments appear to be addressed.

@jrafanie jrafanie merged commit a439e6c into ManageIQ:master Mar 15, 2017
@jrafanie jrafanie added this to the Sprint 57 Ending Mar 27, 2017 milestone Mar 15, 2017
@jrafanie jrafanie assigned jrafanie and unassigned gtanzillo Mar 15, 2017
@carbonin carbonin deleted the use_new_setup_script branch May 18, 2017 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants