Compare commits

...

16 Commits
1.3.2 ... 1.3.4

Author SHA1 Message Date
Felix Fontein
8a9d18cc86 Release 1.3.4. 2021-01-14 16:07:29 +01:00
Felix Fontein
b7b69d918a Add release summary. 2021-01-14 16:06:02 +01:00
patchback[bot]
a3f08377b2 bitbucket_pipeline_variable: Hide secured values in console log (#1635) (#1637)
**SECURITY** - CVE-2021-20180

Hide user sensitive information which is marked as ``secured``
while logging in console.

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit 1d0c5e2ba4)

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-01-14 16:04:27 +01:00
patchback[bot]
4c9c8e0514 npm - handle json decode exception (#1625) (#1636)
* Provide a user friendly message by handling json decode
  exception rather than providing a stacktrace

Fixes: #1614

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit a9c64655de)

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-01-14 14:40:33 +01:00
Felix Fontein
3911b83145 Next release will be 1.3.4. 2021-01-13 13:19:40 +01:00
Felix Fontein
20e1d7c08b Release 1.3.3. 2021-01-13 12:31:11 +01:00
Felix Fontein
24aa8afde8 Add release summary. 2021-01-13 12:28:33 +01:00
patchback[bot]
71c6ec0b00 init_reconfigure fails on module cloud/misc/terraform.py (#1620) (#1629)
* fix reconfigure option

If `init_reconfigure` is true, the init fails because it is run as:
`terraform init -input=false - r e c o n f i g u r e`

* changelog fragment

* typo

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 9f4fd4c899)

Co-authored-by: christophemorio <49184206+christophemorio@users.noreply.github.com>
2021-01-13 11:12:50 +01:00
patchback[bot]
469e32e15b Remove bigmstone (#1626) (#1627)
Removing bigmstone from BOTMETA.

(cherry picked from commit 19fdb29db7)

Co-authored-by: Matthew Stone <dev@mattstone.io>
2021-01-12 17:52:50 +01:00
patchback[bot]
ebfb46aa78 Updated doc. Module not idempotent. delegate_to not needed. (#1587) (#1622)
(cherry picked from commit 63817f7c1b)

Co-authored-by: Vladimir Botka <vbotka@gmail.com>
2021-01-12 12:08:17 +01:00
patchback[bot]
fa2d2d6971 snmp_facts: Hide user sensitive information in console (#1621) (#1623)
**SECURITY** - CVE-2021-20178

Hide user sensitive information like `privkey` and `authkey`
while logging in console.

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit 3560aeb12f)

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-01-12 12:08:03 +01:00
patchback[bot]
a1429d0266 Skip monit tests on RHEL. (#1615) (#1617)
(cherry picked from commit 637571993a)

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-01-12 07:09:04 +01:00
Felix Fontein
3077ac770f chroot: re-enable connection chroot tests (#1591) (#1602)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit e7b16a96b9)

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-01-07 12:20:28 +01:00
patchback[bot]
7813cd751a hg: Re-enable tests (#1599) (#1600)
* Update license boilerplate
* Change mercurial repository links

Fixes: #840

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit 126c397d6c)

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-01-07 07:44:20 +01:00
Felix Fontein
4461c18957 Add kubevirt removal announcement. (#1594) 2021-01-05 18:41:02 -05:00
Felix Fontein
34cf93a538 Next release will be 1.3.3. 2021-01-04 18:26:38 +01:00
15 changed files with 230 additions and 64 deletions

2
.github/BOTMETA.yml vendored
View File

@@ -576,7 +576,7 @@ files:
$modules/net_tools/nmcli.py: $modules/net_tools/nmcli.py:
maintainers: alcamie101 maintainers: alcamie101
$modules/net_tools/snmp_facts.py: $modules/net_tools/snmp_facts.py:
maintainers: ogenstad bigmstone ujwalkomarla maintainers: ogenstad ujwalkomarla
$modules/notification/osx_say.py: $modules/notification/osx_say.py:
maintainers: ansible mpdehaan maintainers: ansible mpdehaan
labels: _osx_say labels: _osx_say

View File

@@ -5,6 +5,54 @@ Community General Release Notes
.. contents:: Topics .. contents:: Topics
v1.3.4
======
Release Summary
---------------
Bugfix/security release that addresses CVE-2021-20180.
Security Fixes
--------------
- bitbucket_pipeline_variable - **CVE-2021-20180** - hide user sensitive information which are marked as ``secured`` from logging into the console (https://github.com/ansible-collections/community.general/pull/1635).
Bugfixes
--------
- npm - handle json decode exception while parsing command line output (https://github.com/ansible-collections/community.general/issues/1614).
v1.3.3
======
Release Summary
---------------
Bugfix/security release that addresses CVE-2021-20178.
Major Changes
-------------
- For community.general 2.0.0, the kubevirt modules will be moved to the `community.kubevirt <https://galaxy.ansible.com/community/kubevirt>`_ collection.
A redirection will be inserted so that users using ansible-base 2.10 or newer do not have to change anything.
If you use Ansible 2.9 and explicitly use kubevirt modules from this collection, you will need to adjust your playbooks and roles to use FQCNs starting with ``community.kubevirt.`` instead of ``community.general.``,
for example replace ``community.general.kubevirt_vm`` in a task by ``community.kubevirt.kubevirt_vm``.
If you use ansible-base and installed ``community.general`` manually and rely on the kubevirt modules, you have to make sure to install the ``community.kubevirt`` collection as well.
If you are using FQCNs, for example ``community.general.kubevirt_vm`` instead of ``kubevirt_vm``, it will continue working, but we still recommend to adjust the FQCNs as well.
Security Fixes
--------------
- snmp_facts - **CVE-2021-20178** - hide user sensitive information such as ``privkey`` and ``authkey`` from logging into the console (https://github.com/ansible-collections/community.general/pull/1621).
Bugfixes
--------
- terraform - fix ``init_reconfigure`` option for proper CLI args (https://github.com/ansible-collections/community.general/pull/1620).
v1.3.2 v1.3.2
====== ======

View File

@@ -1764,3 +1764,54 @@ releases:
- jira_improvements.yaml - jira_improvements.yaml
- oc-migration.yml - oc-migration.yml
release_date: '2021-01-04' release_date: '2021-01-04'
1.3.3:
changes:
bugfixes:
- terraform - fix ``init_reconfigure`` option for proper CLI args (https://github.com/ansible-collections/community.general/pull/1620).
major_changes:
- 'For community.general 2.0.0, the kubevirt modules will be moved to the `community.kubevirt
<https://galaxy.ansible.com/community/kubevirt>`_ collection.
A redirection will be inserted so that users using ansible-base 2.10 or newer
do not have to change anything.
If you use Ansible 2.9 and explicitly use kubevirt modules from this collection,
you will need to adjust your playbooks and roles to use FQCNs starting with
``community.kubevirt.`` instead of ``community.general.``,
for example replace ``community.general.kubevirt_vm`` in a task by ``community.kubevirt.kubevirt_vm``.
If you use ansible-base and installed ``community.general`` manually and rely
on the kubevirt modules, you have to make sure to install the ``community.kubevirt``
collection as well.
If you are using FQCNs, for example ``community.general.kubevirt_vm`` instead
of ``kubevirt_vm``, it will continue working, but we still recommend to adjust
the FQCNs as well.
'
release_summary: Bugfix/security release that addresses CVE-2021-20178.
security_fixes:
- snmp_facts - **CVE-2021-20178** - hide user sensitive information such as
``privkey`` and ``authkey`` from logging into the console (https://github.com/ansible-collections/community.general/pull/1621).
fragments:
- 1.3.3.yml
- 1620-terraform_init_reconfigure_fix.yml
- kubevirt-migration.yml
- snmp_facts.yml
release_date: '2021-01-13'
1.3.4:
changes:
bugfixes:
- npm - handle json decode exception while parsing command line output (https://github.com/ansible-collections/community.general/issues/1614).
release_summary: Bugfix/security release that addresses CVE-2021-20180.
security_fixes:
- bitbucket_pipeline_variable - **CVE-2021-20180** - hide user sensitive information
which are marked as ``secured`` from logging into the console (https://github.com/ansible-collections/community.general/pull/1635).
fragments:
- 1.3.4.yml
- 1614_npm.yml
- cve_bitbucket_pipeline_variable.yml
release_date: '2021-01-14'

View File

@@ -1,6 +1,6 @@
namespace: community namespace: community
name: general name: general
version: 1.3.2 version: 1.3.4
readme: README.md readme: README.md
authors: authors:
- Ansible (https://github.com/ansible) - Ansible (https://github.com/ansible)

View File

@@ -219,7 +219,7 @@ def init_plugins(bin_path, project_path, backend_config, backend_config_files, i
for f in backend_config_files: for f in backend_config_files:
command.extend(['-backend-config', f]) command.extend(['-backend-config', f])
if init_reconfigure: if init_reconfigure:
command.extend('-reconfigure') command.extend(['-reconfigure'])
rc, out, err = module.run_command(command, cwd=project_path) rc, out, err = module.run_command(command, cwd=project_path)
if rc != 0: if rc != 0:
module.fail_json(msg="Failed to initialize Terraform modules:\r\n{0}".format(err)) module.fail_json(msg="Failed to initialize Terraform modules:\r\n{0}".format(err))

View File

@@ -19,6 +19,7 @@ module: nagios
short_description: Perform common tasks in Nagios related to downtime and notifications. short_description: Perform common tasks in Nagios related to downtime and notifications.
description: description:
- "The C(nagios) module has two basic functions: scheduling downtime and toggling alerts for services or hosts." - "The C(nagios) module has two basic functions: scheduling downtime and toggling alerts for services or hosts."
- The C(nagios) module is not idempotent.
- All actions require the I(host) parameter to be given explicitly. In playbooks you can use the C({{inventory_hostname}}) variable to refer - All actions require the I(host) parameter to be given explicitly. In playbooks you can use the C({{inventory_hostname}}) variable to refer
to the host the playbook is currently running on. to the host the playbook is currently running on.
- You can specify multiple services at once by separating them with commas, .e.g., C(services=httpd,nfs,puppet). - You can specify multiple services at once by separating them with commas, .e.g., C(services=httpd,nfs,puppet).
@@ -26,7 +27,6 @@ description:
e.g., C(service=host). This keyword may not be given with other services at the same time. e.g., C(service=host). This keyword may not be given with other services at the same time.
I(Setting alerts/downtime/acknowledge for a host does not affect alerts/downtime/acknowledge for any of the services running on it.) I(Setting alerts/downtime/acknowledge for a host does not affect alerts/downtime/acknowledge for any of the services running on it.)
To schedule downtime for all services on particular host use keyword "all", e.g., C(service=all). To schedule downtime for all services on particular host use keyword "all", e.g., C(service=all).
- When using the C(nagios) module you will need to specify your Nagios server using the C(delegate_to) parameter.
options: options:
action: action:
description: description:

View File

@@ -269,8 +269,8 @@ def main():
level=dict(type='str', choices=['authNoPriv', 'authPriv']), level=dict(type='str', choices=['authNoPriv', 'authPriv']),
integrity=dict(type='str', choices=['md5', 'sha']), integrity=dict(type='str', choices=['md5', 'sha']),
privacy=dict(type='str', choices=['aes', 'des']), privacy=dict(type='str', choices=['aes', 'des']),
authkey=dict(type='str'), authkey=dict(type='str', no_log=True),
privkey=dict(type='str'), privkey=dict(type='str', no_log=True),
), ),
required_together=( required_together=(
['username', 'level', 'integrity', 'authkey'], ['username', 'level', 'integrity', 'authkey'],

View File

@@ -7,39 +7,39 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = ''' DOCUMENTATION = r'''
--- ---
module: npm module: npm
short_description: Manage node.js packages with npm short_description: Manage node.js packages with npm
description: description:
- Manage node.js packages with Node Package Manager (npm) - Manage node.js packages with Node Package Manager (npm).
author: "Chris Hoffman (@chrishoffman)" author: "Chris Hoffman (@chrishoffman)"
options: options:
name: name:
description: description:
- The name of a node.js library to install - The name of a node.js library to install.
type: str type: str
required: false required: false
path: path:
description: description:
- The base path where to install the node.js libraries - The base path where to install the node.js libraries.
type: path type: path
required: false required: false
version: version:
description: description:
- The version to be installed - The version to be installed.
type: str type: str
required: false required: false
global: global:
description: description:
- Install the node.js library globally - Install the node.js library globally.
required: false required: false
default: no default: no
type: bool type: bool
executable: executable:
description: description:
- The executable location for npm. - The executable location for npm.
- This is useful if you are using a version manager, such as nvm - This is useful if you are using a version manager, such as nvm.
type: path type: path
required: false required: false
ignore_scripts: ignore_scripts:
@@ -55,12 +55,12 @@ options:
default: no default: no
ci: ci:
description: description:
- Install packages based on package-lock file, same as running npm ci - Install packages based on package-lock file, same as running C(npm ci).
type: bool type: bool
default: no default: no
production: production:
description: description:
- Install dependencies in production mode, excluding devDependencies - Install dependencies in production mode, excluding devDependencies.
required: false required: false
type: bool type: bool
default: no default: no
@@ -71,7 +71,7 @@ options:
type: str type: str
state: state:
description: description:
- The state of the node.js library - The state of the node.js library.
required: false required: false
type: str type: str
default: present default: present
@@ -80,7 +80,7 @@ requirements:
- npm installed in bin path (recommended /usr/local/bin) - npm installed in bin path (recommended /usr/local/bin)
''' '''
EXAMPLES = ''' EXAMPLES = r'''
- name: Install "coffee-script" node.js package. - name: Install "coffee-script" node.js package.
community.general.npm: community.general.npm:
name: coffee-script name: coffee-script
@@ -124,12 +124,12 @@ EXAMPLES = '''
state: present state: present
''' '''
import json
import os import os
import re import re
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils._text import to_native
import json
class Npm(object): class Npm(object):
@@ -155,7 +155,7 @@ class Npm(object):
else: else:
self.name_version = self.name self.name_version = self.name
def _exec(self, args, run_in_check_mode=False, check_rc=True): def _exec(self, args, run_in_check_mode=False, check_rc=True, add_package_name=True):
if not self.module.check_mode or (self.module.check_mode and run_in_check_mode): if not self.module.check_mode or (self.module.check_mode and run_in_check_mode):
cmd = self.executable + args cmd = self.executable + args
@@ -167,7 +167,7 @@ class Npm(object):
cmd.append('--ignore-scripts') cmd.append('--ignore-scripts')
if self.unsafe_perm: if self.unsafe_perm:
cmd.append('--unsafe-perm') cmd.append('--unsafe-perm')
if self.name: if self.name and add_package_name:
cmd.append(self.name_version) cmd.append(self.name_version)
if self.registry: if self.registry:
cmd.append('--registry') cmd.append('--registry')
@@ -191,7 +191,11 @@ class Npm(object):
installed = list() installed = list()
missing = list() missing = list()
data = json.loads(self._exec(cmd, True, False)) data = {}
try:
data = json.loads(self._exec(cmd, True, False, False) or '{}')
except (getattr(json, 'JSONDecodeError', ValueError)) as e:
self.module.fail_json(msg="Failed to parse NPM output with error %s" % to_native(e))
if 'dependencies' in data: if 'dependencies' in data:
for dep in data['dependencies']: for dep in data['dependencies']:
if 'missing' in data['dependencies'][dep] and data['dependencies'][dep]['missing']: if 'missing' in data['dependencies'][dep] and data['dependencies'][dep]['missing']:

View File

@@ -85,7 +85,7 @@ EXAMPLES = r'''
RETURN = r''' # ''' RETURN = r''' # '''
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule, _load_params
from ansible_collections.community.general.plugins.module_utils.source_control.bitbucket import BitbucketHelper from ansible_collections.community.general.plugins.module_utils.source_control.bitbucket import BitbucketHelper
error_messages = { error_messages = {
@@ -211,6 +211,14 @@ def delete_pipeline_variable(module, bitbucket, variable_uuid):
)) ))
class BitBucketPipelineVariable(AnsibleModule):
def __init__(self, *args, **kwargs):
params = _load_params() or {}
if params.get('secured'):
kwargs['argument_spec']['value'].update({'no_log': True})
super(BitBucketPipelineVariable, self).__init__(*args, **kwargs)
def main(): def main():
argument_spec = BitbucketHelper.bitbucket_argument_spec() argument_spec = BitbucketHelper.bitbucket_argument_spec()
argument_spec.update( argument_spec.update(
@@ -221,7 +229,7 @@ def main():
secured=dict(type='bool', default=False), secured=dict(type='bool', default=False),
state=dict(type='str', choices=['present', 'absent'], required=True), state=dict(type='str', choices=['present', 'absent'], required=True),
) )
module = AnsibleModule( module = BitBucketPipelineVariable(
argument_spec=argument_spec, argument_spec=argument_spec,
supports_check_mode=True, supports_check_mode=True,
) )

View File

@@ -1,3 +1,3 @@
needs/root needs/root
shippable/posix/group3 shippable/posix/group3
skip/macos # FIXME skip/macos # Skipped due to limitation of macOS 10.15 SIP, please read https://github.com/ansible-collections/community.general/issues/1017#issuecomment-755088895

View File

@@ -1,4 +1,3 @@
shippable/posix/group2 shippable/posix/group2
skip/python3 skip/python3
skip/aix skip/aix
disabled # tests use bitbucket, which dropped mercurial support on 2020-08-26 (https://bitbucket.org/blog/sunsetting-mercurial-support-in-bitbucket)

View File

@@ -4,22 +4,9 @@
#################################################################### ####################################################################
# test code for the hg module # test code for the hg module
# (c) 2014, James Tanner <tanner.jc@gmail.com> # Copyright: (c) 2014, James Tanner <tanner.jc@gmail.com>
# This file is part of Ansible
# #
# Ansible is free software: you can redistribute it and/or modify # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# 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.
#
# Ansible 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 Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: determine if mercurial is already installed - name: determine if mercurial is already installed
command: which hg command: which hg

View File

@@ -1,27 +1,16 @@
# test code for the hg module # test code for the hg module
# (c) 2018, Ansible Project # Copyright: (c) 2018, Ansible Project
# This file is part of Ansible
# #
# Ansible is free software: you can redistribute it and/or modify # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# 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.
#
# Ansible 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 Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: set where to extract the repo - name: set where to extract the repo
set_fact: checkout_dir={{ output_dir }}/epdb set_fact:
checkout_dir: "{{ output_dir }}/hg_project_test"
- name: set what repo to use - name: set what repo to use
set_fact: repo=https://bitbucket.org/rpathsync/epdb set_fact:
repo: "http://hg.pf.osdn.net/view/a/ak/akasurde/hg_project_test"
- name: clean out the output_dir - name: clean out the output_dir
shell: rm -rf {{ output_dir }}/* shell: rm -rf {{ output_dir }}/*
@@ -30,7 +19,9 @@
shell: which hg shell: which hg
- name: initial checkout - name: initial checkout
hg: repo={{ repo }} dest={{ checkout_dir }} hg:
repo: "{{ repo }}"
dest: "{{ checkout_dir }}"
register: hg_result register: hg_result
- debug: var=hg_result - debug: var=hg_result
@@ -46,17 +37,21 @@
- "hg_result.changed" - "hg_result.changed"
- name: repeated checkout - name: repeated checkout
hg: repo={{ repo }} dest={{ checkout_dir }} hg:
repo: "{{ repo }}"
dest: "{{ checkout_dir }}"
register: hg_result2 register: hg_result2
- debug: var=hg_result2 - debug: var=hg_result2
- name: check for tags - name: check for tags
stat: path={{ checkout_dir }}/.hgtags stat:
path: "{{ checkout_dir }}/.hgtags"
register: tags register: tags
- name: check for remotes - name: check for remotes
stat: path={{ checkout_dir }}/.hg/branch stat:
path: "{{ checkout_dir }}/.hg/branch"
register: branches register: branches
- debug: var=tags - debug: var=tags
@@ -68,13 +63,16 @@
- "tags.stat.isreg" - "tags.stat.isreg"
- "branches.stat.isreg" - "branches.stat.isreg"
- name: verify on a reclone things are marked unchanged - name: verify on a re-clone things are marked unchanged
assert: assert:
that: that:
- "not hg_result2.changed" - "not hg_result2.changed"
- name: Checkout non-existent repo clone - name: Checkout non-existent repo clone
hg: repo=https://bitbucket.org/pyro46/pythonscript_1 clone=no update=no hg:
repo: "http://hg.pf.osdn.net/view/a/ak/akasurde/hg_project_test_1"
clone: no
update: no
register: hg_result3 register: hg_result3
ignore_errors: true ignore_errors: true

View File

@@ -6,3 +6,4 @@ skip/macos
skip/freebsd skip/freebsd
skip/aix skip/aix
skip/python2.6 # python-daemon package used in integration tests requires >=2.7 skip/python2.6 # python-daemon package used in integration tests requires >=2.7
skip/rhel # FIXME

View File

@@ -0,0 +1,70 @@
#
# Copyright: (c) 2021, Abhijeet Kasurde <akasurde@redhat.com>
# 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)
__metaclass__ = type
from ansible_collections.community.general.tests.unit.compat.mock import call, patch
from ansible_collections.community.general.plugins.modules.packaging.language import npm
from ansible_collections.community.general.tests.unit.plugins.modules.utils import (
AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args)
class NPMModuleTestCase(ModuleTestCase):
module = npm
def setUp(self):
super(NPMModuleTestCase, self).setUp()
ansible_module_path = "ansible_collections.community.general.plugins.modules.packaging.language.npm.AnsibleModule"
self.mock_run_command = patch('%s.run_command' % ansible_module_path)
self.module_main_command = self.mock_run_command.start()
self.mock_get_bin_path = patch('%s.get_bin_path' % ansible_module_path)
self.get_bin_path = self.mock_get_bin_path.start()
self.get_bin_path.return_value = '/testbin/npm'
def tearDown(self):
self.mock_run_command.stop()
self.mock_get_bin_path.stop()
super(NPMModuleTestCase, self).tearDown()
def module_main(self, exit_exc):
with self.assertRaises(exit_exc) as exc:
self.module.main()
return exc.exception.args[0]
def test_present(self):
set_module_args({
'name': 'coffee-script',
'global': 'true',
'state': 'present'
})
self.module_main_command.side_effect = [
(0, '{}', ''),
(0, '{}', ''),
]
result = self.module_main(AnsibleExitJson)
self.assertTrue(result['changed'])
self.module_main_command.assert_has_calls([
call(['/testbin/npm', 'list', '--json', '--long', '--global'], check_rc=False, cwd=None),
])
def test_absent(self):
set_module_args({
'name': 'coffee-script',
'global': 'true',
'state': 'absent'
})
self.module_main_command.side_effect = [
(0, '{"dependencies": {"coffee-script": {}}}', ''),
(0, '{}', ''),
]
result = self.module_main(AnsibleExitJson)
self.assertTrue(result['changed'])
self.module_main_command.assert_has_calls([
call(['/testbin/npm', 'uninstall', '--global', 'coffee-script'], check_rc=True, cwd=None),
])