Execution of core-modules failes in action-plugins

21 views
Skip to first unread message

Sirk Johannsen

unread,
May 12, 2016, 1:10:44 PM5/12/16
to Ansible Project
Hi,

I am trying to write an action plugin that executes 2 core modules.
I always get the error message that the plugin I'm trying to execute is missing the interpreter line (#/usr/bin/python)

Certainly someone has done this before. I'd really appreaciate if someone could point me to my mistake:

#!/usr/bin/python
#
# This file extends Ansible

from __future__ import (absolute_import, division, print_function)
__metaclass__
= type

from ansible.plugins.action import ActionBase
from ansible.utils.boolean import boolean

class ActionModule(ActionBase):

    TRANSFERS_FILES
= True

   
def run(self, tmp=None, task_vars=None):
       
''' handler for fetch operations '''
       
if task_vars is None:
            task_vars
= dict()

        result
= super(ActionModule, self).run(tmp, task_vars)

        source            
= self._task.args.get('remote_src', None)
        dest              
= self._task.args.get('dest', None)
        flat              
= boolean(self._task.args.get('flat'))
        fail_on_missing  
= boolean(self._task.args.get('fail_on_missing'))
        validate_checksum
= boolean(self._task.args.get('validate_checksum', self._task.args.get('validate_md5')))

        fetch_args
= dict(
            src
=source,
            dest
='/tmp/_template.j2'
       
)

        template_args
=self._task.args.copy()
        template_args
.update(
            dict
(
                src
='/tmp/_template.j2',
                dest
=dest
           
)
       
)

        module_return
=self._execute_module(module_name='fetch', module_args=fetch_args, task_vars=task_vars, tmp=tmp)
        result
.update(module_return)
       
#result.update(self._execute_module(module_name='template', module_args=template_args, task_vars=task_vars))
       
#module_executed = True

       
return result

result is

fatal: [centos-72]: FAILED! => {"failed": true, "msg": "module (fetch) is missing interpreter line"}

many thanks in advance for your help.

Best,

Sirk
Reply all
Reply to author
Forward
0 new messages