ur8qnw
Last Updated: February 25, 2016
·
31.67K
· dorfsmay
Ff251bd0806aa3e700db933d599dadd4

How can you run only one task out of a playbook, for debug purposes

Use tags!

for example:

---
hosts: all
gather_facts: no

    - name: set minus o vi
  lineinfile: dest=/root/.profile state=file create=yes state=present insertafter=EOF regexp='' line='set -o vi'

  - name: create /export/data directory
    action: command mkdir -p /export/build creates=/export/data
   tags:
     - debug

- name: install all packages
  apt: pkg=$item install_recommends=yes
  with_lines: cat /var/tmp/packages.all

Running the following will only run the create directory task:

ansible-playbook setup.playbook.yaml --tags debug

Or even better, with -vvv for debug mode:

ansible-playbook -vvv setup.playbook.yaml --tags debug
Say Thanks
Respond

2 Responses
Add your response

4949
3c1b7e921632632e11d5d2ee59403f5f

Also new in 1.1, "ansible-playbook playbook.yml --step" can let you interactively step through playbooks and decide what to run.

over 1 year ago ·
6237
20d9174f86be92d440f4d623c2d62284

and in ansible 1.2+ you can use:

--step --start-at-task=tasknamehere

and it will do stepped task execution starting at the first task matching the string you put in

over 1 year ago ·
Filed Under