|
|
@ -1,115 +1,98 @@
|
|
|
|
#!/usr/bin/python
|
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
|
|
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
|
|
|
|
# Copyright: (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
__metaclass__ = type
|
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
|
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
|
|
'status': ['preview'],
|
|
|
|
'status': ['preview'],
|
|
|
|
'supported_by': 'core'}
|
|
|
|
'supported_by': 'core'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DOCUMENTATION = '''
|
|
|
|
DOCUMENTATION = '''
|
|
|
|
---
|
|
|
|
---
|
|
|
|
module: subversion
|
|
|
|
module: subversion
|
|
|
|
short_description: Deploys a subversion repository.
|
|
|
|
short_description: Deploys a subversion repository
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Deploy given repository URL / revision to dest. If dest exists, update to the specified revision, otherwise perform a checkout.
|
|
|
|
- Deploy given repository URL / revision to dest. If dest exists, update to the specified revision, otherwise perform a checkout.
|
|
|
|
version_added: "0.7"
|
|
|
|
version_added: "0.7"
|
|
|
|
author: "Dane Summers (@dsummersl) <njharman@gmail.com>"
|
|
|
|
author:
|
|
|
|
|
|
|
|
- Dane Summers (@dsummersl) <njharman@gmail.com>
|
|
|
|
notes:
|
|
|
|
notes:
|
|
|
|
- Requires I(svn) to be installed on the client.
|
|
|
|
- Requires I(svn) to be installed on the client.
|
|
|
|
- This module does not handle externals
|
|
|
|
- This module does not handle externals.
|
|
|
|
requirements: []
|
|
|
|
|
|
|
|
options:
|
|
|
|
options:
|
|
|
|
repo:
|
|
|
|
repo:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The subversion URL to the repository.
|
|
|
|
- The subversion URL to the repository.
|
|
|
|
required: true
|
|
|
|
required: true
|
|
|
|
aliases: [ name, repository ]
|
|
|
|
aliases: [ name, repository ]
|
|
|
|
default: null
|
|
|
|
|
|
|
|
dest:
|
|
|
|
dest:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Absolute path where the repository should be deployed.
|
|
|
|
- Absolute path where the repository should be deployed.
|
|
|
|
required: true
|
|
|
|
required: true
|
|
|
|
default: null
|
|
|
|
|
|
|
|
revision:
|
|
|
|
revision:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Specific revision to checkout.
|
|
|
|
- Specific revision to checkout.
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: HEAD
|
|
|
|
default: HEAD
|
|
|
|
aliases: [ version ]
|
|
|
|
aliases: [ version ]
|
|
|
|
force:
|
|
|
|
force:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- If C(yes), modified files will be discarded. If C(no), module will fail if it encounters modified files.
|
|
|
|
- If C(yes), modified files will be discarded. If C(no), module will fail if it encounters modified files.
|
|
|
|
Prior to 1.9 the default was `yes`.
|
|
|
|
Prior to 1.9 the default was C(yes).
|
|
|
|
required: false
|
|
|
|
type: bool
|
|
|
|
default: "no"
|
|
|
|
default: "no"
|
|
|
|
choices: [ "yes", "no" ]
|
|
|
|
|
|
|
|
username:
|
|
|
|
username:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- --username parameter passed to svn.
|
|
|
|
- C(--username) parameter passed to svn.
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: null
|
|
|
|
|
|
|
|
password:
|
|
|
|
password:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- --password parameter passed to svn.
|
|
|
|
- C(--password) parameter passed to svn.
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: null
|
|
|
|
|
|
|
|
executable:
|
|
|
|
executable:
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: null
|
|
|
|
|
|
|
|
version_added: "1.4"
|
|
|
|
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Path to svn executable to use. If not supplied,
|
|
|
|
- Path to svn executable to use. If not supplied,
|
|
|
|
the normal mechanism for resolving binary paths will be used.
|
|
|
|
the normal mechanism for resolving binary paths will be used.
|
|
|
|
|
|
|
|
version_added: "1.4"
|
|
|
|
checkout:
|
|
|
|
checkout:
|
|
|
|
required: false
|
|
|
|
description:
|
|
|
|
|
|
|
|
- If C(no), do not check out the repository if it does not exist locally.
|
|
|
|
|
|
|
|
type: bool
|
|
|
|
default: "yes"
|
|
|
|
default: "yes"
|
|
|
|
choices: [ "yes", "no" ]
|
|
|
|
|
|
|
|
version_added: "2.3"
|
|
|
|
version_added: "2.3"
|
|
|
|
description:
|
|
|
|
|
|
|
|
- If no, do not check out the repository if it does not exist locally
|
|
|
|
|
|
|
|
update:
|
|
|
|
update:
|
|
|
|
required: false
|
|
|
|
description:
|
|
|
|
|
|
|
|
- If C(no), do not retrieve new revisions from the origin repository.
|
|
|
|
|
|
|
|
type: bool
|
|
|
|
default: "yes"
|
|
|
|
default: "yes"
|
|
|
|
choices: [ "yes", "no" ]
|
|
|
|
|
|
|
|
version_added: "2.3"
|
|
|
|
version_added: "2.3"
|
|
|
|
description:
|
|
|
|
|
|
|
|
- If no, do not retrieve new revisions from the origin repository
|
|
|
|
|
|
|
|
export:
|
|
|
|
export:
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: "no"
|
|
|
|
|
|
|
|
choices: [ "yes", "no" ]
|
|
|
|
|
|
|
|
version_added: "1.6"
|
|
|
|
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- If C(yes), do export instead of checkout/update.
|
|
|
|
- If C(yes), do export instead of checkout/update.
|
|
|
|
|
|
|
|
type: bool
|
|
|
|
|
|
|
|
default: "no"
|
|
|
|
|
|
|
|
version_added: "1.6"
|
|
|
|
switch:
|
|
|
|
switch:
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: "yes"
|
|
|
|
|
|
|
|
choices: [ "yes", "no" ]
|
|
|
|
|
|
|
|
version_added: "2.0"
|
|
|
|
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- If C(no), do not call svn switch before update.
|
|
|
|
- If C(no), do not call svn switch before update.
|
|
|
|
|
|
|
|
default: "yes"
|
|
|
|
|
|
|
|
version_added: "2.0"
|
|
|
|
|
|
|
|
type: bool
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
|
|
|
EXAMPLES = '''
|
|
|
|
# Checkout subversion repository to specified folder.
|
|
|
|
- name: Checkout subversion repository to specified folder
|
|
|
|
- subversion:
|
|
|
|
subversion:
|
|
|
|
repo: svn+ssh://an.example.org/path/to/repo
|
|
|
|
repo: svn+ssh://an.example.org/path/to/repo
|
|
|
|
dest: /src/checkout
|
|
|
|
dest: /src/checkout
|
|
|
|
|
|
|
|
|
|
|
|
# Export subversion directory to folder
|
|
|
|
- name: Export subversion directory to folder
|
|
|
|
- subversion:
|
|
|
|
subversion:
|
|
|
|
repo: svn+ssh://an.example.org/path/to/repo
|
|
|
|
repo: svn+ssh://an.example.org/path/to/repo
|
|
|
|
dest: /src/export
|
|
|
|
dest: /src/export
|
|
|
|
|
|
|
|
|
|
|
|
# Example just get information about the repository whether or not it has
|
|
|
|
- name: Get information about the repository whether or not it has already been cloned locally
|
|
|
|
# already been cloned locally.
|
|
|
|
|
|
|
|
- subversion:
|
|
|
|
- subversion:
|
|
|
|
repo: svn+ssh://an.example.org/path/to/repo
|
|
|
|
repo: svn+ssh://an.example.org/path/to/repo
|
|
|
|
dest: /srv/checkout
|
|
|
|
dest: /srv/checkout
|
|
|
@ -124,8 +107,7 @@ from ansible.module_utils.basic import AnsibleModule
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Subversion(object):
|
|
|
|
class Subversion(object):
|
|
|
|
def __init__(
|
|
|
|
def __init__(self, module, dest, repo, revision, username, password, svn_path):
|
|
|
|
self, module, dest, repo, revision, username, password, svn_path):
|
|
|
|
|
|
|
|
self.module = module
|
|
|
|
self.module = module
|
|
|
|
self.dest = dest
|
|
|
|
self.dest = dest
|
|
|
|
self.repo = repo
|
|
|
|
self.repo = repo
|
|
|
@ -218,24 +200,22 @@ class Subversion(object):
|
|
|
|
return change, curr, head
|
|
|
|
return change, curr, head
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ===========================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
module = AnsibleModule(
|
|
|
|
module = AnsibleModule(
|
|
|
|
argument_spec=dict(
|
|
|
|
argument_spec=dict(
|
|
|
|
dest=dict(type='path'),
|
|
|
|
dest=dict(type='path'),
|
|
|
|
repo=dict(required=True, aliases=['name', 'repository']),
|
|
|
|
repo=dict(type='str', required=True, aliases=['name', 'repository']),
|
|
|
|
revision=dict(default='HEAD', aliases=['rev', 'version']),
|
|
|
|
revision=dict(type='str', default='HEAD', aliases=['rev', 'version']),
|
|
|
|
force=dict(default='no', type='bool'),
|
|
|
|
force=dict(type='bool', default=False),
|
|
|
|
username=dict(required=False),
|
|
|
|
username=dict(type='str'),
|
|
|
|
password=dict(required=False, no_log=True),
|
|
|
|
password=dict(type='str', no_log=True),
|
|
|
|
executable=dict(default=None, type='path'),
|
|
|
|
executable=dict(type='path'),
|
|
|
|
export=dict(default=False, required=False, type='bool'),
|
|
|
|
export=dict(type='bool', default=False),
|
|
|
|
checkout=dict(default=True, required=False, type='bool'),
|
|
|
|
checkout=dict(type='bool', default=True),
|
|
|
|
update=dict(default=True, required=False, type='bool'),
|
|
|
|
update=dict(type='bool', default=True),
|
|
|
|
switch=dict(default=True, required=False, type='bool'),
|
|
|
|
switch=dict(type='bool', default=True),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
supports_check_mode=True
|
|
|
|
supports_check_mode=True,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
dest = module.params['dest']
|
|
|
|
dest = module.params['dest']
|
|
|
|