Ansible ad-hoc command with direct host specified - no hosts matched

后端 未结 1 1570
半阙折子戏
半阙折子戏 2021-02-13 03:10

I am running a 16.04 Ubuntu desktop machine using VirtualBox. This VM has Ansible 2.4.0 installed. I am trying to run an ad-hoc ansible command just to prove it works (I am doin

相关标签:
1条回答
  • 2021-02-13 03:30

    I provide this host's IP address directly in the command. In this very case, according to my understanding, the inventory file is irrelevant.

    Wrong. You specify host pattern, which should match hosts in your inventory. Inventory is a must for Ansible.

    There's an option to specify "inline" inventory. For your case:

    ansible all -i '10.0.3.248,' -m ping -u ubuntu
    

    in this example: host pattern is all, inventory is a list of a single host 10.0.3.248.
    Note comma at the end – it is important, this way Ansible understand that it is inline inventory, and not path to file.

    0 讨论(0)
提交回复
热议问题