I want to use the module mongodb_replication defined in  greendayonfire.mongodb role. 
I know I can use the module in my tasks after applying the role in the same play. But I don't want to apply the role (and execute all it's tasks). Is there any way to get to "include" the role without executing the tasks?
I want to have it like this
---
- hosts: mongodb-nodes
  become: true
  roles:
    - base
    - greendayonfire.mongodb
  vars:
    mongodb_package: mongodb-org
    mongodb_version: "3.2"
    mongodb_force_wait_for_port: true
    mongodb_net_bindip: 0.0.0.0
    mongodb_net_http_enabled: true
    mongodb_replication_replset: "rs1"
    mongodb_storage_prealloc: false
- hosts: mongodb-0
      tasks:
        - mongodb_replication: replica_set=rs1 host_name=item state=present
          with_items:
            - mongodb-0
            - mongodb-1
            - mongodb-2
where the second play is the one that runs the  mongodb_replication module (only in the node mongodb-0). Right now it can't find the module. 
I guess can I copy the module out of the role into my playbook but I will be cleaner if I could just import the module from the role (which I don't want to edit)
I found that it's possible to load the role without executing the task by using the when: false clause when referring to the role. This loads the vars, defaults, modules, etc. 
- hosts: mongodb-0
      roles:
        - role: greendayonfire.mongodb
          when: false
      tasks:
        - mongodb_replication: replica_set=rs1 host_name=item state=present
          with_items:
            - mongodb-0
            - mongodb-1
            - mongodb-2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With