Question

When I try to use the Ansible's Composer module and paste the following task into my playbook.yml file I get an error.

playbook.yml

- name: Composer Install Site Dependencies
  composer: command=install working_dir=/var/www/html

Error:

ERROR: composer is not a legal parameter in an Ansible task or handler
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

After some investigation I ran "anisble-doc --list" on the command line to see the available modules and "composer" is not listed. I am running Ansible version 1.5.4, do I have to add it separately?

Was it helpful?

Solution

As @user272735 indicated in the comments, this is an unreleased module- it's slated for the 1.6 release, which is under "active development". (admittedly it was originally slated for 1.4) You have a couple of options:

  • install ansible from the bleeding edge. See "running from source". (obviously, this is scary)
  • ninja-patch the file into your locally installed tree. (obviously, this is scary)
  • add the file into your local Ansible repo.

As "developing modules" says, a fourth option is to specify your library path via ANSIBLE_LIBRARY or --module-path. HOWEVER, this overrides your global library/module path. That isn't what you want to do unless you are providing every module.

adding into your repo

I'm assuming your repo is named "ansible" and is set up properly, like this:

ansible/ ansible/roles/ ansible/group_vars/

In that case, simply add a library directory at the top (the 'best practices' discusses this but not in the expected section):

ansible/ ansible/roles/ ansible/group_vars/ ansible/library/

Inside there, add the composer file in there. That makes its path/file the following:

ansible/library/composer

Note it is not composer.py or anything else. Also, it doesn't seem to need the +x bit, so no fussy worries there.

Once you do that, you can run Ansible commands as you'd expect. The composer module will simply be there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top