-
Notifications
You must be signed in to change notification settings - Fork 897
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
[EmbeddedAnsible] Handle nested playbooks #19089
[EmbeddedAnsible] Handle nested playbooks #19089
Conversation
...models/manageiq/providers/embedded_ansible/automation_manager/configuration_script_source.rb
Outdated
Show resolved
Hide resolved
...models/manageiq/providers/embedded_ansible/automation_manager/configuration_script_source.rb
Outdated
Show resolved
Hide resolved
...models/manageiq/providers/embedded_ansible/automation_manager/configuration_script_source.rb
Outdated
Show resolved
Hide resolved
...models/manageiq/providers/embedded_ansible/automation_manager/configuration_script_source.rb
Outdated
Show resolved
Hide resolved
...models/manageiq/providers/embedded_ansible/automation_manager/configuration_script_source.rb
Outdated
Show resolved
Hide resolved
...models/manageiq/providers/embedded_ansible/automation_manager/configuration_script_source.rb
Outdated
Show resolved
Hide resolved
...s/manageiq/providers/embedded_ansible/automation_manager/configuration_script_source_spec.rb
Outdated
Show resolved
Hide resolved
I'm good with this testing style and FakeAnsibleRepo helper class. It seems like we could even reuse this helper elsewhere. I just don't like the spec + String -> gsub | YAML.parse -> Hash when we can just do spec + Hash. |
e2c80f9
to
c559319
Compare
Still working on trying out some of the other fixes for this PR (supporting master...NickLaMuro:well_at_least_I_thought_it_was_cool And will continue working on the other changes after I break for lunch. |
c559319
to
bd1db5d
Compare
@Fryguy is this ready to go outside of the typo? Also @NickLaMuro can you add the BZ link to at least one commit (or ideally all of them)? |
With the current GitRepository#entries method, the results returned are only the top level files. In this patch a new method, `GitWorktree#blob_list`, was added to list only files (no directory entires) for a given ref (or the current one). Using this in place of `.entries` allows us to find nested playbooks properly. Partially fixes https://bugzilla.redhat.com/show_bug.cgi?id=1734446
433fcf5
to
e07c478
Compare
...models/manageiq/providers/embedded_ansible/automation_manager/configuration_script_source.rb
Outdated
Show resolved
Hide resolved
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.
LGTM...up to you if you care about those 2 comments above.
When syncing playbooks from the GitRepository, make sure we are only pulling in files that match a playbook extension (yaml), and have the "looks of a playbook". Basically, they should include one of the following lines: "- hosts: ..." "- import_playbook: ..." "- include:" (sans-quotes) So if there is a `hosts` line, or we are importing another playbook or role, it is a playbook. Logic for this commit borrowed from AWX: https://github.com/ansible/awx/blob/128fa894/awx/main/utils/ansible.py#L17 https://github.com/ansible/awx/blob/128fa894/awx/main/utils/ansible.py#L39-L66 Partially fixes https://bugzilla.redhat.com/show_bug.cgi?id=1734446
Any file which it's content starts with `"$ANSIBLE_VAULT"` is considered a "playbook" by AWX: https://github.com/ansible/awx/blob/1242ee2b6584f32cbc4267145ee0c0c6bc845049/awx/main/utils/ansible.py#L59 So we are going to replicate that as well... Partially fixes https://bugzilla.redhat.com/show_bug.cgi?id=1734446
Role directories, and others, shouldn't be included with the list of executable playbooks for EmbeddedAnsible, so this filters them out. Logic for `.playbook_dir?` pulled from awx: https://github.com/ansible/awx/blob/128fa894/awx/main/utils/ansible.py#L21-L36 Partially fixes https://bugzilla.redhat.com/show_bug.cgi?id=1734446
Playbooks shouldn't be in hidden directories, or considered when they are a hidden file either. Partially fixes https://bugzilla.redhat.com/show_bug.cgi?id=1734446
e07c478
to
efd8050
Compare
Checked commits NickLaMuro/manageiq@652105e~...efd8050 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 |
…d-playbooks [EmbeddedAnsible] Handle nested playbooks (cherry picked from commit 1d47fd7) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1734446
Ivanchuk backport details:
|
@NickLaMuro Travis is failing in
|
As mentioned by:
https://bugzilla.redhat.com/show_bug.cgi?id=1734446
We currently don't support nested playbooks with
EmbeddedAnsible
usingAnsibleRunner
. This was an oversight that Ansible Tower /awx
gave us for free, so this implements what those two were doing in the past.Of note, we are saving the full relative file path for the name now in the ConfigurationScriptPayload record. This is what was done previously when doing a refresh, but worth noting.
Links
awx
links:valid_playbook_re
skip_directory
could_be_playbook
Steps for Testing/QA
Need to test this with an actual playbook run still...