-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[chore] Update project_update playbook to be compliant with ansible-lint #13526
[chore] Update project_update playbook to be compliant with ansible-lint #13526
Conversation
e786ce2
to
cdbf20d
Compare
I don't see ansible-lint in any of our checks? |
awx/playbooks/project_update.yml
Outdated
- name: delete project directory before update | ||
command: "find -delete" # volume mounted, cannot delete folder itself | ||
- name: Delete project directory before update | ||
ansible.builtin.command: "find -delete" # volume mounted, cannot delete folder itself |
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.
is this sufficiently version-compatible? A lot of people are surely using 2.9, which has collections, but not sure if this works.
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.
we run project update in controlplane ee so we should be fine
in the latest awx-ee (stream9 based) we are running 2.14.2
awx/playbooks/project_update.yml
Outdated
args: | ||
chdir: "{{ project_path }}" | ||
tags: | ||
- delete | ||
changed_when: false |
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.
This isn't really correct. When the project folder contents are deleted, something is changed. If you're giving a value to changed_when, true
would be a better shot at being correct. What if you gave changed=true and wrote another expression to skip the task where there are no contents inside the folder? That is the only way I can see making this correct.
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.
Why hardcode changed_when
at all, as opposed to making it accurate? You can use find -delete -print
, register the task output, and do something like changed_when: reg.stdout != "."
(that might not be exact, but that general idea)
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.
i changed it to true is that good enough
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.
i changed it to true is that good enough
It's not accurate:
[rick@fedora asdf]$ find . -delete -print
.
[rick@fedora asdf]$ find . -delete -print
.
Why should changed be true the second time?
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.
I'm worried about performance implications of any version of -print
because it prints every file. If this is recorded in the event data (as stdout) then that is the exact thing we got ourselves in trouble with when we used the Ansible built-in module (I think file) for this purpose. Once you get to "large" repo sizes (realistically, any major project out there) then the sheer number of files becomes a problem, particularly when the .git folder is included. This kind of situation would make the page un-navigable in the UI and cause a mess of other problems.
You know, we don't even really need to make this determination in the playbook. Since the folder must be on the control node, we could determine in the task code whether there is anything to be deleted. You could even pass in a variable just for the somewhat ridiculous purpose of setting the changed status. This would be preferable to risking performance regressions.
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.
If this is recorded in the event data (as stdout) then that is the exact thing we got ourselves in trouble with when we used the Ansible built-in module (I think file) for this purpose.
Okay, what about:
shell: find . -delete -print | head -2
register: reg
changed_when: reg.stdout_lines | length > 1
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, that should be fine, because the bash commands will behave extremely efficiently in this case.
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.
@TheRealHaoLiu if you go this route, note you'll need shell and not command
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.
updated as per @relrod's suggestion please re-review
cdbf20d
to
5364fb4
Compare
5364fb4
to
a985784
Compare
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.
Looks fine to me, but I'd like to see the blank lines between tasks preserved. I think they make enough of a difference when mentally/quickly parsing yaml.
register: results | ||
|
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.
Can you preserve these blank lines between tasks? They make mentally parsing the YAML easier.
I wrote an integration test for the "changed" status. The test basically assures the following:
This requires having exactly 1 control node in the system. If this is working, then I'd like to merge this and merge the test. |
a985784
to
019e6a5
Compare
SUMMARY
periodic therapeutic yak shaving...
TODO:
Commands should not change things if nothing needs doing.
File permissions unset or incorrect.
File permissions unset or incorrect.
File permissions unset or incorrect.
ISSUE TYPE
COMPONENT NAME
AWX VERSION
ADDITIONAL INFORMATION