Hello,
I’m trying to run a playbook which executes a shell script in a remote
instance.
Playbook
---
- name: Test SH
hosts: schedule-dev
become: yes
gather_facts: no
tasks:
- name: Test Shell Ansible
shell: |
sh create_partition_db.sh {{ carrier }}
args:
chdir: /opt/app/automation
executable: /bin/bash
register: output
- name: ouput
debug:
var: output.stdout
The value of the variable {{ carrier }} is sent through the command line:
ansible-playbook -i hosts-dev --extra-vars "carrier=dev"
playbook/step-2.yaml
When I run the playbook I see this error:
fatal: [schedule01-dev]: FAILED! => {"ansible_facts":
{"discovered_interpreter_python": "/usr/bin/python"}, "changed": true,
"cmd": "sh create_partition_db.sh 00CN\n", "delta": "0:00:00.003453",
"end": "2022-02-10 13:27:23.244718", "msg": "non-zero return code", "rc":
2, "start": "2022-02-10 13:27:23.241265", "stderr":
"create_partition_db.sh: 3: create_partition_db.sh: source: not
found\ncreate_partition_db.sh: 4: create_partition_db.sh: source: not
found\ncreate_partition_db.sh: 6: create_partition_db.sh: get_partitions:
not found\ncreate_partition_db.sh: 8: create_partition_db.sh: function: not
found\ncreate_partition_db.sh: 34: create_partition_db.sh: Syntax error:
\"}\" unexpected", "stderr_lines": ["create_partition_db.sh: 3:
create_partition_db.sh: source: not found", "create_partition_db.sh: 4:
create_partition_db.sh: source: not found", "create_partition_db.sh: 6:
create_partition_db.sh: get_partitions: not found",
"create_partition_db.sh: 8: create_partition_db.sh: function: not found",
"create_partition_db.sh: 34: create_partition_db.sh: Syntax error: \"}\"
unexpected"], "stdout": "", "stdout_lines": []}
PLAY RECAP
*****************************************************************************************************************************************
schedule01-dev : ok=0 changed=0 unreachable=0 failed=1
skipped=0 rescued=0 ignored=0
When I run the script from the instance I don’t see any errors, I think it
has to do with the fact that in the script I use the source command to call
other files:
#!/bin/bash
source config-dev.cfg
source functions.sh
Any sugestion?
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAGUDtn%3DHeuyr5kyXPYODJKCvn06d6QhmMne9USsxWxD%3D8O%2B-zw%40mail.gmail.com.