Skip to content

Commit

Permalink
Optionally allow user provisioning failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Shapiro authored and pomegranited committed Nov 23, 2016
1 parent 08486dd commit 42b2816
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions playbooks/edx-east/manage_edxapp_users_and_groups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,20 @@
vars:
python_path: /edx/bin/python.edxapp
manage_path: /edx/bin/manage.edxapp
ignore_user_creation_errors: no
deployment_settings: "{{ EDXAPP_SETTINGS | default('aws') }}"
tasks:
- name: Manage groups
shell: >
{{ python_path }} {{ manage_path }} lms --settings=aws
{{ python_path }} {{ manage_path }} lms --settings={{ deployment_settings }}
manage_group {{ item.name | quote }}
{% if item.get('permissions', []) | length %}--permissions {{ item.permissions | default([]) | map('quote') | join(' ') }}{% endif %}
{% if item.get('remove') %}--remove{% endif %}
with_items: django_groups

- name: Manage users
shell: >
{{ python_path }} {{ manage_path }} lms --settings=aws
{{ python_path }} {{ manage_path }} lms --settings={{ deployment_settings }}
manage_user {{ item.username | quote }} {{ item.email | quote }}
{% if item.get('groups', []) | length %}--groups {{ item.groups | default([]) | map('quote') | join(' ') }}{% endif %}
{% if item.get('remove') %}--remove{% endif %}
Expand All @@ -97,3 +99,17 @@
{% if item.get('unusable_password') %}--unusable-password{% endif %}
{% if item.get('initial_password_hash') %}--initial-password-hash {{ item.initial_password_hash | quote }}{% endif %}
with_items: django_users
ignore_errors: yes
register: manage_users_result

# Note that we're doing something a bit odd with this play. Unfortunately, it appears that the
# version of Ansible we're using (1.9.3-edx as of October 2016) does not support variable statements
# in the `ignore_errors` field. As a result, we're capturing the result of that play, and using it
# to determine if we execute an explicit `fail` play.

- name: "Managing users fails on error unless {{ ignore_user_creation_errors }}"
fail: item
when:
- item|failed
- not ignore_user_creation_errors | bool
with_items: manage_users_result.results

0 comments on commit 42b2816

Please sign in to comment.