# How to log what a perl script does,called from an Ansible shell module?

**URL:** <https://forum.ansible.com/t/how-to-log-what-a-perl-script-does-called-from-an-ansible-shell-module/26685>\
**Category:** Ansible Project\
**Created:** [February 8, 2018, 5:02pm UTC](https://forum.ansible.com/t/how-to-log-what-a-perl-script-does-called-from-an-ansible-shell-module/26685 "2018-02-08T17:02:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZillaYT](https://avatars.discourse-cdn.com/v4/letter/z/4da419/32.png) [@ZillaYT](https://forum.ansible.com/u/ZillaYT)\
**Post date:** [February 8, 2018, 5:02pm UTC](https://forum.ansible.com/t/how-to-log-what-a-perl-script-does-called-from-an-ansible-shell-module/26685/1 "2018-02-08T17:02:56Z")

</div>

I’m trying to automate installation of gitsyncd and gitmirrord applications via download of the git-syncing.git repository, which installs a /tmp/git-sync/install.pl PERL script. I then run the following:

`

- name: Install git-sync services  
shell: |  
cd /tmp/git-sync  
/usr/local/perl ./install.pl --no-prompt  
environment:  
ENV\_VAR1: env\_value1  
ENV\_VAR2: env\_value2  
register: install\_rc
- debug: var=install\_rc  
`

install\_rc shows nothing. Using -vv option to run my playbook shows nothing either.

I expect the gitsyncd and gitmirrord services to be installed, but they’re not so I’m trying to debug why. I can run the Perl script manually and it works.

Any ideas?

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [February 8, 2018, 5:06pm UTC](https://forum.ansible.com/t/how-to-log-what-a-perl-script-does-called-from-an-ansible-shell-module/26685/2 "2018-02-08T17:06:01Z")

</div>

It is likely because you need to add a `;` after your `cd`. Otherwise I’m guessing it’s being interpreted wrong.

I’d expect `install_rc` to show something though, likely indicating what the problem is.

Also, instead of using `cd`, look at using `chdir` instead:

shell: /usr/local/perl ./[install.pl](http://install.pl) --no-prompt  
args:  
chdir: /tmp/git-sync

---

<div class="post-metadata">

**Author:** ![ZillaYT](https://avatars.discourse-cdn.com/v4/letter/z/4da419/32.png) [@ZillaYT](https://forum.ansible.com/u/ZillaYT)\
**Post date:** [February 8, 2018, 5:50pm UTC](https://forum.ansible.com/t/how-to-log-what-a-perl-script-does-called-from-an-ansible-shell-module/26685/3 "2018-02-08T17:50:46Z")

</div>

No the pipe “|” after the shell command will execute the commands as they are listed, I’ve done it a million times. I will try your suggestion though.

---

<div class="post-metadata">

**Author:** ![ZillaYT](https://avatars.discourse-cdn.com/v4/letter/z/4da419/32.png) [@ZillaYT](https://forum.ansible.com/u/ZillaYT)\
**Post date:** [February 8, 2018, 6:07pm UTC](https://forum.ansible.com/t/how-to-log-what-a-perl-script-does-called-from-an-ansible-shell-module/26685/4 "2018-02-08T18:07:57Z")

</div>

I implemented your chdir idea and it worked for me. I like it better anyway. Thanks!
