pyinfra+vagrant - AttributeError: 'NoneType' object has no attribute 'lookup'

Created on 21 Jan 2020  路  3Comments  路  Source: Fizzadar/pyinfra

Hello!
Help me, please. (OS Ubuntu 19.10)

I have Vagrantfile:

`# Testing Vagrantfile

orderer_servers = [
{
:hostname => "admin-node"
:ip => "192.168.1.50",
:box => "ubuntu/bionic64",
:ram => 512
}]

peer_servers = [
{
:hostname => "node-1",
:ip => "192.168.1.60",
:box => "ubuntu/bionic64",
:ram => 512
},
{
:hostname => "node-2",
:ip => "192.168.1.70",
:box => "ubuntu/bionic64",
:ram => 512
}
]

Vagrant.configure("2") do |config|

peer_servers.each do |machine|
config.vm.define machine[:hostname] do |node|

  node.vm.box = machine[:box]
  node.vm.hostname = machine[:hostname]
  node.vm.network "public_network", ip: machine[:ip], bridge: "wlp2s0"

  # config.ssh.insert_key = false

  node.vm.provider "virtualbox" do |vb|
    vb.customize ["modifyvm", :id, "--memory", machine[:ram]]
  end
end

end

orderer_servers.each do |machine|
config.vm.define machine[:hostname] do |node|

  node.vm.box = machine[:box]
  node.vm.hostname = machine[:hostname]
  node.vm.network "public_network", ip: machine[:ip], bridge: "wlp2s0"

  # config.ssh.insert_key = false

  node.vm.provider "virtualbox" do |vb|
    vb.customize ["modifyvm", :id, "--memory", machine[:ram]]
  end
end

end
end`

Im running pyinfra: pyinfra -vv @vagrant/admin-node deploy_to_admin.py

--> Loading config... --> Loading inventory... Getting Vagrant config... localhost: >>> vagrant status --machine-readable localhost: 1579610588,node-1,metadata,provider,virtualbox localhost: 1579610589,node-2,metadata,provider,virtualbox localhost: 1579610589,admin-node,metadata,provider,virtualbox localhost: 1579610589,node-1,provider-name,virtualbox localhost: 1579610589,node-1,state,not_created localhost: 1579610589,node-1,state-human-short,not created localhost: 1579610589,node-1,state-human-long,The environment has not yet been created. Runvagrant upto\ncreate the environment. If a machine is not created%!(VAGRANT_COMMA) only the\ndefault provider will be shown. So if a provider is not listed%!(VAGRANT_COMMA)\nthen the machine is not created for that environment. localhost: 1579610589,node-2,provider-name,virtualbox localhost: 1579610589,node-2,state,not_created localhost: 1579610589,node-2,state-human-short,not created localhost: 1579610589,node-2,state-human-long,The environment has not yet been created. Runvagrant upto\ncreate the environment. If a machine is not created%!(VAGRANT_COMMA) only the\ndefault provider will be shown. So if a provider is not listed%!(VAGRANT_COMMA)\nthen the machine is not created for that environment. localhost: 1579610589,admin-node,provider-name,virtualbox localhost: 1579610589,admin-node,state,running localhost: 1579610589,admin-node,state-human-short,running localhost: 1579610589,admin-node,state-human-long,The VM is running. To stop this VM%!(VAGRANT_COMMA) you can runvagrant haltto\nshut it down forcefully%!(VAGRANT_COMMA) or you can runvagrant suspendto simply\nsuspend the virtual machine. In either case%!(VAGRANT_COMMA) to restart it again%!(VAGRANT_COMMA)\nsimply runvagrant up. localhost: 1579610590,,ui,info,Current machine states:\n\nnode-1 not created (virtualbox)\nnode-2 not created (virtualbox)\nadmin-node running (virtualbox)\n\nThis environment represents multiple VMs. The VMs are all listed\nabove with their current state. For more information about a specific\nVM%!(VAGRANT_COMMA) runvagrant status NAME`.
localhost: >>> vagrant ssh-config admin-node
localhost: Host admin-node
localhost: HostName 127.0.0.1
localhost: User vagrant
localhost: Port 2200
localhost: UserKnownHostsFile /dev/null
localhost: StrictHostKeyChecking no
localhost: PasswordAuthentication no
localhost: IdentityFile /home/georg/PycharmProjects/ndb_chaos_tests/.vagrant/machines/admin-node/virtualbox/private_key
localhost: IdentitiesOnly yes
localhost: LogLevel FATAL
localhost:

--> Connecting to hosts...
Traceback (most recent call last):
File "src/gevent/greenlet.py", line 766, in gevent._greenlet.Greenlet.run
File "/home/georg/PycharmProjects/ndb_chaos_tests/venv/lib/python3.7/site-packages/pyinfra/api/host.py", line 82, in connect
self.connection = self.executor.connect(state, self, args, *kwargs)
File "/home/georg/PycharmProjects/ndb_chaos_tests/venv/lib/python3.7/site-packages/pyinfra/api/connectors/ssh.py", line 162, in connect
client.connect(hostname, **kwargs)
File "/home/georg/PycharmProjects/ndb_chaos_tests/venv/lib/python3.7/site-packages/pyinfra/api/connectors/sshuserclient/client.py", line 36, in connect
self.hostname, self.config = self.parse_config(hostname)
File "/home/georg/PycharmProjects/ndb_chaos_tests/venv/lib/python3.7/site-packages/pyinfra/api/connectors/sshuserclient/client.py", line 51, in parse_config
host_config = ssh_config.lookup(hostname)
AttributeError: 'NoneType' object has no attribute 'lookup'
2020-01-21T12:43:13Z ()> failed with AttributeError

--> An unexpected exception occurred:

File "/home/georg/PycharmProjects/ndb_chaos_tests/venv/lib/python3.7/site-packages/pyinfra/api/connectors/sshuserclient/client.py", line 51, in parse_config
host_config = ssh_config.lookup(hostname)
AttributeError: 'NoneType' object has no attribute 'lookup'

--> The full traceback has been written to pyinfra-debug.log`

May be its bug?

P.S. English is not my native language, so please be kind to my mistakes.

Most helpful comment

@grybakov @mkinney I've now released v0.13 which includes this!

All 3 comments

Your english is fine.

I think this was a bug that was fixed https://github.com/Fizzadar/pyinfra/commit/01ee3100ea8bcc8e722ac51ce24cfb3fc9f9e4bb but has not yet been released.

@mkinney Ok. Thx. Waiting for release.

@grybakov @mkinney I've now released v0.13 which includes this!

Was this page helpful?
0 / 5 - 0 ratings