I suspect this is a common problem - but despite my efforts to troubleshoot and debug this on my own I havent had much luck.
I have a shell script that I create through Ansible’s template module which I then wish to run use the shell module. If I let the template task run - and then manually run the shell script - things work as expected. When I use Ansible instead to run the exact same shell script through a task - the task says its runs - but the script doesnt actually do anything. The tasks look like this and are part of a role that Im building…
-
name: Template the host VM population script
template:
mode: 0755
src: host_vm_population_script
dest: “{{ build_location }}scripts/populate_vm.sh” -
name: Call the VM population script
shell: “{{ build_location }}scripts/populate_vm.sh”
I’ve tried everything I can think of. The Ansible user on the target host is root. I’ve…
-Changed the permission to wide open on the shell script
-Put the full path to all executables in the shell script
-Tried running it through different shells (as well as made sure it was using the same as the current user Im testing with)
Im at a bit of a loss here. The shell script is using guestfish to modify a VM image and copy/edit some files in it. Like I said - it works great when run manually. On a more interesting note (not sure how related this is) but this worked with a previous iteration of the VM image perfectly. I then shrank the size of the QCOW2 image by compressing it and freeing up empty space in the image size. While this seems like the obvious change that broke this task - I cant’ sort out why it would have and if it did - then why does it work just fine when I run it manually?
Here’s a snippet from the shell script…
/usr/bin/guestmount -a {{ build_location }}vm_files/vm.qcow2 -m /dev/test1-vg/root --rw /mnt/vm
/bin/mkdir -p /mnt/vm/opt
/bin/mkdir -p /mnt/vm/opt/scripts
So I guess what Im hoping someone can help me with is further troubleshooting the Ansible task to figure out why its breaking. Running it with -vvv
only shows me that the task completes. I’ve also tried modify the shell command to dump standard error and standard output to a log file and I’ve gotten nothing useful out of that either. Are there any other ways to get some more output here from the task run to see what it’s doing?
Any input would be appreciated.
Thanks!