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

166 views
Skip to first unread message

ZillaYT

unread,
Feb 8, 2018, 12:02:56 PM2/8/18
to Ansible Project
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?



Matt Martz

unread,
Feb 8, 2018, 12:08:51 PM2/8/18
to ansible...@googlegroups.com
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



--
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 ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/bbe1771e-cb60-4297-ae81-0cdfe8b07ddd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

ZillaYT

unread,
Feb 8, 2018, 12:50:46 PM2/8/18
to Ansible Project
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.


On Thursday, February 8, 2018 at 12:08:51 PM UTC-5, Matt Martz wrote:
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


On Thu, Feb 8, 2018 at 11:02 AM, ZillaYT <zil...@gmail.com> wrote:
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?



--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

ZillaYT

unread,
Feb 8, 2018, 1:07:57 PM2/8/18
to Ansible Project
I implemented your chdir idea and it worked for me. I like it better anyway. Thanks!


On Thursday, February 8, 2018 at 12:08:51 PM UTC-5, Matt Martz wrote:
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


On Thu, Feb 8, 2018 at 11:02 AM, ZillaYT <zil...@gmail.com> wrote:
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?



--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages