简体   繁体   中英

File created by ansible script module not present after running against remote node

I'm setting up some server in AWS, and want to use Ansible to do some shell in remote nodes. I write playbook as follow

- hosts: remote-nodes
  tasks:
      - name: Execute script
        script: /home/ubuntu/FastBFT_ethereum/experiment/a.sh

remote nodes a.sh as follow

#!/usr/bin/env bash
echo "test">> test.txt
python writejson.py

But when I check the test.text, I find it doesn't work in remote nodes.help me please.

Assuming that you want test.txt to be created in the experiment directory, this should be changed to something like:

- hosts: remote-nodes
  tasks:
  - name: Execute script
    script: /home/ubuntu/FastBFT_ethereum/experiment/a.sh
    args:
      chdir: /home/ubuntu/FastBFT_ethereum/experiment

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM