Commit c2f22eb2 authored by rgaudin's avatar rgaudin
Browse files

Fixed #158: admin account and password passed as shell variables so it's not visible in logs

parent 31ed54bf
......@@ -36,14 +36,24 @@
- name: Initialize aflatoun and Create an admin user
become: yes
become_user: "{{ username }}"
shell: KALITE_PYTHON={{ aflatoun_env }}/bin/python KALITE_HOME={{ aflatoun_root }} {{ aflatoun_env }}/bin/kalite manage setup --username={{ admin_account }} --password={{ admin_password }} --noinput --no-assessment-items
environment:
KALITE_PYTHON: "{{ aflatoun_env }}/bin/python"
KALITE_HOME: "{{ aflatoun_root }}"
ADMIN_ACCOUNT: "{{ admin_account }}"
ADMIN_PASSWORD: "{{ admin_password }}"
shell: "{{ aflatoun_env }}/bin/kalite manage setup --username=$ADMIN_ACCOUNT --password=$ADMIN_PASSWORD --noinput --no-assessment-items"
when: admin_account is defined
tags: ['setup', 'reconfigure']
- name: Initialize Aflatoun without creating an admin user
become: yes
become_user: "{{ username }}"
shell: KALITE_PYTHON={{ aflatoun_env }}/bin/python KALITE_HOME={{ aflatoun_root }} {{ aflatoun_env }}/bin/kalite manage setup --noinput --no-assessment-items
environment:
KALITE_PYTHON: "{{ aflatoun_env }}/bin/python"
KALITE_HOME: "{{ aflatoun_root }}"
ADMIN_ACCOUNT: "{{ admin_account }}"
ADMIN_PASSWORD: "{{ admin_password }}"
shell: "{{ aflatoun_env }}/bin/kalite manage setup --noinput --no-assessment-items"
when: admin_account is not defined
tags: ['setup', 'reconfigure']
......
......@@ -22,9 +22,9 @@
- name: create password file for clock
environment:
USERNAME: "{{ admin_account }}"
PASSWORD: "{{ admin_password }}"
shell: python -c 'import os ; from random import choice; from crypt import crypt ; from string import ascii_letters, digits ; symbols = ascii_letters + digits ; salt = choice(symbols) + choice(symbols) ; print("{u}:{p}\n".format(u=os.environ.get("USERNAME", "admin"), p=crypt(os.environ.get("PASSWORD", "admin"), salt)))' > /var/www/.admin-passwd
ADMIN_ACCOUNT: "{{ admin_account }}"
ADMIN_PASSWORD: "{{ admin_password }}"
shell: python -c 'import os ; from random import choice; from crypt import crypt ; from string import ascii_letters, digits ; symbols = ascii_letters + digits ; salt = choice(symbols) + choice(symbols) ; print("{u}:{p}\n".format(u=os.environ.get("ADMIN_ACCOUNT", "admin"), p=crypt(os.environ.get("ADMIN_PASSWORD", "admin"), salt)))' > /var/www/.admin-passwd
tags: ['setup', 'reconfigure']
- name: Create /var/www/clock folder
......
......@@ -113,7 +113,9 @@
- name: Check if EduPi super user is installed
become: yes
become_user: "{{ username }}"
shell: /bin/echo "from django.contrib.auth.models import User; print('****{}****'.format(User.objects.filter(username='{{ admin_account }}').count()))" | {{ edupi_env }}/bin/python3 {{ edupi_root }}/manage.py shell --plain
environment:
ADMIN_ACCOUNT: "{{ admin_account }}"
shell: /bin/echo "import os; from django.contrib.auth.models import User; print('****{}****'.format(User.objects.filter(username=os.environ.get('ADMIN_ACCOUNT')).count()))" | {{ edupi_env }}/bin/python3 {{ edupi_root }}/manage.py shell --plain
register: edupi_admin_shell_output
when: admin_account is defined
tags: reconfigure
......@@ -121,7 +123,10 @@
- name: Install EduPi super user
become: yes
become_user: "{{ username }}"
shell: /bin/echo "from django.contrib.auth.models import User; User.objects.create_superuser('{{ admin_account }}', None, '{{ admin_password }}')" | {{ edupi_env }}/bin/python3 {{ edupi_root }}/manage.py shell --plain
environment:
ADMIN_ACCOUNT: "{{ admin_account }}"
ADMIN_PASSWORD: "{{ admin_password }}"
shell: /bin/echo "import os; from django.contrib.auth.models import User; User.objects.create_superuser(os.environ.get('ADMIN_ACCOUNT'), None, os.environ.get('ADMIN_PASSWORD'))" | {{ edupi_env }}/bin/python3 {{ edupi_root }}/manage.py shell --plain
when: admin_account is defined and edupi_admin_shell_output.stdout.split('****')[1]|int == 0
tags: reconfigure
......
......@@ -163,7 +163,9 @@
- name: Check if ideascube super user is installed
become: yes
become_user: "{{ username }}"
command: ideascube shell -c "from ideascube.models import User; print('****{}****'.format(User.objects.filter(serial='{{ admin_account }}').count()))"
environment:
ADMIN_ACCOUNT: "{{ admin_account }}"
command: ideascube shell -c "import os; from ideascube.models import User; print('****{}****'.format(User.objects.filter(serial=os.environ.get('ADMIN_ACCOUNT')).count()))"
register: ideascube_admin_shell_output
when: admin_account is defined
tags: reconfigure
......@@ -171,7 +173,10 @@
- name: Install Ideascube super user
become: yes
become_user: "{{ username }}"
command: ideascube shell -c "from ideascube.models import User; User.objects.create_superuser('{{ admin_account }}', '{{ admin_password }}')"
environment:
ADMIN_ACCOUNT: "{{ admin_account }}"
ADMIN_PASSWORD: "{{ admin_password }}"
command: ideascube shell -c "import os; from ideascube.models import User; User.objects.create_superuser(os.environ.get('ADMIN_ACCOUNT'), os.environ.get('ADMIN_PASSWORD'))"
when: admin_account is defined and ideascube_admin_shell_output.stdout.split('****')[1]|int == 0
tags: reconfigure
......
......@@ -40,7 +40,9 @@
environment:
KALITE_PYTHON: "{{ kalite_env }}/bin/python"
KALITE_HOME: "{{ kalite_root }}"
command: "{{ kalite_env }}/bin/kalite manage setup --username={{ admin_account }} --password={{ admin_password }} --noinput"
ADMIN_ACCOUNT: "{{ admin_account }}"
ADMIN_PASSWORD: "{{ admin_password }}"
command: "{{ kalite_env }}/bin/kalite manage setup --username=$ADMIN_ACCOUNT --password=$ADMIN_PASSWORD --noinput"
when: admin_account is defined
tags:
- setup
......
......@@ -57,7 +57,9 @@
- name: Add admin account to Wikifundi
environment:
WIKIFUNDI_LANG: "{{ item }}"
command: php maintenance/createAndPromote.php --bureaucrat --sysop --force "{{ admin_account }}" "{{ admin_password }}"
ADMIN_ACCOUNT: "{{ admin_account }}"
ADMIN_PASSWORD: "{{ admin_password }}"
command: php maintenance/createAndPromote.php --bureaucrat --sysop --force "$ADMIN_ACCOUNT" "$ADMIN_PASSWORD"
args:
chdir: "{{ mediawiki_root }}"
with_items: "{{ ansible_local.config.wikifundi_languages | default(omit) }}"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment