Hi,

Is there a way to set fact using action_plugin, than calling set_fact?

Here is my playbook:
---
- hosts: all
  gather_facts: no
  tasks:
    - name: import role
      import_role:
        name: testrole
        tasks_from: test1

    - name: print
      debug:
         msg: "{{testfact}}"

action plugin:

testrole/action_plugins/updatefact.py

from ansible.plugins.action import ActionBase

class ActionModule(ActionBase):
    def run(self, tmp=None, task_vars=None):
      result = super(ActionModule, self).run(tmp, task_vars)
      modresult = self._execute_module(tmp=tmp, task_vars=task_vars)
      task_vars['ansible_facts'].update({"testfact": modresult})
      return modresult

runs a module and return a result which is used to update a fact

I know i am doing wrong but would appreciate any pointers to how to achieve
it?

Regards,
Punit

-- 
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/CAFXWBQJg0TEpN4fXxvxuUKJBHyOUfZZGeCc34JSZVdQS%3DoAsvw%40mail.gmail.com.

Reply via email to