ansible module add_host error: skipping: no hosts matched

  ansible, oracle, windows

The Skript, running at a Linux host, should call some Windows hosts with Oracle Databases on. Each Oracle Database is in DNS with its name "db-[ORACLE_SID]".
Lets say, you have a database with ORACLE SID TEST02, it can be resolved as db-TEST02.
The complete skript is doing some more stuff, but this example is sufficient to explain the problem.

The db-[SID] hostnames must be added as dynamic hosts to able to parallelize the processing.
The problem is, that oracle_databases is not passed to the new playbook. It worked, if I change the hosts from windows to localhost, but I need to analyze something first and get some data from the windows hosts, so this is not an option.

Here is the script:

# ansible-playbook parallel.yml -e "databases=TEST01,TEST02,TEST03"

- hosts: windows
  gather_facts: false
    ansible_connection: winrm
    ansible_port: 5985
    ansible_winrm_transport: kerberos
    ansible_winrm_kerberos_delegation: true

    - set_fact:
        database: "{{ databases.split(',') }}"

    - name: Add databases as hosts, to parallelize the shutdown process
        name: "db-{{ item }}"
        groups: oracle_databases
      loop: "{{ database | list}}"

##### just to check, what is in oracle_databases
    - name: show the content of oracle_databases
        msg: "{{ item }}"
        - oracle_databases

- hosts: oracle_databases
  gather_facts: true


    - debug:
          - "Hosts, on which the playbook is running: {{ ansible_play_hosts }}"
        verbosity: 1

My inventory file is just small, but there will be more windows hosts in future:

[[email protected] oracle_change_home]$ cat inventory


And the output

[[email protected] oracle_change_home]$ ansible-playbook para.yml -l windows68 -e "databases=TEST01,TEST02"
/usr/lib/python2.7/site-packages/ansible/parsing/vault/ CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in a future release.
  from cryptography.exceptions import InvalidSignature
/usr/lib/python2.7/site-packages/requests/ RequestsDependencyWarning: urllib3 (1.23) or chardet (2.2.1) doesn't match a supported version!

PLAY [windows] *****************************************************************************************************************************

TASK [set_fact] ****************************************************************************************************************************
ok: [windows68]

TASK [Add databases as hosts, to parallelize the shutdown process] *************************************************************************
changed: [windows68] => (item=TEST01)
changed: [windows68] => (item=TEST02)

TASK [show the content of oracle_databases] ************************************************************************************************
ok: [windows68] => (item=db-TEST01) => {
    "msg": "db-TEST01"
ok: [windows68] => (item=db-TEST02) => {
    "msg": "db-TEST02"

PLAY [oracle_databases] ********************************************************************************************************************
skipping: no hosts matched

PLAY RECAP *********************************************************************************************************************************
windows68                   : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Source: Windows Questions