Limiting host scope
You can run playbooks against some or all Opsview hosts. For example, you can run playbooks against only a specific collector cluster or all collectors except one. These powerful targeting options can speed up running playbooks by limiting them to only run against necessary hosts.
Deploy playbooks can be limited to specific hosts using the -l
option followed by a list of hostnames or Ansible tags separated by commas and wrapped in single quotes.
Hostnames
You can run deploy playbooks against only a list of specified hosts. Hostnames can include wildcard (*) expansion, so collector-fr-*
would expand to include collector-fr-1
, collector-fr-2
, etc.
Example: Run the setup_hosts.yml
playbook against only the hosts ‘fr-col-1’, ‘de-col-2’, and ‘de-col-3’:
/opt/opsview/deploy/bin/opsview-deploy -l 'fr-col-1,de-col-2,de-col-3' /opt/opsview/deploy/lib/playbooks/setup_hosts.yml
Ansible tags
One of the most powerful ways to take advantage of limiting host scope is using Ansible tags. Follow these steps to list all available Ansible tags for your system: 1. Log in to your deployment host (usually your orchestrator) as root
. 2. Run this source command:
source /opt/opsview/deploy/bin/rc.ansible
- Run this
ansible-inventory
command and pipe its output tojq
:
ansible-inventory --list | jq -r '.opsview_all.children[]'
dosh
Alternatively, you can list available Ansible tags using the dosh
support script.
/opt/opsview/supportscripts/bin/dosh -l
Example: Run the setup-everything.yml
playbook against all collectors in the cluster ‘cluster_1’:
/opt/opsview/deploy/bin/opsview-deploy -l opsview_cluster_cluster_1 /opt/opsview/deploy/lib/playbooks/setup-everything.yml
Example: Run the check_deploy.yml
playbook against all collectors, except ‘fr-col-1’, in the cluster ‘france’ :
/opt/opsview/deploy/bin/opsview-deploy -l 'opsview_cluster_france,!fr-col-1' /opt/opsview/deploy/lib/playbooks/check_deploy.yml
Exclusions
To exclude a host or tag that would otherwise be included, include the hostname or tag preceded by an exclamation point (‘!’).
Example: Run the check_deploy.yml
playbook against all collectors except those in clusters ‘cluster-fr’ and ‘cluster-de’:
/opt/opsview/deploy/bin/opsview-deploy -l 'opsview_collector,!opsview_cluster_cluster_fr,!opsview_cluster_cluster_de' /opt/opsview/deploy/lib/playbooks/setup_hosts.yml
Note how the Ansible tags replace hyphens with underscores.
Comments
0 comments
Please sign in to leave a comment.