Coder Social home page Coder Social logo

Comments (6)

geerlingguy avatar geerlingguy commented on July 17, 2024 7

Thanks for this, and to anyone finding this in the future, you can add it to your sequence in molecule.yml with:

scenario:
  name: default
  test_sequence:
    - lint
    - destroy
    - dependency
    - syntax
    - create
    - prepare
    - converge
    - idempotence
    # Added --check run test.
    - check
    - side_effect
    - verify
    - destroy

from molecule.

conorsch avatar conorsch commented on July 17, 2024 1

If we are to add check into the test sequence. Where would it go? It doesn't make sense to run it after converge, since nothing would then change.

Adding after converge actually does make sense, although it's not intuitive. Many roles use a command/register pragma to store a dynamic variable, then inspect that var in a subsequent task as part of conditional logic. By default, Ansible skips command tasks, because it can't know the severity of side-effects, so the subsequent tasks inspecting the var will fail in check mode. Having Molecule run a check mode after converge would be very useful to catch errors like this.

It's technically possible to support dry-runs of a first-time role run with Ansible, but I don't see many role authors striving for it. For example, get_url tasks will be skipped by default, and then any tasks referencing a file downloaded by get_url will fail, since the file doesn't exist. A reasonable order for running --check mode seems to be:

      - destroy
      - syntax
      - create
      - converge
      - idempotence
      - check
      - verify

If you run check before converge, I'd wager that most Ansible roles would fail, since folks simply don't plan for that use case.

from molecule.

retr0h avatar retr0h commented on July 17, 2024

Implemented in #201.

from molecule.

conorsch avatar conorsch commented on July 17, 2024

@retr0h The --check and --syntax-check arguments to ansible-playbook are distinct—looks like #201 adds the --syntax-check functionality as molecule check. That's fine, but it's not the same thing as --check, which performs a dry-run of the playbook.

from molecule.

retr0h avatar retr0h commented on July 17, 2024

Opening

from molecule.

retr0h avatar retr0h commented on July 17, 2024

@conorsch I think I'm going to need more details on this. I'm not entirely sure how it would be helpful.

If we are to add check into the test sequence. Where would it go? It doesn't make sense to run it after converge, since nothing would then change.

Since change always returns success, I don't see how it would be useful in the test sequence. I can implement the changed subcommand, but not add it to the test sequence. People can then do what they wish with it?

from molecule.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.