--- # Copyright 2017, Logan Vig # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - name: Test the tagfilter execution strategy with a list of skip tags hosts: localhost strategy: tagfilter gather_facts: no vars: skip_tags: - skipit - tagskip tasks: - name: Test skipped task debug: msg: "This task is skipped" register: skipped_task tags: # Multiple tags specified before the skip tag to make sure the .product() # loop in the strategy is working properly. (ie. ensure each element in # the skip_tags list is being checked against each element in this tag # list.) - test-tag1 - test-tag2 - test-tag3 - test-tag4 - test-skipit - name: Test unskipped task command: /bin/true register: run_task notify: Skipped Handler tags: - skip_ansible_lint - test-runit handlers: - name: Skipped Handler debug: msg: "This handler is always skipped" register: skipped_handler post_tasks: - name: Check task run states assert: that: - "skipped_task is not defined" - "run_task is changed" - "skipped_handler is not defined" - name: Test the tagfilter execution strategy with a string skip tag hosts: localhost strategy: tagfilter gather_facts: no vars: skip_tags: skipit tasks: - name: Test skipped task debug: msg: "This task is skipped" register: skipped_task tags: - test-skipit - name: Test unskipped task command: /bin/true register: run_task notify: Skipped Handler tags: - skip_ansible_lint - test-runit handlers: - name: Skipped Handler debug: msg: "This handler is always skipped" register: skipped_handler post_tasks: - name: Check task run states assert: that: - "skipped_task is not defined" - "run_task is changed" - "skipped_handler is not defined" - name: Test the tagfilter execution strategy with handlers enabled hosts: localhost strategy: tagfilter gather_facts: no vars: skip_handlers: False skip_tags: skipit tasks: - name: Test skipped task command: /bin/true register: skipped_task notify: Skipped Handler tags: - skip_ansible_lint - test-skipit - name: Test unskipped task command: /bin/true register: run_task notify: Run Handler tags: - skip_ansible_lint - test-runit handlers: - name: Skipped Handler debug: msg: "This handler is always skipped" register: skipped_handler - name: Run Handler command: /bin/true register: run_handler post_tasks: - name: Check task run states assert: that: - "skipped_task is not defined" - "run_task is changed" - "skipped_handler is not defined" - "run_handler is changed"