running ansible-galaxy install in a playbook

Running ansible 2.1.0

I’m trying to run ansible-galaxy install in a play book to download the needed roles in an automated fashion to my local machine and it seems to skip the task.

So far I have tried:

  • hosts: localhost
    connection: local
    tasks:

  • name: install required roles
    command: ansible-galaxy install -r requirements.yml -p roles

  • hosts: localhost
    connection: local
    tasks:

  • name: install required roles
    local_action: command ansible-galaxy install -r requirements.yml -p roles

  • hosts: localhost
    connection: local
    tasks:

  • name: install required roles
    command: ansible-galaxy install -r requirements.yml -p roles
    delegate_to: localhost

There is nothing that is being outputted saying an error or its skipped it just doesn’t run and goes to the next part of the playbook, which is:

  • hosts: localhost
    connection: local
    gather_facts: True
    roles:
  • ec2instance

Which then fails because it can’t find the role.

Any help is appreciated.