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
Create an ansible script for running populate_model. #3195
Conversation
{{ python_path }} {{ manage_path }} lms --settings=aws | ||
populate_model -f {{ file | quote }} -u {{ user }} | ||
register: command_result | ||
failed_when: "'Import complete' not in command_result.stdout" |
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 tested that this is working, but is there a way to print out command_result.stdout when it succeeds? It would be nice to know how many entries were created.
The management command prints "Import complete, {0} new entries created").format(created_entries))
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.
You can use the debug module to print arbitrary text.
I think that rather than determining failure from checking output, it'd be better to rely on the exit code of the command (which is ansible's default behavior). If the management command doesn't exit with non-zero exit code on failure, that should be fixed.
Also, it'd be good to use changed_when
to let ansible show an "OK - unchanged" status when "new entries created" is 0.
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.
Ah, I got confused about changed_when vs. failed_when. I will delete failed_when and add changed_when.
I was able to run this on a sandbox and populate 2 different configuration models, using JSON files from https://github.com/edx/xblock-configuration. |
Initially used for xblock configurations, but can be used for any ConfigurationModel.
cfacfbe
to
24bb55f
Compare
@maxrothman Updates are made. This PR failed due to timeout the last time it ran; I assume this has nothing to do with my new file, but let me know if I'm wrong! |
Double check that on failures it doesn't report "changed" because of the You can ignore the timing-out tests. They don't test this playbook. |
@maxrothman It does not report "changed" when it fails: |
👍 |
Merging per @maxrothman comment about timeout failure not being a concern. |
Initially used for xblock configurations, but can be used for any
ConfigurationModel.
Please review @maxrothman