1

我的 ansible 角色之一调用 rhsm_repository 模块:

- name: Enable Red Hat Software Collections repo
  rhsm_repository:
    name: rhel-server-rhscl-7-rpms
  when: ( ansible_os_family == "RedHat" and ansible_facts['distribution_major_version'] == "7")

我正在向角色添加分子测试,但收敛步骤无法启用存储库:

TASK [mariadb : Enable Red Hat Software Collections repo]
*********************************************************
fatal: [rhel7]: FAILED! => {"changed": false, "msg": "rhel-server-rhscl-7-rpms is not a valid repository ID", "results": ["rhel-server-rhscl-7-rpms is not a valid repository ID"]}

在容器中运行subscription-manager命令也会失败。 subscription-manager是此模块 AFAICT 使用的命令。

[root@rhel7 /]# subscription-manager status
subscription-manager is disabled when running inside a container. Please refer to your host system for subscription management.

我的主机是 RHEL8,所以即使我愿意,我也无法启用 repo。但是使用分子的想法是允许测试各种发行版,因此无论如何这似乎都是错误的方法。

如何在容器中rhsm_repository使用分子测试模块?podman

我的分子的platform定义是:

  - name: rhel7                                    
    image: registry.access.redhat.com/ubi7/ubi-init
    command: "/usr/sbin/init"                      
    tmpfs:                                         
      - /run                                       
      - /tmp                                       
    pre_build_image: true                          
4

1 回答 1

1

这显然不能在容器内进行测试,所以忘记这个容器的 podman 或 docker。

您将不得不使用molecule驱动程序插件,例如(非详尽列表)molecules-vmwaremolecules-vagrantmolecules-openstack ... 这将让您启动一个运行强制操作系统的实际虚拟机来使用和测试该模块。

有关分子的(主要是...)社区插件列表,请参阅ansible-community 的 github 上与“分子”匹配的项目列表

于 2022-01-18T17:41:51.457 回答