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
Written by Yves Dorfsman
Related protips
2 Responses
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
·
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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ansible
Authors
Misha Behersky
78.83K
tartansandal
73.25K
Related Tags
#ansible
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#