help building action plugin

All,

I’m in the process of building an action plugin. I may be going about this all wrong in which case I welcome feedback on how to better my overall design.

I have discovered the action plugin, although run on the management node, is actually running once per each node in the inventory. Where I’m struggling is that each run of the action plugin requires knowledge of intimate details for the other node(s).

As an example, I have three hosts in my inventory, node1 - 3. When Ansible gathers facts it’ll get specific information such as the IP address of eth1. I’m trying to then use that data so that when the action plugin is running for node1 I’ll somehow have access to the IP address of eth1 on node2.

While it may seem hackish (or even messy), I decided to go about this because the complexity of doing something like this with templates and scripts was even uglier. :wink:

Thoughts / ideas on how these different loops / runs can share information would be greatly appreciated.

Could you describe a bit more about what you need to achieve? It might be that there’s a way of doing whatever it is without having to write what sounds like quite a specialised action plugin?

It sounds like you might be able to achieve what you want by setting some facts in your playbook but I’m speculating as I don’t understand what you are trying to achieve.

Jon

Thanks for the reply, Jon.

I’m building a module and action plugin that creates a overlay network mesh using a highly-hacked (internal) version of Open vSwitch (http://openvswitch.org/).

Each node must have an RSA keypair (private / public). All nodes must have a copy of the public key so that they can connect securely with the other nodes. There is also a highly simplistic configuration file which has the IP address each node should attempt to connect to. For example, node1 should build tunnels to all the other nodes and the config may look like this:

build_conn_to: node2
build_conn_to: node3
build_conn_to: node4

From a development perspective I’ve been aiming to do most of the work in the action plugin, primarily because the management node is going to have to generate and then transfer the public key from each node to the remaining nodes. It also stands to reason that the management node has a “better view” of all the nodes and can easily generate a configuration like the one above.

The management node’s “holistic view,” however, appears to be less holistic than I once thought. :wink: It appears that when the node1 fork is running it has no knowledge of the inject data for node2. This prevents me from accessing things to like the secondary interface’s IP address on node2 (which Ansible slurps up during the gather fact phase). In summary, node1 knows only about node1 and it’s relevant data.

Ideally I would like to be able to grab the inject data for node2 - 4 in the node1 execution. This would give me the ability to quickly whip up the configuration files needed on all the nodes and then push them (along with the certificates) to the relevant nodes.

Although I can think of a few days of doing this with a mix of action plugins and Ansible playbook tasks, but am aiming to make this “very simple” to the user by only having to run one “ovs” task which does all the work in the background, such as:

name: set up ovs overlay network
ovs: key_length=4096 net_type=mesh interface=eth1

This would result in all the nodes being fully configured with a copy of the needed RSA certificates and configuration files – everything needed for OVS to work.

Any thoughts on how it would be possible to “leak” information between the different threads executed for each node in the action plugin? Is there another plugin better suited to do something like this? Am I going about this all wrong?

Thanks in advance.

See if this helps:
http://docs.ansible.com/playbooks_variables.html#fact-caching

Giovanni

instead of a plugin it seems what you want is a collection of tasks,
mostly a role, that does all this, generate the certs, pull them,
distribute them, etc.