我想修改 Ansible 剧本以使用 enix.mongodb 角色安装特定版本的 MongoDB。根据文档mongodb_version
,我可以设置一个角色变量来执行此操作。我已经尝试更新 Ansible 剧本,但它不喜欢我指定它的方式。
- 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
应该在哪里,我应该如何指定它?有一个 requirements.yml 文件,其中还指定了角色。
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
以下是我运行剧本时遇到的错误:
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
非常感谢。