Commit 00cb08de authored by Matthieu Gautier's avatar Matthieu Gautier
Browse files

Pass the right argument to ansible to create the super user.

parent 4b0e09b7
import json
# machine must provide write_file and exec_cmd functions
def run(machine, name, timezone, wifi_pwd, edupi, wikifundi, aflatoun, kalite, zim_install, ansiblecube_path):
def run(machine, name, timezone, wifi_pwd, edupi, wikifundi, aflatoun, kalite, zim_install, ansiblecube_path, admin_account):
machine.exec_cmd("sudo apt-get update")
machine.exec_cmd("sudo apt-get install -y python-pip python-yaml python-jinja2 python-httplib2 python-paramiko python-pkg-resources libffi-dev libssl-dev git lsb-release")
machine.exec_cmd("sudo pip install ansible==2.2.0")
......@@ -54,6 +54,8 @@ def run(machine, name, timezone, wifi_pwd, edupi, wikifundi, aflatoun, kalite, z
extra_vars += " git_branch=oneUpdateFile0.3"
extra_vars += " own_config_file=True"
extra_vars += " managed_by_bsf=False"
if admin_account is not None:
extra_vars += " admin_account='{login}' admin_password='{pwd}'"
ansible_args = "--inventory hosts"
ansible_args += " --tags master,custom"
......@@ -62,4 +64,10 @@ def run(machine, name, timezone, wifi_pwd, edupi, wikifundi, aflatoun, kalite, z
ansible_pull_cmd = "sudo sh -c 'cd {} && /usr/local/bin/ansible-playbook {}'".format(ansiblecube_path, ansible_args)
machine.exec_cmd(ansible_pull_cmd)
if admin_account is not None:
run_ansible_pull_cmd = ansible_pull_cmd.format(**admin_account)
displayed_ansible_pull_cmd = ansible_pull_cmd.format(login='****', pwd='****')
else:
run_ansible_pull_cmd = displayed_ansible_pull_cmd = ansible_pull_cmd
machine.exec_cmd(run_ansible_pull_cmd, displayed_ansible_pull_cmd)
......@@ -86,7 +86,8 @@ def run_installation(name, timezone, language, wifi_pwd, admin_account, kalite,
edupi=edupi,
aflatoun=aflatoun,
ansiblecube_path=ansiblecube_emulation_path,
zim_install=zim_install)
zim_install=zim_install,
admin_account=admin_account)
# Write ideascube configuration
with open(data.pibox_ideascube_conf, "r") as f:
......@@ -170,10 +171,6 @@ def run_installation(name, timezone, language, wifi_pwd, admin_account, kalite,
emulation.put_file(css, css_emulation_path)
emulation.exec_cmd("sudo chown ideascube:ideascube {}".format(css_emulation_path))
if admin_account is not None:
logger.std("create super user")
emulation.exec_cmd("sudo ideascube createsuperuser --serial '{}' <<< '{}'".format(admin_account["login"], admin_account["pwd"]), show_command=False)
# Write image to SD Card
if sd_card:
emulator.copy_image(sd_card)
......
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