Hi, 
I am developing a new Ansible collection to manage configuration of network 
devices. These devices are configured only over API. I need to be able to 
define them in an inventory file. From my understanding, I should create a 
new connection plugin and use it to connect to devices.

The problem starts when I try to access values for my connection plugin 
configuration options. These values are device-specific so it would be best 
to define them in an inventory file.

When I run a playbook that uses config_module I am getting an error:
fatal: [device_1]: FAILED! => {"msg": "No setting was provided for required 
configuration plugin_type: connection plugin: plugin_name setting: address "
}

My code example 
<https://gist.github.com/Soothly/183f419d7a26b11e58292950134a23ef>

I am running Ansible 8.2 [ansible-core 2.15.2]

I've noticed that my other calls to self.get_option(option) always return 
default value from connection plugin documentation irrespective of what is 
defined in the inventory file. I've checked that these inventory variables 
are available at playbook level. I am able to use debug module to print 
their values.

How do I access inventory variables for a given host in my connection 
plugin?

It seems to have been possible 
<https://github.com/xlab-steampunk/ansible-pms-plugins/tree/master/connection> 
in Ansible 2.9
I could pass them from the playbook to config_module as arguments and 
define ansible_connection: local for each device in inventory but it:

   - raises separation of concerns issue (module for configuration should 
   not care about connection details)


   - adds additional arguments for each task with configuration module 
   (there will be many in a playbook)
   - means that the connection will not be persistent between tasks


Any ideas?

Best Regards
Piotr Gabryś

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/7c95bc19-3a53-46d9-91e2-b5dd8c8a2d9cn%40googlegroups.com.

Reply via email to