浏览代码

Removed third-party path plugin. Ansible 1.9 contains one.

merge-requests/1/merge
Christoph Haas 10 年前
父节点
当前提交
d79f1978e0
共有 7 个文件被更改,包括 0 次插入186 次删除
  1. +0
    -8
      roles/thydel.patch/.gitignore
  2. +0
    -9
      roles/thydel.patch/LICENSE.md
  3. +0
    -40
      roles/thydel.patch/README.md
  4. +0
    -117
      roles/thydel.patch/library/patch
  5. +0
    -1
      roles/thydel.patch/meta/.galaxy_install_info
  6. +0
    -10
      roles/thydel.patch/meta/main.yml
  7. +0
    -1
      roles/thydel.patch/tasks/main.yml

+ 0
- 8
roles/thydel.patch/.gitignore 查看文件

@@ -1,8 +0,0 @@
.hg/
.hgignore
.hgremote
.gitconfig
.gitremote
.gitfirstcommit
.hgfirstcommit
README.html

+ 0
- 9
roles/thydel.patch/LICENSE.md 查看文件

@@ -1,9 +0,0 @@
The MIT License (MIT)

Copyright (c) 2014 Thierry Delamare

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 0
- 40
roles/thydel.patch/README.md 查看文件

@@ -1,40 +0,0 @@
# Patch

Ansible role to embed patch module

- Original `patch` module from
[luisperlaz/ansible-misc-modules](https://github.com/luisperlaz/ansible-misc-modules)

- Reorganize filetree to fit `galaxy` and new repos to get a better galaxy name.

- Patch module to support
[check-mode](https://github.com/thydel/ansible-misc-modules/commit/ecee1b0d830917bc2f88998f1e47deaca293f799)

## Example Playbook

After declaring `patch` role:

``` yaml
- hosts: all
roles:
- patch
```

You can use patch module:

``` yaml
- name: Patch some paramiko code
patch: patchfile=/tmp/critical.patch strip=1 basedir=/usr/share/pyshared/paramiko"
```

## Prerequisites:

GNU patch installed

## License

MIT

## Author Information

Thierry Delamare

+ 0
- 117
roles/thydel.patch/library/patch 查看文件

@@ -1,117 +0,0 @@
#!/usr/bin/python -tt

# (c) 2012, Luis Alberto Perez Lazaro <luisperlazaro@gmail.com>
#
# This module is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
#

DOCUMENTATION = '''
---
module: patch
author: Luis Alberto Perez Lazaro
version_added: 0.9
short_description: apply patch files
description:
- Apply patch files using the GNU patch tool. Before using this module make sure the patch tool is installed.
options:
patchfile:
required: true
description:
- A patch file as accepted by the gnu patch tool
strip:
required: true
aliases: [ p ]
description:
- Number that indicates the smallest prefix containing leading slashes that
will be stripped from each file name found in the patch file. For more information
see the strip parameter of the gnu patch tool.
basedir:
required: true
description:
- base directory in which the patch file will be applied
examples:
- code: "patch: patchfile=/tmp/critical.patch strip=1 basedir=/usr/share/pyshared/paramiko"
description: Example git checkout from Ansible Playbooks
'''

def _run(args):
cmd = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = cmd.communicate()
rc = cmd.returncode
return (rc, out, err)

def _is_already_applied(patch_file, strip):
reverse_cmd = "patch -s -R -N -p%s --dry-run < %s" % (strip, patch_file)
(rc, _, _) = _run(reverse_cmd)
return rc == 0

def _apply_patch(module, patch_file, strip):
patch_cmd = "patch -s -N -t -r - -p%s < %s" % (strip, patch_file)
(rc, out, err) = _run(patch_cmd)
if rc != 0:
msg = out if not err else err
module.fail_json(msg=msg)

def _get_params(module):
patchfile = os.path.expanduser(module.params['patchfile'])
strip = module.params['strip']
basedir = module.params['basedir']

if basedir:
os.chdir(os.path.expanduser(basedir))

if not os.path.exists(patchfile):
module.fail_json(msg="patchfile %s doesn't exist" % (patchfile))
if not os.access(patchfile, os.R_OK):
module.fail_json(msg="patchfile %s not readable" % (patchfile))

if not os.path.exists(basedir):
module.fail_json(msg="basedir %s doesn't exist" % (patchfile))

try:
strip = int(strip)
except Exception:
module.fail_json(msg="p must be a number")

return patchfile, strip, basedir

# ===========================================

def main():
module = AnsibleModule(
argument_spec = dict(
patchfile=dict(required=True),
basedir=dict(),
strip=dict(default=0, aliases=['p'])
),
supports_check_mode = True
)
patchfile, strip, basedir = _get_params(module)

changed = False

if module.check_mode:
if _is_already_applied(patchfile, strip):
module.exit_json(changed=changed)
module.exit_json(changed=True)

if not _is_already_applied(patchfile, strip):
_apply_patch(module, patchfile, strip)
changed = True

module.exit_json(changed=changed)

# include magic from lib/ansible/module_common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
main()

+ 0
- 1
roles/thydel.patch/meta/.galaxy_install_info 查看文件

@@ -1 +0,0 @@
{install_date: 'Mon Oct 5 13:52:12 2015', version: master}

+ 0
- 10
roles/thydel.patch/meta/main.yml 查看文件

@@ -1,10 +0,0 @@
---
galaxy_info:
author: Thierry Delamare
description: Embed patch module
company: EpiConcept
license: MIT
min_ansible_version: 1.3
categories:
- packaging
dependencies: []

+ 0
- 1
roles/thydel.patch/tasks/main.yml 查看文件

@@ -1 +0,0 @@
---

正在加载...
取消
保存