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

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?

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 --no-prompt
args:
chdir: /tmp/git-sync

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.

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