Could not match supplied host pattern, ignoring:

Hello!
Id like to use fron anther project what functioned for a diffrent cause: move db from servers wih survey, bbut i get this message and tomehow the host gets the wrong ip from the dest var.

my hosts i edited to just ip for debug:


the Survey of the faulty host:

Workflow:

Log:

Enter passphrase for /runner/artifacts/6924/ssh_key_data: 
Identity added: /runner/artifacts/6924/ssh_key_data (/runner/artifacts/6924/ssh_key_data)
ansible-playbook [core 2.15.12]
  config file = None
  configured module search path = ['/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /runner/requirements_collections:/runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.9.19 (main, Jul 18 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/usr/bin/python3)
  jinja version = 3.1.4
  libyaml = True
No config file found; using defaults
host_list declined parsing /runner/inventory/hosts as it did not pass its verify_file() method
Parsed /runner/inventory/hosts inventory source with script plugin
Skipping callback 'awx_display', as we already have a stdout callback.
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: workflow_variables_checker.yaml **************************************
1 plays in functions/SQL/migration/workflow_variables_checker.yaml
[WARNING]: Could not match supplied host pattern, ignoring: 192.168.151.201

PLAY [Display and compare extra variables and fail if they match] **************

TASK [Display the value of 'sql_src_srv'] **************************************
task path: /runner/project/functions/SQL/migration/workflow_variables_checker.yaml:11
ok: [192.168.151.237] => {
    "msg": "The value of sql_src_srv is 192.168.151.237"
}

TASK [Display the value of 'sql_src_db'] ***************************************
task path: /runner/project/functions/SQL/migration/workflow_variables_checker.yaml:15
ok: [192.168.151.237] => {
    "msg": "The value of sql_src_db is sakila"
}

TASK [Display the value of 'sql_dest_srv'] *************************************
task path: /runner/project/functions/SQL/migration/workflow_variables_checker.yaml:19
ok: [192.168.151.237] => {
    "msg": "The value of sql_dest_srv is 192.168.151.201"
}

TASK [Check if 'sql_src_srv' and 'sql_dest_srv' have the same content and fail if true] ***
task path: /runner/project/functions/SQL/migration/workflow_variables_checker.yaml:23
skipping: [192.168.151.237] => {
    "changed": false,
    "false_condition": "sql_src_srv == sql_dest_srv",
    "skip_reason": "Conditional result was False"
}

Somehow the vars get correct set , but hte host sqldest srv gets an random ip in the next playbook of the workflow right at the beginning without any reason:

Enter passphrase for /runner/artifacts/6933/ssh_key_data: 
Identity added: /runner/artifacts/6933/ssh_key_data (/runner/artifacts/6933/ssh_key_data)
ansible-playbook [core 2.15.12]
  config file = None
  configured module search path = ['/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /runner/requirements_collections:/runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.9.19 (main, Jul 18 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/usr/bin/python3)
  jinja version = 3.1.4
  libyaml = True
No config file found; using defaults
host_list declined parsing /runner/inventory/hosts as it did not pass its verify_file() method
Parsed /runner/inventory/hosts inventory source with script plugin
Skipping callback 'awx_display', as we already have a stdout callback.
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: install_pymysql_env_workflow-vars.yaml *******************************
1 plays in functions/SQL/migration/install_pymysql_env_workflow-vars.yaml

PLAY [install pymysql+ requirements+env] ***************************************

TASK [Ensure pip and venv are installed] ***************************************
task path: /runner/project/functions/SQL/migration/install_pymysql_env_workflow-vars.yaml:10
<192.168.151.150> ESTABLISH SSH CONNECTION FOR USER: root
<192.168.151.150> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 'ControlPath="/runner/cp/e3b87fbd70"' 192.168.151.150 '/bin/sh -c '"'"'echo ~root && sleep 0'"'"''
<192.168.151.237> ESTABLISH SSH CONNECTION FOR USER: root
<192.168.151.237> SSH: EXEC ssh -C -o ControlMaster=auto -o Contr

Thank you again!!

It is hart to help you, with only this information.

Could not match supplied host pattern normally means that the host list in your playbook and the limit doesn’t match.

can you show us the ansible-playbook call and some of the Task definitions in your Playbook that doesn’t work correctly.

I’m also not sure how you pass the variables, maybe this will help you: delegating-facts

okay,
there are a few the first checks if sorce and dest is the same:

---
- name: Create temp MySQL user with full privileges
  hosts:
    - "{{ sql_dest_srv }}"  
    - "{{ sql_src_srv }}"   
  gather_facts: false  
  become: true
  vars:
    ansible_python_interpreter: /opt/myenv/bin/python3

  tasks:
    - name: Create MySQL user with necessary privileges
      community.mysql.mysql_user:
        name: "{{ sql_user }}"
        password: "{{ sql_passwd }}"
        login_unix_socket: /var/run/mysqld/mysqld.sock
        priv: '*.*:ALL,GRANT'
        host: '%'
        state: present

then install of pymysql and env as requirements for the rest:

---
- name: install pymysql+ requirements+env
  hosts: all
  gather_facts: false  # Disabling fact gathering to speed up the playbook execution
  become: true
#  vars:
#    ansible_python_interpreter: /opt/myenv/bin/python3

  tasks:
    - name: Ensure pip and venv are installed
      ansible.builtin.apt:
        name: 
          - python3-pip
          - python3-venv
          - python3-dev
          - build-essential
          - libssl-dev
          - libffi-dev
          - libmysqlclient-dev
          - pkg-config
        state: present
      #become: yes

    - name: Create a virtual environment
      ansible.builtin.command:
        cmd: python3 -m venv /opt/myenv
      #become: yes
      args:
        creates: /opt/myenv

    - name: Install required Python packages in virtual environment
      ansible.builtin.pip:
        executable: /opt/myenv/bin/pip
        name:
          - pymysql
          #- mysqlclient
      #become: yes

then adding the sql migration user:

---
- name: Create temp MySQL user with full privileges
  hosts:
    - "{{ sql_dest_srv }}"  # {{ sql_dest_srv }} 192.168.151.141
    - "{{ sql_src_srv }}"   # {{ sql_src_srv }} 192.168.151.237
  gather_facts: false  # Disabling fact gathering to speed up the playbook execution
  become: true
  vars:
    ansible_python_interpreter: /opt/myenv/bin/python3

  tasks:
    - name: Create MySQL user with necessary privileges
      community.mysql.mysql_user:
        name: "{{ sql_user }}"
        password: "{{ sql_passwd }}"
        login_unix_socket: /var/run/mysqld/mysqld.sock
        priv: '*.*:ALL,GRANT'
        host: '%'
        state: present

need more?
the {{ sql_src_db }} {{ sql_src_srv }}{{ sql_dest_srv }} env get set in the survey the rest vie env credentials.

i got it running, but i accidently deleted the wokflow in the templates

I messed up myself- forgot to set the hosts to all playboooks he same and not just in the Workflow

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.