我正在通过ansible-playbook自动化安装sage。在这个过程中,我需要运行两个shell脚本。 以下是第一个shell脚本的样子:
#!/bin/bash
# Creating Sage notebook
dir="/root/.sage/sage_notebook.sagenb"
screen -S "Sage_Server" sage -c 'notebook(interface="", directory=$dir, port=80, accounts=true)'
这是第二个shell脚本的代码:
#!/bin/bash
# Creating Sage inotebook
address=$(hostname --ip-address)
sage -c "inotebook(interface=" "'$address'" ",port=80,accounts=true)"
以下是playbook的样式:
---
- hosts: localhost
remote_user: root
tasks:
- name : update system
apt : update_cache=yes
- name : install m4
apt : name=m4 state=present
- name : install build-essential
apt : name=build-essential state=present
- name : install gcc
apt : name=gcc state=present
- name : install gfortran
apt : name=gfortran state=present
- name : install libssl-dev
apt : name=libssl-dev state=present
- name : install python-software-properties
apt : name=python-software-properties state=present
- name : add sage ppa repo
apt_repository: repo='ppa:aims/sagemath'
- name : update system
apt : update_cache=yes
- name : install dvipng
apt : name=dvipng state=present
- name : install sage binary
apt : name=sagemath-upstream-binary state=present
- name : invoke create_sagenb script
command: /usr/bin/screen -d -m sudo /root/databases-and-datamining-iiith/python-scripts/create_sagenb -i -y
- name : invoke start_sage script
command: /usr/bin/screen -d -m sudo /root/databases-and-datamining-iiith/python-scripts/start_sage -i -y
现在当我运行第一个脚本时,它会要求输入一个新的sage密码,这个密码可以是任何东西。但是我无法从playbook中传递该密码。 即使如此,如果我这样做
ps -ef | grep sh
我看到脚本在运行,但是Sage服务没有启动。它需要密码才能启动服务。
请问有人可以告诉我如何通过命令将密码作为参数传递给shell脚本吗?