User Tools

Site Tools


devops:ansible_playbook_exclude_host_cli

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
devops:ansible_playbook_exclude_host_cli [2017/01/24 17:49]
lubos
devops:ansible_playbook_exclude_host_cli [2017/02/06 14:47]
lubos
Line 1: Line 1:
-====== Excluding a host from Ansible ​from Command Line ======+====== Excluding a host from Ansible ​Playbook ​Command Line ======
  
 If you are like me, then your Ansible world is not ideal. Separate environments force you operating on multiple inventories. These multiple inventories have a caveat that some hosts like monitoring, log forwarding, jump stations, etc. are common boxes at the edge of these environments. Boxes like these should be excluded from from applying the configuration multiple times, once for each environment. If you are like me, then your Ansible world is not ideal. Separate environments force you operating on multiple inventories. These multiple inventories have a caveat that some hosts like monitoring, log forwarding, jump stations, etc. are common boxes at the edge of these environments. Boxes like these should be excluded from from applying the configuration multiple times, once for each environment.
  
-There is an undocumented feature in ''​ansible-playbook'',​ which allows you to exclude the host. I have never found this anywhere in docs nor any of the books I hve, so here it is:+There is an undocumented feature in ''​ansible-playbook'',​ which allows you to exclude the host. I have never found this anywhere in docs nor any of the books I have, so here it is:
  
 +''​ansible-playbook -i <​inventory>​ playbook.yml --limit='​!hostname'​
 +''​
  
 +You can verify the host list with ''​--list-hosts''​ flag:
  
 +''​ansible-playbook -i <​inventory>​ playbook.yml --limit='​!hostname'​ --list-hosts
 +''​
  
 +==== EDIT ====
  
 +06. Feb. 2016
  
 +More information could be found in [[http://​docs.ansible.com/​ansible/​intro_patterns.html|Ansible Paterns]] article in online docs, at the end of the document. This also applies to ''​--limit''​ command line parameter to ''​ansible-playbook''​.
devops/ansible_playbook_exclude_host_cli.txt ยท Last modified: 2017/02/06 14:47 by lubos