@@ -0,0 +1,2865 @@
+#!/usr/bin/python%0A# -*- coding: utf-8 -*-%0A%0A# (c) 2012, Luis Alberto Perez Lazaro %3Cluisperlazaro@gmail.com%3E (original patch module)%0A# (c) 2015, Jakub Jirutka %3Cjakub@jirutka.cz%3E (original patch module)%0A# (c) 2016, Wolf480pl %3Cwolf480@interia.pl%3E%0A#%0A# This file is part of Ansible%0A#%0A# Ansible is free software: you can redistribute it and/or modify%0A# it under the terms of the GNU General Public License as published by%0A# the Free Software Foundation, either version 3 of the License, or%0A# (at your option) any later version.%0A#%0A# Ansible is distributed in the hope that it will be useful,%0A# but WITHOUT ANY WARRANTY; without even the implied warranty of%0A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A# GNU General Public License for more details.%0A#%0A# You should have received a copy of the GNU General Public License%0A# along with Ansible.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A%0ADOCUMENTATION = '''%0A---%0Amodule: make%0Aauthor:%0A    - %22Wolf480pl%22%0Adescription:%0A    - Run a Makefile using GNU Make tool%0Ashort_description: Run a Makefile using GNU Make tool.%0Aoptions:%0A  basedir:%0A    description:%0A      - Path of a base directory in which the Makefile will be ran.%0A    required: true%0A  target:%0A    description:%0A      - The make target to invoke%0A    required: false%0Anote:%0A  - This module requires GNU I(make) utility to be installed on the remote host.%0A'''%0A%0Aimport os%0Afrom os import path, R_OK, W_OK%0A%0A%0Aclass MakeError(Exception):%0A    pass%0A%0Adef is_already_built(make_func, target=None):%0A    opts = %5B'-q'%5D%0A    if target:%0A        opts.append(target)%0A%0A    (rc, _, _) = make_func(opts)%0A    return rc == 0%0A%0A%0Adef do_build(make_func, target=None):%0A    opts = %5B%5D%0A    if target:%0A        opts.append(target)%0A%0A    (rc, out, err) = make_func(opts)%0A    if rc != 0:%0A        msg = err or out%0A        raise MakeError(msg)%0A%0A%0Adef main():%0A    module = AnsibleModule(%0A        argument_spec=%7B%0A            'basedir': %7B'required': True, 'aliases': %5B'chdir'%5D%7D,%0A            'target': %7B%7D,%0A        %7D,%0A        supports_check_mode=True%0A    )%0A%0A    # Create type object as namespace for module params%0A    p = type('Params', (), module.params)%0A%0A    p.basedir = os.path.abspath(os.path.expanduser(p.basedir))%0A%0A    if not path.exists(p.basedir):%0A        module.fail_json(msg=%22basedir %25s doesn't exist%22 %25 (p.basedir))%0A%0A    os.chdir(p.basedir)%0A%0A    make_bin = module.get_bin_path('make')%0A    if make_bin is None:%0A        module.fail_json(msg=%22make command not found%22)%0A    make_func = lambda opts: module.run_command(%22%25s %25s%22 %25 (make_bin, ' '.join(opts)))%0A%0A    changed = False%0A    if not is_already_built(make_func, p.target):%0A        try:%0A            do_build( make_func, p.target )%0A            changed = True%0A        except PatchError, e:%0A            module.fail_json(msg=str(e))%0A%0A    module.exit_json(changed=changed)%0A%0A# import module snippets%0Afrom ansible.module_utils.basic import *%0Amain()%0A

Add a `make` module