0
votes

I want to modify an Ansible playbook to install a specific version of MongoDB using the enix.mongodb role. According to the docs there is a mongodb_version role variable that I can set to do this. I have tried updating the Ansible playbook, but it doesn't like the way I am specifying it.

    - hosts: development_ec2
      remote_user: ubuntu
      become: yes

      pre_tasks:
       - name: Update all apt packages
         apt: update_cache=yes

      roles:
        - role: geerlingguy.nodejs
        - role: geerlingguy.git
        - role: geerlingguy.docker
        - role: geerlingguy.helm
        - role: enix.mongodb:
                  mongodb__version: 4.0

Where should, and how should I specify it? There is a requirements.yml file where the roles are also specified.

    roles:
      - name: geerlingguy.nodejs
        version: 5.1.1
      - name: geerlingguy.git
        version: 2.1.0
      - name: geerlingguy.docker
        version: 2.7.0
      - name: enix.mongodb
        version: 1.1.0
      - name: geerlingguy.helm
        version: 1.0.0

Below is the error I get when I run the playbook:

    ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from 
    each:
    JSON: No JSON object could be decoded

    Syntax Error while loading YAML.
      mapping values are not allowed in this context

    The error appears to be in '/home/ubuntu/tc-ansible/playbooks/development.yml': line 14,
    column 25, but may be elsewhere in the file depending on the exact syntax problem.

    The offending line appears to be:

        - role: geerlingguy.helm
        - role: enix.mongodb:
                            ^ here

Many thanks.

1

1 Answers

0
votes

For those who could pass by there and that might be still looking for selecting the version with MongoDB you can try this:

  roles:
    - role: enix.mongodb
      mongodb__version: 4.4