Skip to content

Execute task on the same host >1 time #633

@bitprophet

Description

@bitprophet

Currently host lists are fully deduped in order to prevent unwanted duplicity when merging different host list sources. E.g. specifying a role containing host1 and at the same time also using a @hosts('host1') decorator would, without deduping, run twice on host1, which is not usually the desired effect.

However, this protective feature disables any wanted duplicity, i.e. running a task multiple times on the same server on purpose. (This has become especially important for some folks with the advent of parallelism.)

I see two solutions:

  • Simply add another global option that is tested in the host merging method (currently Task.get_hosts IIRC) and if set, does not do any deduping, but simply adds all sources together.
    • Simplest/easiest, fills the need, while staying off by default to protect newbies from unexpected/odd behavior.
  • Try to be "smart" and dedupe inter-source but not intra-source, i.e. two examples of the same host string from two different sources (say, -H and @hosts) would get deduped, but identical host strings in the same source (e.g. env.hosts = ['host1', 'host1', 'host1']) would not get deduped.
    • Harder to implement, but "cleaner", in that it would not require an option to be activated, and instead would try to determine what the user's actual intent was.

I don't see any serious downsides to going with the simpler approach. Users wanting this feature are more likely to be advanced enough that they know to search for and activate nondefault options; and they're also more likely to understand the tradeoff and/or not specify multiple sources simultaneously.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions