2

Can I review tasks that would be run by ansible-playbook?

ansible-playbook --check does not list all tasks. Tasks which depend on previous tasks being performed may fail, causing ansible to stop half-way through.

ansible-playbook --list-tasks does not respect --limit, or when the provided inventory omits a host. So it lists too many tasks.

$ rpm -q ansible
ansible-2.2.0.0-3.fc25.noarch

Another puzzle here is the apparent duplication in output of --list-tasks, which can also be seen in --list-hosts. In the example below, the only host in the inventory is alan-laptop. I don't see why the target hosts frpm the playbook are being listed twice on the first line - first with brackets, and then without.

  play #1 (all): all    TAGS: []
    pattern: [u'all']
    hosts (1):
      alan-laptop

  play #2 (alan-laptop, alan-nuc): alan-laptop, alan-nuc    TAGS: []
    pattern: [u'alan-laptop, alan-nuc']
    hosts (1):
      alan-laptop
2

Once you're unhappy with --check mode, it is possible to solve the problem with --list-tasks. Follow the recommended "content organisation", and keep separate playbooks for groups of hosts which require the same tasks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.