gpt4 book ai didi

python - 分子在运行基本测试时提示 "[703] Should change default metadata: description"

转载 作者:行者123 更新时间:2023-12-01 07:15:14 25 4
gpt4 key购买 nike

我无法运行 molecule test 命令,因为它抛出以下错误,而我可以运行单个命令而不会出现任何错误(下面还提供了 --debug o/p)

[701] Role info should contain platforms
/root/.config/pip/molecule-testing/meta/main.yml:1
{'meta/main.yml': {'__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company': u'your company (optional)', u'galaxy_tags': [], '__line__': 2, '__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 1}}

[703] Should change default metadata: author
/root/.config/pip/molecule-testing/meta/main.yml:1
{'meta/main.yml': {'__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company': u'your company (optional)', u'galaxy_tags': [], '__line__': 2, '__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 1}}

[703] Should change default metadata: description
/root/.config/pip/molecule-testing/meta/main.yml:1
{'meta/main.yml': {'__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company': u'your company (optional)', u'galaxy_tags': [], '__line__': 2, '__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 1}}

[703] Should change default metadata: company
/root/.config/pip/molecule-testing/meta/main.yml:1...

但是,如果我运行下面的命令,它就可以正常工作。那么,谁能指出为什么整个测试失败,我该怎么办?

  1. 分子创建
  2. 分子列表
Validation completed successfully.
Instance Name Driver Name Provisioner Name Scenario Name Created Converged
--------------- ------------- ------------------ --------------- --------- -----------
instance docker ansible default true false

  • 分子会聚
  • Validation completed successfully.
    --> Test matrix

    └── default
    ├── dependency
    ├── create
    ├── prepare
    └── converge

    --> Scenario: 'default'
    --> Action: 'dependency'
    Skipping, missing the requirements file.
    --> Scenario: 'default'
    --> Action: 'create'
    Skipping, instances already created.
    --> Scenario: 'default'
    --> Action: 'prepare'
    Skipping, prepare playbook not configured.
    --> Scenario: 'default'
    --> Action: 'converge'

    PLAY [Converge] ****************************************************************

    TASK [Gathering Facts] *********************************************************
    ok: [instance]

    TASK [molecule-testing : Molecule Hello World!] ********************************
    ok: [instance] => {
    "msg": "Hello, World!"
    }

    PLAY RECAP *********************************************************************
    instance : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

  • 分子列表
  •  molecule list
    --> Validating schema /root/.config/pip/molecule-testing/molecule/default/molecule.yml.
    Validation completed successfully.
    Instance Name Driver Name Provisioner Name Scenario Name Created Converged
    --------------- ------------- ------------------ --------------- --------- -----------
    instance docker ansible default true true
  • 分子破坏
  • 分子列表
  • --> Validating schema /root/.config/pip/molecule-testing/molecule/default/molecule.yml.
    Validation completed successfully.
    Instance Name Driver Name Provisioner Name Scenario Name Created Converged
    --------------- ------------- ------------------ --------------- --------- -----------
    instance docker ansible default true false

    文件夹结构如下

    .
    ├── defaults
    │   └── main.yml
    ├── handlers
    │   └── main.yml
    ├── meta
    │   └── main.yml
    ├── molecule
    │   └── default
    │   ├── Dockerfile.j2
    │   ├── INSTALL.rst
    │   ├── molecule.yml
    │   ├── playbook.yml
    │   └── tests
    │   ├── test_default.py
    │   └── test_default.pyc
    ├── README.md
    ├── tasks
    │   └── main.yml
    └── vars
    └── main.yml

    molecule.yml 文件是

    ---
    dependency:
    name: galaxy
    driver:
    name: docker
    lint:
    name: yamllint
    platforms:
    - name: instance
    image: centos:7
    privileged: true
    command: /sbin/init
    volume_mounts:
    - "/sys/fs/cgroup:/sys/fs/cgroup:ro"
    provisioner:
    name: ansible
    lint:
    name: ansible-lint
    scenario:
    name: default

    任务\main.yml -->

    ---
    # tasks file for molecule-testing
    - name: Molecule Hello World!
    debug:
    msg: Hello, World!

    分子和ansible的版本如下

    molecule --version
    molecule, version 2.22

    ansible --version
    ansible 2.8.4
    config file = None
    configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
    ansible python module location = /root/molecule_ansible2.7/lib/python2.7/site-packages/ansible
    executable location = /root/molecule_ansible2.7/bin/ansible
    python version = 2.7.5 (default, Jun 11 2019, 14:33:56) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]

    docker 镜像

    docker images
    REPOSITORY TAG IMAGE ID CREATED SIZE
    docker.io/centos 7 67fa590cfc1c 4 weeks ago 202 MB

    molecule --debug test 的示例输出为


    DEBUG: COMMAND
    /root/molecule_ansible2.7/bin/ansible-lint -v --exclude=/root/.cache/molecule/molecule-testing/default /root/.config/pip/molecule-testing/molecule/default/playbook.yml

    Examining /root/.config/pip/molecule-testing/molecule/default/playbook.yml of type playbook
    Examining /root/.config/pip/molecule-testing/tasks/main.yml of type tasks
    Examining /root/.config/pip/molecule-testing/handlers/main.yml of type handlers
    Examining /root/.config/pip/molecule-testing/meta/main.yml of type meta
    [701] Role info should contain platforms
    /root/.config/pip/molecule-testing/meta/main.yml:1
    {'meta/main.yml': {'__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company': u'your company (optional)', u'galaxy_tags': [], '__line__': 2, '__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 1}}

    [703] Should change default metadata: author
    /root/.config/pip/molecule-testing/meta/main.yml:1
    {'meta/main.yml': {'__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company': u'your company (optional)', u'galaxy_tags': [], '__line__': 2, '__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 1}}

    [703] Should change default metadata: description
    /root/.config/pip/molecule-testing/meta/main.yml:1
    {'meta/main.yml': {'__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company': u'your company (optional)', u'galaxy_tags': [], '__line__': 2, '__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 1}}

    [703] Should change default metadata: company
    /root/.config/pip/molecule-testing/meta/main.yml:1
    {'meta/main.yml': {'__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company': u'your company (optional)', u'galaxy_tags': [], '__line__': 2, '__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 1}}

    [703] Should change default metadata: license
    /root/.config/pip/molecule-testing/meta/main.yml:1
    {'meta/main.yml': {'__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company': u'your company (optional)', u'galaxy_tags': [], '__line__': 2, '__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 1}}

    An error occurred during the test sequence action: 'lint'. Cleaning up.

    最佳答案

    TLDR;

    这些是 ansible-lint 报告的错误/良好实践,您应该修复。您只需启动 molecule lint 即可单独运行 lint 阶段。

    根据当前的输出,您只需在角色的 meta/main.yml 中添加一些信息。

    到底发生了什么

    每个分子命令(例如融合创建销毁测试 ...)针对您的角色启动一系列步骤(序列)。您可以在命令的输出中看到步骤列表,如以下示例所示,取自您运行 converge 时的问题:

    └── default
    ├── dependency
    ├── create
    ├── prepare
    └── converge

    这些序列是默认配置的,但可以在场景目录中的 molecule.yml 中进行自定义。你可以看看customization on an open source role I maintain如果您对该主题感兴趣。

    默认情况下,converge 序列不包含 lint 阶段。因此,您可以运行测试剧本,而无需验证所有内容。

    另一方面,测试序列包括以下所有步骤:

    └── default
    ├── lint
    ├── dependency
    ├── cleanup
    ├── destroy
    ├── syntax
    ├── create
    ├── prepare
    ├── converge
    ├── idempotence
    ├── side_effect
    ├── verify
    ├── cleanup
    └── destroy

    如您所见,第一个是 lint,它(再次默认)应该运行 yamllint在所有 yml 文件上,后跟 ansible-lint关于您的角色和测试剧本,最后 flake8在你的 python 文件上( testinfra 测试、自定义模块、自定义插件过滤器...)。

    您的完整测试失败,因为最佳实践检查器 ansible-lint 正在报告您应该修复的问题。据我所知,它们非常琐碎,应该在您的 meta/main.yml

    中删除几行

    关于python - 分子在运行基本测试时提示 "[703] Should change default metadata: description",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58010187/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com