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

Create an ansible script for running populate_model. #3195

Merged
merged 1 commit into from Jun 29, 2016

Conversation

cahrens
Copy link

@cahrens cahrens commented Jun 29, 2016

Initially used for xblock configurations, but can be used for any
ConfigurationModel.

Please review @maxrothman

{{ 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"
Copy link
Author

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))

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 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.

Copy link
Author

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.

@cahrens
Copy link
Author

cahrens commented Jun 29, 2016

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.
@cahrens cahrens force-pushed the christina/configuration_model_playbook branch from cfacfbe to 24bb55f Compare June 29, 2016 19:25
@cahrens
Copy link
Author

cahrens commented Jun 29, 2016

@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!

@maxrothman
Copy link
Contributor

maxrothman commented Jun 29, 2016

Double check that on failures it doesn't report "changed" because of the changed_when, then I'm 👍

You can ignore the timing-out tests. They don't test this playbook.

@cahrens
Copy link
Author

cahrens commented Jun 29, 2016

@maxrothman It does not report "changed" when it fails:

image

@maxrothman
Copy link
Contributor

👍

@cahrens
Copy link
Author

cahrens commented Jun 29, 2016

Merging per @maxrothman comment about timeout failure not being a concern.

@cahrens cahrens merged commit 7c55c68 into master Jun 29, 2016
@jdmulloy jdmulloy deleted the christina/configuration_model_playbook branch June 21, 2018 01:48
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.

None yet

2 participants