parent
a40bf06992
commit
16cb0e979d
1 changed files with 65 additions and 65 deletions
|
@ -129,81 +129,81 @@ EXAMPLES='''
|
||||||
|
|
||||||
|
|
||||||
def get_bundler_executable(module):
|
def get_bundler_executable(module):
|
||||||
if module.params.get('executable'):
|
if module.params.get('executable'):
|
||||||
return module.params.get('executable').split(' ')
|
return module.params.get('executable').split(' ')
|
||||||
else:
|
else:
|
||||||
return [ module.get_bin_path('bundle', True) ]
|
return [ module.get_bin_path('bundle', True) ]
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
executable=dict(default=None, required=False),
|
executable=dict(default=None, required=False),
|
||||||
state=dict(default='present', required=False, choices=['present', 'latest']),
|
state=dict(default='present', required=False, choices=['present', 'latest']),
|
||||||
chdir=dict(default=None, required=False),
|
chdir=dict(default=None, required=False),
|
||||||
exclude_groups=dict(default=None, required=False, type='list'),
|
exclude_groups=dict(default=None, required=False, type='list'),
|
||||||
clean=dict(default=False, required=False, type='bool'),
|
clean=dict(default=False, required=False, type='bool'),
|
||||||
gemfile=dict(default=None, required=False),
|
gemfile=dict(default=None, required=False),
|
||||||
local=dict(default=False, required=False, type='bool'),
|
local=dict(default=False, required=False, type='bool'),
|
||||||
deployment_mode=dict(default=False, required=False, type='bool'),
|
deployment_mode=dict(default=False, required=False, type='bool'),
|
||||||
user_install=dict(default=True, required=False, type='bool'),
|
user_install=dict(default=True, required=False, type='bool'),
|
||||||
gem_path=dict(default=None, required=False),
|
gem_path=dict(default=None, required=False),
|
||||||
binstub_directory=dict(default=None, required=False),
|
binstub_directory=dict(default=None, required=False),
|
||||||
extra_args=dict(default=None, required=False),
|
extra_args=dict(default=None, required=False),
|
||||||
),
|
),
|
||||||
supports_check_mode=True
|
supports_check_mode=True
|
||||||
)
|
)
|
||||||
|
|
||||||
executable = module.params.get('executable')
|
executable = module.params.get('executable')
|
||||||
state = module.params.get('state')
|
state = module.params.get('state')
|
||||||
chdir = module.params.get('chdir')
|
chdir = module.params.get('chdir')
|
||||||
exclude_groups = module.params.get('exclude_groups')
|
exclude_groups = module.params.get('exclude_groups')
|
||||||
clean = module.params.get('clean')
|
clean = module.params.get('clean')
|
||||||
gemfile = module.params.get('gemfile')
|
gemfile = module.params.get('gemfile')
|
||||||
local = module.params.get('local')
|
local = module.params.get('local')
|
||||||
deployment_mode = module.params.get('deployment_mode')
|
deployment_mode = module.params.get('deployment_mode')
|
||||||
user_install = module.params.get('user_install')
|
user_install = module.params.get('user_install')
|
||||||
gem_path = module.params.get('gem_install_path')
|
gem_path = module.params.get('gem_install_path')
|
||||||
binstub_directory = module.params.get('binstub_directory')
|
binstub_directory = module.params.get('binstub_directory')
|
||||||
extra_args = module.params.get('extra_args')
|
extra_args = module.params.get('extra_args')
|
||||||
|
|
||||||
cmd = get_bundler_executable(module)
|
cmd = get_bundler_executable(module)
|
||||||
|
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
cmd.append('check')
|
cmd.append('check')
|
||||||
rc, out, err = module.run_command(cmd, cwd=chdir, check_rc=False)
|
rc, out, err = module.run_command(cmd, cwd=chdir, check_rc=False)
|
||||||
|
|
||||||
module.exit_json(changed=rc != 0, state=state, stdout=out, stderr=err)
|
module.exit_json(changed=rc != 0, state=state, stdout=out, stderr=err)
|
||||||
|
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
cmd.append('install')
|
cmd.append('install')
|
||||||
if exclude_groups:
|
if exclude_groups:
|
||||||
cmd.extend(['--without', ':'.join(exclude_groups)])
|
cmd.extend(['--without', ':'.join(exclude_groups)])
|
||||||
if clean:
|
if clean:
|
||||||
cmd.append('--clean')
|
cmd.append('--clean')
|
||||||
if gemfile:
|
if gemfile:
|
||||||
cmd.extend(['--gemfile', gemfile])
|
cmd.extend(['--gemfile', gemfile])
|
||||||
if local:
|
if local:
|
||||||
cmd.append('--local')
|
cmd.append('--local')
|
||||||
if deployment_mode:
|
if deployment_mode:
|
||||||
cmd.append('--deployment')
|
cmd.append('--deployment')
|
||||||
if not user_install:
|
if not user_install:
|
||||||
cmd.append('--system')
|
cmd.append('--system')
|
||||||
if gem_path:
|
if gem_path:
|
||||||
cmd.extend(['--path', gem_path])
|
cmd.extend(['--path', gem_path])
|
||||||
if binstub_directory:
|
if binstub_directory:
|
||||||
cmd.extend(['--binstubs', binstub_directory])
|
cmd.extend(['--binstubs', binstub_directory])
|
||||||
else:
|
else:
|
||||||
cmd.append('update')
|
cmd.append('update')
|
||||||
if local:
|
if local:
|
||||||
cmd.append('--local')
|
cmd.append('--local')
|
||||||
|
|
||||||
if extra_args:
|
if extra_args:
|
||||||
cmd.extend(extra_args.split(' '))
|
cmd.extend(extra_args.split(' '))
|
||||||
|
|
||||||
rc, out, err = module.run_command(cmd, cwd=chdir, check_rc=True)
|
rc, out, err = module.run_command(cmd, cwd=chdir, check_rc=True)
|
||||||
|
|
||||||
module.exit_json(changed='Installing' in out, state=state, stdout=out, stderr=err)
|
module.exit_json(changed='Installing' in out, state=state, stdout=out, stderr=err)
|
||||||
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import *
|
from ansible.module_utils.basic import *
|
||||||
|
|
Loading…
Reference in a new issue