Task fails when using ansible-pull, but works when running remotely?

Hi

We are using EC2, with auto scale. When a new server is built, we install ansible and initiate ansible-pull.

This pulls down the playscript from our repo.

It always gets stuck here:

  • hosts: localhost

  • name: Install composer command: php -c /etc/php-cli.ini /tmp/composer --install-dir=/usr/local/bin --filename=composer --disable-tls creates= /usr/local/bin/composer sudo: yes ignore_errors: yes - name: composer create-project composer: command=create-project working_dir=/home/vhosts/skiddle.com optimize_autoloader=no sudo: yes sudo_user: apache TASK [Install composer] ******************************************************** fatal: [localhost]: FAILED! => {“changed”: true, “cmd”: [“php”, “-c”, “/etc/php-cli.ini”, “/tmp/composer”, “–install-dir=/usr/local/bin”, “–filename =composer”, “–disable-tls”, “/usr/local/bin/composer”], “delta”: “0:00:00.040005”, “end”: “2016-09-23 06:44:38.486817”, “failed”: true, “rc”: 255, “s tart”: “2016-09-23 06:44:38.446812”, “stderr”: “”, “stdout”: “All settings correct for using Composer”, “stdout_lines”: [“All settings correct for usi ng Composer”], “warnings”: }

TASK [composer create-project] ************************************************* fatal: [localhost]: FAILED! => {“changed”: false, “failed”: true, “msg”: “Failed to find required executable composer”}

However, if we then re-run this from our ansible control server (exact same playbook, but ‘hosts’ is changed to remote IP), it always works:

TASK: [install composer] ******************************************************

ok: [10.0.2.153]

TASK: [Install composer] ******************************************************

changed: [10.0.2.153]

TASK: [composer create-project] ***********************************************

ok: [10.0.2.153]

This is causing us issues as itmeans our autoscale builds fail until manual interversion.

Any ideas please?

Ben

Hi,

Did you try to run the second commande using command/shell module instead of composer?

Feel like it fails to detect composer install done in previous task.

M B

Hi

The commands we use are in the original post, so the first installation of composer is done via ‘command’:

  • name: Install composer

command: php -c /etc/php-cli.ini /tmp/composer --install-dir=/usr/local/bin --filename=composer --disable-tls

creates= /usr/local/bin/composer

sudo: yes

ignore_errors: yes

then the create-project is done via the composer module:

  • name: composer create-project

composer: command=create-project working_dir=/home/vhosts/skiddle.com optimize_autoloader=no

sudo: yes

sudo_user: apache

I raised this with Amazon AWS support and they seem to think the issue is down to COMPOSER_HOME not being set correctly?

This message may contain privileged and confidential information intended only for the use of the addressee named above. If you are not the intended recipient you are hereby notified that any use, dissemination, distribution, disclosure or reproduction of this message is strictly prohibited. If you receive this message in error please notify Skiddle Ltd immediately. Whilst Skiddle Ltd operates antivirus software it does not accept responsibility for any damage whatsoever or howsoever that is caused by viruses or infections being passed on. Any views expressed within this message are solely those of the sender and do not necessarily reflect the views of Skiddle Ltd.

Not sure it’s COMPOSER_HOME env variable.

If you execute ansible using shell it may work fine as you indicate the bin path instead of relying on env to detect it.

But I noticed in the module code:

https://github.com/ansible/ansible-modules-extras/blob/aeecd8b09ea95759a0ef16528376f5590badebdf/packaging/language/composer.py

That composer is found using /bin/usr path

here:

composer_path = module.get_bin_path(“composer”, True, [“/usr/local/bin”])

using def get_bin_path(self, arg, required=False, opt_dirs=): in 1723

https://github.com/ansible/ansible/blob/fda933723c8cb60248d41b5691edd86fe0a40807/lib/ansible/module_utils/basic.py

That function is triggering the error there. Hmm I don’t see any refrence to composer_home more over where composer is installed.

M B

Hi

Thanks for this, so how can I solve it, with reference to my install script?

This message may contain privileged and confidential information intended only for the use of the addressee named above. If you are not the intended recipient you are hereby notified that any use, dissemination, distribution, disclosure or reproduction of this message is strictly prohibited. If you receive this message in error please notify Skiddle Ltd immediately. Whilst Skiddle Ltd operates antivirus software it does not accept responsibility for any damage whatsoever or howsoever that is caused by viruses or infections being passed on. Any views expressed within this message are solely those of the sender and do not necessarily reflect the views of Skiddle Ltd.

Execute the first step to install composer then get where composer binary is installed.

Also what if you pick my advice and try to hit composer using shell or command directly instead?

M B