$ ansible --version
ansible 2.10.8
I have a playbook called site.yml that just contains other playbooks. Some playbooks I only want to ron when I use a --tags update tag, but some playbooks I want to run all the time, but only certain tasks tagged appropriately. In my example below, I want all the tasks on the prepare-update.yml playbook to only run on update tag, while I want to run the postgresql.yml playbook all the time. I then want to control some tasks to run or not in my postgresql role
- import_playbook: prepare-update.yml
tags: update
- import_playbook: postgresql.yml
the posgresql.yml playbook simply contains a postgresql role
---
- hosts: "{{ var_host | default('exa_site') }}"
become_method: runas
roles:
- postgresql
Now my postgresql role's tasks/main.yml has
---
# tasks file for postgresql
- include_tasks: install_postgresql.yml
- include_tasks: run_postgresql_queries.yml
- include_tasks: install_pgadmin4.yml
and my install_postgresql.yml task has these tasks. As you can see I use 3 different tags, namely new_install, update, and uninstall
- block:
- name: Download app
win_get_url: ...
- name: Install app
win_shell: ...
tags: new_install
- name: Start service
win_service: ...
tags:
- new_install
- update
- block:
- name: Stop service
win_service: ...
- name: Delete service
win_file: ...
tags: uninstall
When I run the following, I expect some tasks to run based on their tags.
$ ansible-playbook -i hosts.yml -e var_host=my_host --tags new_install site.yml
However, I just get this, where nothing runs.
PLAY [10.227.x.x] *******************************************************
TASK [Gathering Facts] **************************************************
ok: [10.227.x.x]
PLAY RECAP **************************************************************
10.227.x.x : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Why are my tasks tagged as new_install not being run at all?