4
respostas

[WARNING]: Unable to parse /home/vagrant/hosts as an inventory source

Boa noite. Após subir vm via vagrant utilizando vagrantfile. Ao executar o primeiro comando no ansible da seguinte mensagem:

"vagrant@vagrant-ubuntu-trusty-64:~$ ansible wordpress -i hosts -u vagrant --private-key ssh-keys/vagrant_id_rsa -m ping -m shell -a 'echo Hello, World' [WARNING]: Unable to parse /home/vagrant/hosts as an inventory source [WARNING]: No inventory was parsed, only implicit localhost is available [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all' [WARNING]: Could not match supplied host pattern, ignoring: wordpress"

Estou usando Windows

Segue abaixo os arquivos:

(Maquina subiu ok) Vagrant.configure("2") do |config|

config.vm.box = "ubuntu/trusty64"

config.vm.provider "virtualbox" do |v| v.memory = 1024 end

config.vm.define "wordpress" do |m| m.vm.network "private_network", ip: "172.17.177.40" end

end

arquivo hosts. [wordpress] 172.17.177.40

Versão do Ansible:

vagrant@vagrant-ubuntu-trusty-64:$ ansible --version ansible 2.9.21 config file = /etc/ansible/ansible.cfg configured module search path = [u'/home/vagrant/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/dist-packages/ansible executable location = /usr/bin/ansible python version = 2.7.6 (default, Nov 13 2018, 12:45:42) [GCC 4.8.4] vagrant@vagrant-ubuntu-trusty-64:$

Versão do Python! vagrant@vagrant-ubuntu-trusty-64:~$ python -V Python 2.7.6

4 respostas

Olá José, tudo bem?

Dica: use a função "inserir código" para formatar o código nos posts.

Quanto ao erro em questão, o Ansible está informando que não foi possível ler o arquivo de hosts corretamente. Você colocou o IP ao lado do nome do grupo de hosts, quando devem ser em linhas separadas. Desta forma:

[wordpress] 
172.17.177.40

Olá, refiz.... detalhe em vez de mac uso o ubuntu no windows atraves do app. consigo conectar na maquina via ssh. mas nao consigo executar o comando conforme evidencia abaixo.

root@LAPTOP:/mnt/c/Users/jrdsi/OneDrive/Imagens/Documentos/wordpress_ansible/ssh-keys# ssh-copy-id -i vagrant_id_rsa.pub vagrant@172.17.177.40
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "vagrant_id_rsa.pub"
The authenticity of host '172.17.177.40 (172.17.177.40)' can't be established.
ECDSA key fingerprint is SHA256:R/JXNMlkDgK3wQdzCKBd9YrJM/FxJ4YV2BEc0SuLikA.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
vagrant@172.17.177.40's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'vagrant@172.17.177.40'"
and check to make sure that only the key(s) you wanted were added.

root@LAPTOP:/mnt/c/Users/jrdsi/OneDrive/Imagens/Documentos/wordpress_ansible/ssh-keys# ansible wordpress -i hosts -u vagrant --private-key ssh-keys/vagrant_id_rsa -m ping -m shell -a 'echo Hello, World'
Vagrant.configure("2") do |config|

  config.vm.box = "ubuntu/trusty64"

  config.vm.provider "virtualbox" do |v|
    v.memory = 1024
  end

  config.vm.define "wordpress" do |m|
    m.vm.network "private_network", ip: "172.17.177.40"
  end

end
[wordpress]
172.17.177.40

Segue evidencia de conexão.

root@LAPTOP:/mnt/c/Users/jrdsi/OneDrive/Imagens/Documentos/wordpress_ansible# ssh vagrant@172.17.177.40
vagrant@172.17.177.40's password:
Welcome to Ubuntu 14.04.6 LTS (GNU/Linux 3.13.0-170-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Fri May  7 23:39:57 UTC 2021

  System load:  0.0               Processes:           78
  Usage of /:   3.6% of 39.34GB   Users logged in:     1
  Memory usage: 13%               IP address for eth0: 10.0.2.15
  Swap usage:   0%                IP address for eth1: 172.17.177.40

  Graph this data and manage this system at:
    https://landscape.canonical.com/

UA Infrastructure Extended Security Maintenance (ESM) is not enabled.

0 updates can be installed immediately.
0 of these updates are security updates.

Enable UA Infrastructure ESM to receive 64 additional security updates.
See https://ubuntu.com/advantage or run: sudo ua status

New release '16.04.7 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Fri May  7 23:30:49 2021 from 172.17.177.1
vagrant@vagrant-ubuntu-trusty-64:~$

Olá,

Faltou o retorno do comando: # ansible wordpress -i hosts -u vagrant --private-key ssh-keys/vagrant_id_rsa -m ping -m shell -a 'echo Hello, World' Agora que você refez, ocorre o mesmo erro? Poderia postar a saída do comando?