ansible / molecule

Molecule aids in the development and testing of Ansible content: collections, playbooks and roles
https://ansible.readthedocs.io/projects/molecule/
MIT License
3.89k stars 665 forks source link

Molecule fails on Fedora 26 docker container - `dnf makecache fast` doesn't work anymore #925

Closed giovtorres closed 7 years ago

giovtorres commented 7 years ago

molecule version: 1.23.1

molecule file:

---
docker:
  containers:
    - name: fedora26
      image: fedora
      image_version: 26
verifier:
  name: testinfra

Error when creating image:

--> Creating Ansible compatible image of fedora:26 ...
--> Building ansible compatible image...
    Step 1/8 : FROM fedora:26
     ---> c33114392d5e
    Step 2/8 : RUN /bin/sh -c 'if [ -x "$(command -v apt-get)" ]; then apt-get update && apt-get install -y python sudo bash; fi'
     ---> Using cache
     ---> 6ab7733bee52
    Step 3/8 : RUN /bin/sh -c 'if [ -x "$(command -v yum)" ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf; fi'
     ---> Running in 100296cdc1f9
    usage: dnf makecache [-c [config file]] [-q] [-v] [--version]
                     [--installroot [path]] [--nodocs] [--noplugins]
                     [--enableplugin [plugin]] [--disableplugin [plugin]]
                     [--releasever RELEASEVER] [--setopt SETOPTS]
                     [--skip-broken] [-h] [--allowerasing] [-b] [-C]
                     [-R [minutes]] [-d [debug level]] [--debugsolver]
                     [--showduplicates] [-e ERRORLEVEL] [--obsoletes]
                     [--rpmverbosity [debug level name]] [-y] [--assumeno]
                     [--enablerepo [repo]] [--disablerepo [repo] | --repo
                     [repo]] [-x [package]] [--disableexcludes [repo]]
                     [--repofrompath [repo,path]] [--nogpgcheck]
                     [--color COLOR] [--refresh] [-4] [-6] [--downloadonly]
                     [--bugfix] [--enhancement] [--newpackage] [--security]
                     [--advisory ADVISORY] [--bzs BUGZILLA] [--cves CVES]
                     [--sec-severity {Critical,Important,Moderate,Low}]
                     [--timer]
dnf makecache: error: argument timer: invalid choice: 'fast' (choose from 'timer')

    The command '/bin/sh -c /bin/sh -c 'if [ -x "$(command -v yum)" ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf; fi'' returned a non-zero code: 2
ERROR: Build failed for molecule_local/fedora:26.
Creating container fedora26 with base image fedora:26...
Traceback (most recent call last):
  File "/usr/bin/molecule", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python2.7/site-packages/molecule/cli.py", line 41, in main
    cli(obj={})
  File "/usr/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/molecule/command/test.py", line 96, in test
    util.sysexit(t.execute()[0])
  File "/usr/lib/python2.7/site-packages/molecule/command/test.py", line 44, in execute
    status, output = c.execute(exit=False)
  File "/usr/lib/python2.7/site-packages/molecule/command/create.py", line 42, in execute
    self.molecule.driver.up(no_provision=True)
  File "/usr/lib/python2.7/site-packages/molecule/driver/dockerdriver.py", line 172, in up
    hostname=hostname)
  File "/usr/lib/python2.7/site-packages/docker/api/container.py", line 447, in create_container
    return self.create_container_from_config(config, name)
  File "/usr/lib/python2.7/site-packages/docker/api/container.py", line 458, in create_container_from_config
    return self._result(res, True)
  File "/usr/lib/python2.7/site-packages/docker/api/client.py", line 226, in _result
    self._raise_for_status(response)
  File "/usr/lib/python2.7/site-packages/docker/api/client.py", line 222, in _raise_for_status
    raise create_api_error_from_http_exception(e)
  File "/usr/lib/python2.7/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
    raise cls(e, response=response, explanation=explanation)
docker.errors.ImageNotFound: 404 Client Error: Not Found ("No such image: molecule_local/fedora:26")

https://github.com/metacloud/molecule/blob/535db906520a9a526a46d2fef74f1bd458bbcabd/molecule/cookiecutter/scenario/driver/docker/%7B%7Bcookiecutter.molecule_directory%7D%7D/%7B%7Bcookiecutter.scenario_name%7D%7D/Dockerfile.j2#L8

I'm not sure dnf makecache fast ever worked and was always equivalent to dnf makecache. I couldn't find any reference to fast in the dnf codebase. The fast subcommand works in yum with yum makecache fast on EL6 and EL7 and also didn't fail with dnf 1.1 in Fedora 25 when automatically converted to dnf makecache fast with dnf2yum, but now fails in Fedora 26 (dnf 2.5) as an invalid option.

Thanks, Giovanni

I would suggest removing the fast subcommand when dnf is used.

retr0h commented 7 years ago

@aliusmiles did you happen to run into this issue when refactoring as part of #891?

tbondarchuk commented 7 years ago

@retr0h I didn't, and I think I was running Fedora 25 image at the time, since Fedora 26 was released only on Jul 11.

I've run some quick tests, and fedora 26 fails on yum makecache fast as well, since yum command appears to run dnf instead. Will do more testing tomorrow.

retr0h commented 7 years ago

@aliusmiles ok cool, let me know your findings so we can correct this.