-
Notifications
You must be signed in to change notification settings - Fork 896
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
Ansible refresh inventory #13807
Ansible refresh inventory #13807
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ def parse | |
inventory_groups | ||
configured_systems | ||
configuration_scripts | ||
configuration_script_sources | ||
end | ||
|
||
def inventory_groups | ||
|
@@ -32,4 +33,20 @@ def configuration_scripts | |
o[:inventory_root_group] = target.inventory_groups.lazy_find(i.inventory_id.to_s) | ||
end | ||
end | ||
|
||
def configuration_script_sources | ||
collector.projects.each do |i| | ||
o = target.configuration_script_sources.find_or_build(i.id.to_s) | ||
o[:description] = i.description | ||
o[:name] = i.name | ||
|
||
i.playbooks.each do |playbook_name| | ||
# FIXME: its not really nice how I have to build a manager_ref / uuid here | ||
p = target.playbooks.find_or_build("#{i.id}__#{playbook_name}") | ||
# FIXME: how about just adding `o` - configuration_script_source here? | ||
p[:configuration_script_source] = target.configuration_script_sources.lazy_find(i.id.to_s) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if it's always 'o', you can just put it there :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oooh There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hehe' :-) |
||
p[:name] = playbook_name | ||
end | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the manager_ref is "#{i.id}__#{playbook_name}" ?
it might be better not to change manager_ref, since you will need to parse it when talking to provider? E.g. doing some operation with playbook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the playbook is just a name. So to make it really uniq, I need to scope it under
project_id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, so it's better to have in unchanged in our db, so e.g. it you want to delete a playbook you know you need playbook.manager_ref and playbook.configuration_script_source.manager_ref
So you don't need to do a playbook.manager_ref.split("__")
I was proposing another key for pure unique check in #13806
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what should I set it to then? If I do this
the tests fail, because there are duplicate playbook names across projects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this case would need
find_or_build
to take in more than 1 attribute. Are there other use cases that need this too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we need to add the find_or_build_by, as we talked in the other PR
In AWS, I have several entities with unique key.size >= 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great!