跳到内容

角色名称

此规则检查角色名称,以确保它们符合要求。

角色名称必须只包含小写字母数字字符和下划线 _ 字符。角色名称还必须以字母字符开头。

有关更多信息,请参阅 Ansible 文档中的roles 目录主题。

role-name[path] 消息告诉您在导入角色时避免使用路径。您应该只依赖 Ansible 查找角色并使用完全限定名称引用它们的能力。

有问题的代码

---
- name: Example playbook
  hosts: localhost
  roles:
    - 1myrole # <- Does not start with an alphabetic character.
    - myrole2[*^ # <- Contains invalid special characters.
    - myRole_3 # <- Contains uppercase alphabetic characters.

正确的代码

---
- name: Example playbook
  hosts: localhost
  roles:
    - myrole1 # <- Starts with an alphabetic character.
    - myrole2 # <- Contains only alphanumeric characters.
    - myrole_3 # <- Contains only lowercase alphabetic characters.