bash - Not able to call a shell script from an ansible playbook -
i trying run 2 shell scripts in background through ansible playbook. playbook running , displaying tasks ran successfully.
but these 2 shell scripts not running. have checked with:
ps -ef | grep sh
these 2 shell scripts required run sage service , trying automate s age server configuration using ansible. here how playbook looks :
--- - hosts: localhost remote_user: root tasks: - name : update system shell : apt-get update - name : install dependencies shell : apt-get install -y m4 build-essential gcc gfortran libssl-dev - name : install python-software-properties shell : apt-get install python-software-properties - name : add sage ppa repo shell : apt-add-repository ppa:aims/sagemath - name : update system shell : apt-get update - name : install dvipng shell : apt-get install dvipng - name : install sage binary shell : apt-get install sagemath-upstream-binary - name : run create sage script shell : . ./create_sagenb & - name : run start sage script shell : . ./start_sage &
this how create_sagenb looks like:
#!/bin/bash # creating sage notebook screen -s "sage_server" sage -c 'notebook(interface="",directory="/root/.sage/sage_notebook.sagenb",port=80,accounts=true)'
this how start_sage looks:
#!/bin/bash # creating sage notebook address=$(hostname --ip-address) screen -s "sage_server" sage -c "notebook(interface=" "'$address'" ",port=80,accounts=true)"
this how invoke screen sessions in ansible:
- name: invoke script command: /usr/bin/screen -d -m sudo -u myuser /usr/local/bin/myuser.sh -i -y
this starts screen session in detached mode (-d , -m combined), use sudo switch specific user run script as.
Comments
Post a Comment