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

Fixes #28287 - Import Ansible roles and variables in one step #379

Merged
merged 1 commit into from
Feb 17, 2021

Conversation

shiramax
Copy link
Contributor

@shiramax shiramax commented Jan 19, 2021

This PR Includes:

  • The ability to sync roles and their variables from Capsule in one step
  • React table to present all the roles and variables that need to be synced.
  • Removing the 'import variables' view from the index variables page.

</Table>
{renderNotFound()}
{renderPagination()}
{renderSubmitAndCancel()}
Copy link
Contributor

Choose a reason for hiding this comment

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

You can turn these into separate components to make this component a bit more slim.

package.json Outdated Show resolved Hide resolved
@xprazak2
Copy link
Contributor

Nice work, I added a couple of comments.

package.json Outdated Show resolved Hide resolved
@xprazak2
Copy link
Contributor

xprazak2 commented Jan 25, 2021

Nice progress, the pagination does not quite work for me:

roles-page

nit: it could be nice to add a bit of space between the buttons

@shiramax
Copy link
Contributor Author

@xprazak2 I've addressed all your comments, let me know if you have more comments. thanks!

@xprazak2
Copy link
Contributor

I still see roles/variables repeatedly offered for update. Reproducer:

  1. Create a fake role with variable inside roles_path so that proxy is able to detect it:
mkdir -p roles_path/another.role/defaults
echo "another_role_variable: foo" > roles_path/another.role/defaults/main.yml
  1. Create a role and variable via console to simulate that records already exist in database, use the same names as what is in roles_path:
role = AnsibleRole.create(:name => "another.role")
AnsibleVariable.create(
  :key => "another_role_variable",
  :value => "foo",
  :hidden_value => true,
  :imported => true,
  :ansilbe_role_id => role.id
)
  1. Import will show another.role as a role to update, select and confirm. Then try to import again and another.role will be shown for update again.

import_variable_names([]).each do |kind, variables|
variables.each do |variable|
next unless roles['old'].values.map { |role| role['id'] }.include?(variable.ansible_role_id)
role = AnsibleRole.where(:id => variable.ansible_role_id)[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: role = variable.ansible_role ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

package.json Outdated Show resolved Hide resolved
@shiramax
Copy link
Contributor Author

@xprazak2 thanks now I'm able to reproduce it, it was fixed.

@shiramax
Copy link
Contributor Author

[test foreman_ansible]

@xprazak2
Copy link
Contributor

Works as expected, patternfly packages should not be in devDependencies, but I have no additional comments other than that.

Copy link
Contributor

@xprazak2 xprazak2 left a comment

Choose a reason for hiding this comment

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

Does anyone have any additional comments or concerns?

@ezr-ondrej
Copy link
Member

I didn't tested it, but code looks reasonable, if you want mi to take it for a spin, give me a shout

@ezr-ondrej
Copy link
Member

Maybe it would deserve some commit description? 🤷

@@ -22,18 +22,19 @@ def destroy

def import
changed = @importer.import!
if changed.values.all?(&:empty?)
@rows = prepare_ansible_import_rows(changed, @variables_importer)
if @rows.empty?
success no_changed_roles_message
Copy link
Member

Choose a reason for hiding this comment

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

this message could be tailored into "No added or removed roles nor variables" I'm ok to do so in another PR though :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

This PR Includes:
- The ability to sync roles and their variables from Capsule in one step
- React table to present all the roles and variables that need to be synced.
- Removing the 'import variables' view from the index variables page.
Copy link
Member

@ares ares left a comment

Choose a reason for hiding this comment

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

All of my comments are addressed and all works as expected. I'm not merging since I see red tests, but if that's unrelated, anyone please go ahead and click the green button. Thanks @shiramax this is really a nice improvement! Looking forward to see it on the next community demo :-)

@xprazak2 xprazak2 merged commit 321d9c7 into theforeman:master Feb 17, 2021
@xprazak2
Copy link
Contributor

Thanks everyone!

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