2012-08-04 22:07:39 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2012-12-11 10:23:37 +00:00
|
|
|
'''
|
|
|
|
:codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)`
|
2013-09-16 16:24:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
tests.integration.shell.call
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2012-12-11 10:23:37 +00:00
|
|
|
'''
|
2012-08-04 22:07:39 +00:00
|
|
|
|
2012-12-01 23:00:27 +00:00
|
|
|
# Import python libs
|
2014-11-21 19:05:13 +00:00
|
|
|
from __future__ import absolute_import
|
2016-06-28 21:10:11 +00:00
|
|
|
import getpass
|
2012-12-01 23:00:27 +00:00
|
|
|
import os
|
2012-08-04 22:07:39 +00:00
|
|
|
import sys
|
2014-02-20 01:47:17 +00:00
|
|
|
import re
|
2013-09-13 16:12:11 +00:00
|
|
|
import shutil
|
2012-12-01 23:00:27 +00:00
|
|
|
import yaml
|
|
|
|
from datetime import datetime
|
[develop] Merge forward from 2016.3 to develop (#33193)
* Add run_on_start docs to schedule.rst (#32958)
Fixes #22580
* Backport #33021 manually to 2015.5 (#33044)
* Saltfile with pillar tests (#33045)
* add file.managed with pillar data tests
* do not require git for other tests
* Fix minor document error of test.assertion (#33067)
* test pillar.items output (#33060)
* File and User test fixes for 2015.5 on Fedora23 (#33055)
* Fix file_test.test_symlink on 2015.5
* Fix failing user present test
* add test for installing package while using salt-call --local (#33025)
* add test for installing package while using salt-call --local
* fix pylint
* ssh docs: install py-2.6 for RHEL 5
* Bugfix: Restore boolean values from the repo configuration
* Add test data for repos
* Add repo config test
* Bugfix (follow-up): setting priority requires non-positive integer
* modules.npm: do not log npm --version at info level (#33084)
* salt-cloud: fix ipv6-only virtual machines (#32865)
* salt-cloud: fix ipv6-only virtual machines
* fix hostname for rsync fallback in scp_file function
* use 4 spaces instead of 2
* remove global variable, use direct socket call instead
* Use saltstack repo in buildpackage.py on CentOS 5 (#33080)
* Lower display of msgpack failure msg to debug (#33078)
Closes #33074
* cloud.query needs to define mapper.opts (#33098)
* clarify docs that map is designed to be run once. is not stateful (#33102)
* Moved _finger_fail method to parent class.
Method _finger_fail method from SAuth to AsyncAuth class to make method available
in both class and fix an issue where _finger_Fail is called inside AsyncAuth.
* Fix 33058 (#33099)
* Fix servermanager module
- Added check for 2008 version of windows
- Added Import-Module ServerManager to _pshell_json.
Apparently this needs to run each time we issue a
servermanager command.
* Fix list_available
* salt.utils.gitfs: fix formatting for warning messages (#33064)
* salt.utils.gitfs: fix formatting for warning messages
When git_pillar support was added to salt.utils.gitfs, the
recommendation globals had string formatting placeholders added to them,
but the locations where these values are referenced do not call
``.format()`` to properly replace them. This commit fixes that
oversight.
* Remove more gitfs and master-specific wording from log messages
* Add a check that the cmdline of the found proc matches (#33129)
* Doc mock decorators (#33132)
* Add mock function for mocking decorators
* Mock the stdlib user module because importing it will open the repl
* Fix broken parsing of usermgmt.conf on OpenBSD (#33135)
When creating a new user, if a group of the same name already exists,
the usermgmt.conf file is consulted to determine the primary group.
It's in these cases that the parsing bug is triggered.
This code change addresses several of the existing issues:
- The previous split statement explicitly specified a single space.
Since a config line may have any number of spaces and/or tabs
surrounding the entries, the resulting array's elements may be
incorrect.
- According to the man pages for usermgmt.conf, the "group" config
entry accpets a single parameter -- so we shouldn't iterate.
- The "val[1]" was returning the 2nd letter of each word and not the
second word on the config line as intended.
* Move salt-ssh thin dir location to /var/tmp (#33130)
* Move salt-ssh thin dir location to /var/tmp
Closes #32771
* Remove performance penelty language
* If cache_jobs: True is set, populate the local job cache when running salt-call (#33100)
* If cache_jobs: True is set, populate the local job cache
Fixes #32834
Allows a masterless minion to query the job cache.
* Refactor cache_jobs functionality to be DRY
* Skipping salt-call --local test
* Back-port #31769 to 2015.8 (#33139)
* Handle empty acl_name in linux_acl state
Calls to setfacl interpret an empty group or user name to mean to be the
owner of the file they're operating on. For example, for a directory
owned by group 'admin', the ACL 'default:group::rwx' is equivalent to
'default:group:admin:rwx'.
The output of the getfacl execution module returns ACLs in the format of
'group:admin:rwx' instead of 'group::rwx'. This commit changes the
acl.present state to look for the owner of the file if the acl_name
paremeter is empty.
* Fix acl.present/acl.absent changing default ACLs
The behaviour of the acl.present and acl.absent is to check the data
structure returned by getfacl contains a key by the name of acl_type.
However, this data structure does not contain any default ACLs if none
exist, so this check will fail. We omit the check if a default ACL was
passed into the state functions.
Unfortunately, the call to modfacl may fail if the user passes in an
acl_type such as 'default:random'. In this case the state will appear to
succeed, but do nothing.
This fixes the state module to allow setting default ACLs on files which
have none.
* Fix regression in 2016.3 HEAD when version is specified (#33146)
Resolves #33013.
* Hash fileclients by opts (#33142)
* Hash fileclients by opts
There was an issue whereby the cache of the fileclient was being overwritten
by dueling minion instances in multimaster mode. This protects them by hashing
by the id of opts.
Closes #25040
* Silly typo!
* Remove tests which do not test any actual functionality or are too tightly coupled to the implementation
* Strip ldap fqdn (#33127)
* Add option to strip off domain names on computer names that come from LDAP/AD
* Add strip_domains option for ldap.
* Add documentation for auth.ldap.minion_stripdomains.
* [2015.5] Update to latest bootstrap script v2016.05.10 (#33155)
* [2015.8] Update to latest bootstrap script v2016.05.10 (#33156)
* [2016.3] Update to latest bootstrap script v2016.05.10 (#33157)
* add 2015.5.11 release notes (#33160)
* add 2015.8.9 release notes (#33161)
* Pip fix (#33180)
* fix pip!!
* make it work with old pip as well
* Added resiliency
* Don't need to check, just get the right name
* [2015.5] Update to latest bootstrap script v2016.05.11 (#33185)
2016-05-12 14:53:39 +00:00
|
|
|
import logging
|
2012-08-04 22:07:39 +00:00
|
|
|
|
2013-06-24 22:53:59 +00:00
|
|
|
# Import Salt Testing libs
|
|
|
|
from salttesting import skipIf
|
2013-06-27 12:20:06 +00:00
|
|
|
from salttesting.helpers import ensure_in_syspath
|
2016-06-28 21:10:11 +00:00
|
|
|
from salttesting.helpers import (
|
|
|
|
destructiveTest
|
|
|
|
)
|
2013-06-27 12:20:06 +00:00
|
|
|
ensure_in_syspath('../../')
|
|
|
|
|
|
|
|
import integration
|
2016-06-28 21:10:11 +00:00
|
|
|
from integration.utils import testprogram
|
|
|
|
|
|
|
|
# Import salt libs
|
2014-08-20 01:41:35 +00:00
|
|
|
import salt.utils
|
2016-06-28 21:10:11 +00:00
|
|
|
import salt.ext.six as six
|
[develop] Merge forward from 2016.3 to develop (#33193)
* Add run_on_start docs to schedule.rst (#32958)
Fixes #22580
* Backport #33021 manually to 2015.5 (#33044)
* Saltfile with pillar tests (#33045)
* add file.managed with pillar data tests
* do not require git for other tests
* Fix minor document error of test.assertion (#33067)
* test pillar.items output (#33060)
* File and User test fixes for 2015.5 on Fedora23 (#33055)
* Fix file_test.test_symlink on 2015.5
* Fix failing user present test
* add test for installing package while using salt-call --local (#33025)
* add test for installing package while using salt-call --local
* fix pylint
* ssh docs: install py-2.6 for RHEL 5
* Bugfix: Restore boolean values from the repo configuration
* Add test data for repos
* Add repo config test
* Bugfix (follow-up): setting priority requires non-positive integer
* modules.npm: do not log npm --version at info level (#33084)
* salt-cloud: fix ipv6-only virtual machines (#32865)
* salt-cloud: fix ipv6-only virtual machines
* fix hostname for rsync fallback in scp_file function
* use 4 spaces instead of 2
* remove global variable, use direct socket call instead
* Use saltstack repo in buildpackage.py on CentOS 5 (#33080)
* Lower display of msgpack failure msg to debug (#33078)
Closes #33074
* cloud.query needs to define mapper.opts (#33098)
* clarify docs that map is designed to be run once. is not stateful (#33102)
* Moved _finger_fail method to parent class.
Method _finger_fail method from SAuth to AsyncAuth class to make method available
in both class and fix an issue where _finger_Fail is called inside AsyncAuth.
* Fix 33058 (#33099)
* Fix servermanager module
- Added check for 2008 version of windows
- Added Import-Module ServerManager to _pshell_json.
Apparently this needs to run each time we issue a
servermanager command.
* Fix list_available
* salt.utils.gitfs: fix formatting for warning messages (#33064)
* salt.utils.gitfs: fix formatting for warning messages
When git_pillar support was added to salt.utils.gitfs, the
recommendation globals had string formatting placeholders added to them,
but the locations where these values are referenced do not call
``.format()`` to properly replace them. This commit fixes that
oversight.
* Remove more gitfs and master-specific wording from log messages
* Add a check that the cmdline of the found proc matches (#33129)
* Doc mock decorators (#33132)
* Add mock function for mocking decorators
* Mock the stdlib user module because importing it will open the repl
* Fix broken parsing of usermgmt.conf on OpenBSD (#33135)
When creating a new user, if a group of the same name already exists,
the usermgmt.conf file is consulted to determine the primary group.
It's in these cases that the parsing bug is triggered.
This code change addresses several of the existing issues:
- The previous split statement explicitly specified a single space.
Since a config line may have any number of spaces and/or tabs
surrounding the entries, the resulting array's elements may be
incorrect.
- According to the man pages for usermgmt.conf, the "group" config
entry accpets a single parameter -- so we shouldn't iterate.
- The "val[1]" was returning the 2nd letter of each word and not the
second word on the config line as intended.
* Move salt-ssh thin dir location to /var/tmp (#33130)
* Move salt-ssh thin dir location to /var/tmp
Closes #32771
* Remove performance penelty language
* If cache_jobs: True is set, populate the local job cache when running salt-call (#33100)
* If cache_jobs: True is set, populate the local job cache
Fixes #32834
Allows a masterless minion to query the job cache.
* Refactor cache_jobs functionality to be DRY
* Skipping salt-call --local test
* Back-port #31769 to 2015.8 (#33139)
* Handle empty acl_name in linux_acl state
Calls to setfacl interpret an empty group or user name to mean to be the
owner of the file they're operating on. For example, for a directory
owned by group 'admin', the ACL 'default:group::rwx' is equivalent to
'default:group:admin:rwx'.
The output of the getfacl execution module returns ACLs in the format of
'group:admin:rwx' instead of 'group::rwx'. This commit changes the
acl.present state to look for the owner of the file if the acl_name
paremeter is empty.
* Fix acl.present/acl.absent changing default ACLs
The behaviour of the acl.present and acl.absent is to check the data
structure returned by getfacl contains a key by the name of acl_type.
However, this data structure does not contain any default ACLs if none
exist, so this check will fail. We omit the check if a default ACL was
passed into the state functions.
Unfortunately, the call to modfacl may fail if the user passes in an
acl_type such as 'default:random'. In this case the state will appear to
succeed, but do nothing.
This fixes the state module to allow setting default ACLs on files which
have none.
* Fix regression in 2016.3 HEAD when version is specified (#33146)
Resolves #33013.
* Hash fileclients by opts (#33142)
* Hash fileclients by opts
There was an issue whereby the cache of the fileclient was being overwritten
by dueling minion instances in multimaster mode. This protects them by hashing
by the id of opts.
Closes #25040
* Silly typo!
* Remove tests which do not test any actual functionality or are too tightly coupled to the implementation
* Strip ldap fqdn (#33127)
* Add option to strip off domain names on computer names that come from LDAP/AD
* Add strip_domains option for ldap.
* Add documentation for auth.ldap.minion_stripdomains.
* [2015.5] Update to latest bootstrap script v2016.05.10 (#33155)
* [2015.8] Update to latest bootstrap script v2016.05.10 (#33156)
* [2016.3] Update to latest bootstrap script v2016.05.10 (#33157)
* add 2015.5.11 release notes (#33160)
* add 2015.8.9 release notes (#33161)
* Pip fix (#33180)
* fix pip!!
* make it work with old pip as well
* Added resiliency
* Don't need to check, just get the right name
* [2015.5] Update to latest bootstrap script v2016.05.11 (#33185)
2016-05-12 14:53:39 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
_PKG_TARGETS = {
|
|
|
|
'Arch': ['python2-django', 'libpng'],
|
|
|
|
'Debian': ['python-plist', 'apg'],
|
|
|
|
'RedHat': ['xz-devel', 'zsh-html'],
|
|
|
|
'FreeBSD': ['aalib', 'pth'],
|
2016-05-27 05:08:40 +00:00
|
|
|
'SUSE': ['aalib', 'python-pssh']
|
[develop] Merge forward from 2016.3 to develop (#33193)
* Add run_on_start docs to schedule.rst (#32958)
Fixes #22580
* Backport #33021 manually to 2015.5 (#33044)
* Saltfile with pillar tests (#33045)
* add file.managed with pillar data tests
* do not require git for other tests
* Fix minor document error of test.assertion (#33067)
* test pillar.items output (#33060)
* File and User test fixes for 2015.5 on Fedora23 (#33055)
* Fix file_test.test_symlink on 2015.5
* Fix failing user present test
* add test for installing package while using salt-call --local (#33025)
* add test for installing package while using salt-call --local
* fix pylint
* ssh docs: install py-2.6 for RHEL 5
* Bugfix: Restore boolean values from the repo configuration
* Add test data for repos
* Add repo config test
* Bugfix (follow-up): setting priority requires non-positive integer
* modules.npm: do not log npm --version at info level (#33084)
* salt-cloud: fix ipv6-only virtual machines (#32865)
* salt-cloud: fix ipv6-only virtual machines
* fix hostname for rsync fallback in scp_file function
* use 4 spaces instead of 2
* remove global variable, use direct socket call instead
* Use saltstack repo in buildpackage.py on CentOS 5 (#33080)
* Lower display of msgpack failure msg to debug (#33078)
Closes #33074
* cloud.query needs to define mapper.opts (#33098)
* clarify docs that map is designed to be run once. is not stateful (#33102)
* Moved _finger_fail method to parent class.
Method _finger_fail method from SAuth to AsyncAuth class to make method available
in both class and fix an issue where _finger_Fail is called inside AsyncAuth.
* Fix 33058 (#33099)
* Fix servermanager module
- Added check for 2008 version of windows
- Added Import-Module ServerManager to _pshell_json.
Apparently this needs to run each time we issue a
servermanager command.
* Fix list_available
* salt.utils.gitfs: fix formatting for warning messages (#33064)
* salt.utils.gitfs: fix formatting for warning messages
When git_pillar support was added to salt.utils.gitfs, the
recommendation globals had string formatting placeholders added to them,
but the locations where these values are referenced do not call
``.format()`` to properly replace them. This commit fixes that
oversight.
* Remove more gitfs and master-specific wording from log messages
* Add a check that the cmdline of the found proc matches (#33129)
* Doc mock decorators (#33132)
* Add mock function for mocking decorators
* Mock the stdlib user module because importing it will open the repl
* Fix broken parsing of usermgmt.conf on OpenBSD (#33135)
When creating a new user, if a group of the same name already exists,
the usermgmt.conf file is consulted to determine the primary group.
It's in these cases that the parsing bug is triggered.
This code change addresses several of the existing issues:
- The previous split statement explicitly specified a single space.
Since a config line may have any number of spaces and/or tabs
surrounding the entries, the resulting array's elements may be
incorrect.
- According to the man pages for usermgmt.conf, the "group" config
entry accpets a single parameter -- so we shouldn't iterate.
- The "val[1]" was returning the 2nd letter of each word and not the
second word on the config line as intended.
* Move salt-ssh thin dir location to /var/tmp (#33130)
* Move salt-ssh thin dir location to /var/tmp
Closes #32771
* Remove performance penelty language
* If cache_jobs: True is set, populate the local job cache when running salt-call (#33100)
* If cache_jobs: True is set, populate the local job cache
Fixes #32834
Allows a masterless minion to query the job cache.
* Refactor cache_jobs functionality to be DRY
* Skipping salt-call --local test
* Back-port #31769 to 2015.8 (#33139)
* Handle empty acl_name in linux_acl state
Calls to setfacl interpret an empty group or user name to mean to be the
owner of the file they're operating on. For example, for a directory
owned by group 'admin', the ACL 'default:group::rwx' is equivalent to
'default:group:admin:rwx'.
The output of the getfacl execution module returns ACLs in the format of
'group:admin:rwx' instead of 'group::rwx'. This commit changes the
acl.present state to look for the owner of the file if the acl_name
paremeter is empty.
* Fix acl.present/acl.absent changing default ACLs
The behaviour of the acl.present and acl.absent is to check the data
structure returned by getfacl contains a key by the name of acl_type.
However, this data structure does not contain any default ACLs if none
exist, so this check will fail. We omit the check if a default ACL was
passed into the state functions.
Unfortunately, the call to modfacl may fail if the user passes in an
acl_type such as 'default:random'. In this case the state will appear to
succeed, but do nothing.
This fixes the state module to allow setting default ACLs on files which
have none.
* Fix regression in 2016.3 HEAD when version is specified (#33146)
Resolves #33013.
* Hash fileclients by opts (#33142)
* Hash fileclients by opts
There was an issue whereby the cache of the fileclient was being overwritten
by dueling minion instances in multimaster mode. This protects them by hashing
by the id of opts.
Closes #25040
* Silly typo!
* Remove tests which do not test any actual functionality or are too tightly coupled to the implementation
* Strip ldap fqdn (#33127)
* Add option to strip off domain names on computer names that come from LDAP/AD
* Add strip_domains option for ldap.
* Add documentation for auth.ldap.minion_stripdomains.
* [2015.5] Update to latest bootstrap script v2016.05.10 (#33155)
* [2015.8] Update to latest bootstrap script v2016.05.10 (#33156)
* [2016.3] Update to latest bootstrap script v2016.05.10 (#33157)
* add 2015.5.11 release notes (#33160)
* add 2015.8.9 release notes (#33161)
* Pip fix (#33180)
* fix pip!!
* make it work with old pip as well
* Added resiliency
* Don't need to check, just get the right name
* [2015.5] Update to latest bootstrap script v2016.05.11 (#33185)
2016-05-12 14:53:39 +00:00
|
|
|
}
|
2016-06-28 21:10:11 +00:00
|
|
|
_PKGS_INSTALLED = set()
|
2012-08-04 22:07:39 +00:00
|
|
|
|
|
|
|
|
2016-06-28 21:10:11 +00:00
|
|
|
class CallTest(integration.ShellCase, testprogram.TestProgramCase, integration.ShellCaseCommonTestsMixIn):
|
2012-08-04 22:07:39 +00:00
|
|
|
|
|
|
|
_call_binary_ = 'salt-call'
|
|
|
|
|
2012-08-13 06:10:42 +00:00
|
|
|
def test_default_output(self):
|
2012-12-04 19:14:35 +00:00
|
|
|
out = self.run_call('-l quiet test.fib 3')
|
|
|
|
|
2013-01-13 07:01:30 +00:00
|
|
|
expect = ['local:',
|
2015-04-11 19:58:27 +00:00
|
|
|
' - 2']
|
2012-11-04 10:29:07 +00:00
|
|
|
self.assertEqual(expect, out[:-1])
|
2012-08-13 06:10:42 +00:00
|
|
|
|
|
|
|
def test_text_output(self):
|
2013-01-15 06:40:20 +00:00
|
|
|
out = self.run_call('-l quiet --out txt test.fib 3')
|
2012-11-16 00:07:08 +00:00
|
|
|
|
2013-01-15 07:10:19 +00:00
|
|
|
expect = [
|
2015-04-11 19:58:27 +00:00
|
|
|
'local: (2'
|
2012-11-16 00:07:08 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
self.assertEqual(''.join(expect), ''.join(out).rsplit(",", 1)[0])
|
2012-08-13 06:10:42 +00:00
|
|
|
|
2014-10-17 01:44:17 +00:00
|
|
|
def test_json_out_indent(self):
|
|
|
|
out = self.run_call('test.ping -l quiet --out=json --out-indent=-1')
|
|
|
|
expect = ['{"local": true}']
|
|
|
|
self.assertEqual(expect, out)
|
|
|
|
|
|
|
|
out = self.run_call('test.ping -l quiet --out=json --out-indent=0')
|
|
|
|
expect = ['{', '"local": true', '}']
|
|
|
|
self.assertEqual(expect, out)
|
|
|
|
|
|
|
|
out = self.run_call('test.ping -l quiet --out=json --out-indent=1')
|
|
|
|
expect = ['{', ' "local": true', '}']
|
|
|
|
self.assertEqual(expect, out)
|
|
|
|
|
2014-10-14 19:28:19 +00:00
|
|
|
def test_local_sls_call(self):
|
2014-10-15 22:56:41 +00:00
|
|
|
fileroot = os.path.join(integration.FILES, 'file', 'base')
|
2014-10-14 19:28:19 +00:00
|
|
|
out = self.run_call('--file-root {0} --local state.sls saltcalllocal'.format(fileroot))
|
|
|
|
self.assertIn('Name: test.echo', ''.join(out))
|
|
|
|
self.assertIn('Result: True', ''.join(out))
|
|
|
|
self.assertIn('hello', ''.join(out))
|
|
|
|
self.assertIn('Succeeded: 1', ''.join(out))
|
|
|
|
|
[develop] Merge forward from 2016.3 to develop (#33193)
* Add run_on_start docs to schedule.rst (#32958)
Fixes #22580
* Backport #33021 manually to 2015.5 (#33044)
* Saltfile with pillar tests (#33045)
* add file.managed with pillar data tests
* do not require git for other tests
* Fix minor document error of test.assertion (#33067)
* test pillar.items output (#33060)
* File and User test fixes for 2015.5 on Fedora23 (#33055)
* Fix file_test.test_symlink on 2015.5
* Fix failing user present test
* add test for installing package while using salt-call --local (#33025)
* add test for installing package while using salt-call --local
* fix pylint
* ssh docs: install py-2.6 for RHEL 5
* Bugfix: Restore boolean values from the repo configuration
* Add test data for repos
* Add repo config test
* Bugfix (follow-up): setting priority requires non-positive integer
* modules.npm: do not log npm --version at info level (#33084)
* salt-cloud: fix ipv6-only virtual machines (#32865)
* salt-cloud: fix ipv6-only virtual machines
* fix hostname for rsync fallback in scp_file function
* use 4 spaces instead of 2
* remove global variable, use direct socket call instead
* Use saltstack repo in buildpackage.py on CentOS 5 (#33080)
* Lower display of msgpack failure msg to debug (#33078)
Closes #33074
* cloud.query needs to define mapper.opts (#33098)
* clarify docs that map is designed to be run once. is not stateful (#33102)
* Moved _finger_fail method to parent class.
Method _finger_fail method from SAuth to AsyncAuth class to make method available
in both class and fix an issue where _finger_Fail is called inside AsyncAuth.
* Fix 33058 (#33099)
* Fix servermanager module
- Added check for 2008 version of windows
- Added Import-Module ServerManager to _pshell_json.
Apparently this needs to run each time we issue a
servermanager command.
* Fix list_available
* salt.utils.gitfs: fix formatting for warning messages (#33064)
* salt.utils.gitfs: fix formatting for warning messages
When git_pillar support was added to salt.utils.gitfs, the
recommendation globals had string formatting placeholders added to them,
but the locations where these values are referenced do not call
``.format()`` to properly replace them. This commit fixes that
oversight.
* Remove more gitfs and master-specific wording from log messages
* Add a check that the cmdline of the found proc matches (#33129)
* Doc mock decorators (#33132)
* Add mock function for mocking decorators
* Mock the stdlib user module because importing it will open the repl
* Fix broken parsing of usermgmt.conf on OpenBSD (#33135)
When creating a new user, if a group of the same name already exists,
the usermgmt.conf file is consulted to determine the primary group.
It's in these cases that the parsing bug is triggered.
This code change addresses several of the existing issues:
- The previous split statement explicitly specified a single space.
Since a config line may have any number of spaces and/or tabs
surrounding the entries, the resulting array's elements may be
incorrect.
- According to the man pages for usermgmt.conf, the "group" config
entry accpets a single parameter -- so we shouldn't iterate.
- The "val[1]" was returning the 2nd letter of each word and not the
second word on the config line as intended.
* Move salt-ssh thin dir location to /var/tmp (#33130)
* Move salt-ssh thin dir location to /var/tmp
Closes #32771
* Remove performance penelty language
* If cache_jobs: True is set, populate the local job cache when running salt-call (#33100)
* If cache_jobs: True is set, populate the local job cache
Fixes #32834
Allows a masterless minion to query the job cache.
* Refactor cache_jobs functionality to be DRY
* Skipping salt-call --local test
* Back-port #31769 to 2015.8 (#33139)
* Handle empty acl_name in linux_acl state
Calls to setfacl interpret an empty group or user name to mean to be the
owner of the file they're operating on. For example, for a directory
owned by group 'admin', the ACL 'default:group::rwx' is equivalent to
'default:group:admin:rwx'.
The output of the getfacl execution module returns ACLs in the format of
'group:admin:rwx' instead of 'group::rwx'. This commit changes the
acl.present state to look for the owner of the file if the acl_name
paremeter is empty.
* Fix acl.present/acl.absent changing default ACLs
The behaviour of the acl.present and acl.absent is to check the data
structure returned by getfacl contains a key by the name of acl_type.
However, this data structure does not contain any default ACLs if none
exist, so this check will fail. We omit the check if a default ACL was
passed into the state functions.
Unfortunately, the call to modfacl may fail if the user passes in an
acl_type such as 'default:random'. In this case the state will appear to
succeed, but do nothing.
This fixes the state module to allow setting default ACLs on files which
have none.
* Fix regression in 2016.3 HEAD when version is specified (#33146)
Resolves #33013.
* Hash fileclients by opts (#33142)
* Hash fileclients by opts
There was an issue whereby the cache of the fileclient was being overwritten
by dueling minion instances in multimaster mode. This protects them by hashing
by the id of opts.
Closes #25040
* Silly typo!
* Remove tests which do not test any actual functionality or are too tightly coupled to the implementation
* Strip ldap fqdn (#33127)
* Add option to strip off domain names on computer names that come from LDAP/AD
* Add strip_domains option for ldap.
* Add documentation for auth.ldap.minion_stripdomains.
* [2015.5] Update to latest bootstrap script v2016.05.10 (#33155)
* [2015.8] Update to latest bootstrap script v2016.05.10 (#33156)
* [2016.3] Update to latest bootstrap script v2016.05.10 (#33157)
* add 2015.5.11 release notes (#33160)
* add 2015.8.9 release notes (#33161)
* Pip fix (#33180)
* fix pip!!
* make it work with old pip as well
* Added resiliency
* Don't need to check, just get the right name
* [2015.5] Update to latest bootstrap script v2016.05.11 (#33185)
2016-05-12 14:53:39 +00:00
|
|
|
@destructiveTest
|
|
|
|
@skipIf(True, 'Skipping due to off the wall failures and hangs on most os\'s. Will re-enable when fixed.')
|
|
|
|
@skipIf(sys.platform.startswith('win'), 'This test does not apply on Win')
|
2016-06-28 21:10:11 +00:00
|
|
|
@skipIf(getpass.getuser() == 'root', 'Requires root to test pkg.install')
|
[develop] Merge forward from 2016.3 to develop (#33193)
* Add run_on_start docs to schedule.rst (#32958)
Fixes #22580
* Backport #33021 manually to 2015.5 (#33044)
* Saltfile with pillar tests (#33045)
* add file.managed with pillar data tests
* do not require git for other tests
* Fix minor document error of test.assertion (#33067)
* test pillar.items output (#33060)
* File and User test fixes for 2015.5 on Fedora23 (#33055)
* Fix file_test.test_symlink on 2015.5
* Fix failing user present test
* add test for installing package while using salt-call --local (#33025)
* add test for installing package while using salt-call --local
* fix pylint
* ssh docs: install py-2.6 for RHEL 5
* Bugfix: Restore boolean values from the repo configuration
* Add test data for repos
* Add repo config test
* Bugfix (follow-up): setting priority requires non-positive integer
* modules.npm: do not log npm --version at info level (#33084)
* salt-cloud: fix ipv6-only virtual machines (#32865)
* salt-cloud: fix ipv6-only virtual machines
* fix hostname for rsync fallback in scp_file function
* use 4 spaces instead of 2
* remove global variable, use direct socket call instead
* Use saltstack repo in buildpackage.py on CentOS 5 (#33080)
* Lower display of msgpack failure msg to debug (#33078)
Closes #33074
* cloud.query needs to define mapper.opts (#33098)
* clarify docs that map is designed to be run once. is not stateful (#33102)
* Moved _finger_fail method to parent class.
Method _finger_fail method from SAuth to AsyncAuth class to make method available
in both class and fix an issue where _finger_Fail is called inside AsyncAuth.
* Fix 33058 (#33099)
* Fix servermanager module
- Added check for 2008 version of windows
- Added Import-Module ServerManager to _pshell_json.
Apparently this needs to run each time we issue a
servermanager command.
* Fix list_available
* salt.utils.gitfs: fix formatting for warning messages (#33064)
* salt.utils.gitfs: fix formatting for warning messages
When git_pillar support was added to salt.utils.gitfs, the
recommendation globals had string formatting placeholders added to them,
but the locations where these values are referenced do not call
``.format()`` to properly replace them. This commit fixes that
oversight.
* Remove more gitfs and master-specific wording from log messages
* Add a check that the cmdline of the found proc matches (#33129)
* Doc mock decorators (#33132)
* Add mock function for mocking decorators
* Mock the stdlib user module because importing it will open the repl
* Fix broken parsing of usermgmt.conf on OpenBSD (#33135)
When creating a new user, if a group of the same name already exists,
the usermgmt.conf file is consulted to determine the primary group.
It's in these cases that the parsing bug is triggered.
This code change addresses several of the existing issues:
- The previous split statement explicitly specified a single space.
Since a config line may have any number of spaces and/or tabs
surrounding the entries, the resulting array's elements may be
incorrect.
- According to the man pages for usermgmt.conf, the "group" config
entry accpets a single parameter -- so we shouldn't iterate.
- The "val[1]" was returning the 2nd letter of each word and not the
second word on the config line as intended.
* Move salt-ssh thin dir location to /var/tmp (#33130)
* Move salt-ssh thin dir location to /var/tmp
Closes #32771
* Remove performance penelty language
* If cache_jobs: True is set, populate the local job cache when running salt-call (#33100)
* If cache_jobs: True is set, populate the local job cache
Fixes #32834
Allows a masterless minion to query the job cache.
* Refactor cache_jobs functionality to be DRY
* Skipping salt-call --local test
* Back-port #31769 to 2015.8 (#33139)
* Handle empty acl_name in linux_acl state
Calls to setfacl interpret an empty group or user name to mean to be the
owner of the file they're operating on. For example, for a directory
owned by group 'admin', the ACL 'default:group::rwx' is equivalent to
'default:group:admin:rwx'.
The output of the getfacl execution module returns ACLs in the format of
'group:admin:rwx' instead of 'group::rwx'. This commit changes the
acl.present state to look for the owner of the file if the acl_name
paremeter is empty.
* Fix acl.present/acl.absent changing default ACLs
The behaviour of the acl.present and acl.absent is to check the data
structure returned by getfacl contains a key by the name of acl_type.
However, this data structure does not contain any default ACLs if none
exist, so this check will fail. We omit the check if a default ACL was
passed into the state functions.
Unfortunately, the call to modfacl may fail if the user passes in an
acl_type such as 'default:random'. In this case the state will appear to
succeed, but do nothing.
This fixes the state module to allow setting default ACLs on files which
have none.
* Fix regression in 2016.3 HEAD when version is specified (#33146)
Resolves #33013.
* Hash fileclients by opts (#33142)
* Hash fileclients by opts
There was an issue whereby the cache of the fileclient was being overwritten
by dueling minion instances in multimaster mode. This protects them by hashing
by the id of opts.
Closes #25040
* Silly typo!
* Remove tests which do not test any actual functionality or are too tightly coupled to the implementation
* Strip ldap fqdn (#33127)
* Add option to strip off domain names on computer names that come from LDAP/AD
* Add strip_domains option for ldap.
* Add documentation for auth.ldap.minion_stripdomains.
* [2015.5] Update to latest bootstrap script v2016.05.10 (#33155)
* [2015.8] Update to latest bootstrap script v2016.05.10 (#33156)
* [2016.3] Update to latest bootstrap script v2016.05.10 (#33157)
* add 2015.5.11 release notes (#33160)
* add 2015.8.9 release notes (#33161)
* Pip fix (#33180)
* fix pip!!
* make it work with old pip as well
* Added resiliency
* Don't need to check, just get the right name
* [2015.5] Update to latest bootstrap script v2016.05.11 (#33185)
2016-05-12 14:53:39 +00:00
|
|
|
def test_local_pkg_install(self):
|
|
|
|
'''
|
|
|
|
Test to ensure correct output when installing package
|
|
|
|
'''
|
|
|
|
get_os_family = self.run_call('--local grains.get os_family')
|
|
|
|
pkg_targets = _PKG_TARGETS.get(get_os_family[1].strip(), [])
|
|
|
|
check_pkg = self.run_call('--local pkg.list_pkgs')
|
|
|
|
for pkg in pkg_targets:
|
|
|
|
if pkg not in str(check_pkg):
|
|
|
|
out = self.run_call('--local pkg.install {0}'.format(pkg))
|
|
|
|
self.assertIn('local: ----------', ''.join(out))
|
|
|
|
self.assertIn('{0}: ----------'.format(pkg), ''.join(out))
|
|
|
|
self.assertIn('new:', ''.join(out))
|
|
|
|
self.assertIn('old:', ''.join(out))
|
2016-06-28 21:10:11 +00:00
|
|
|
_PKGS_INSTALLED.add(pkg)
|
[develop] Merge forward from 2016.3 to develop (#33193)
* Add run_on_start docs to schedule.rst (#32958)
Fixes #22580
* Backport #33021 manually to 2015.5 (#33044)
* Saltfile with pillar tests (#33045)
* add file.managed with pillar data tests
* do not require git for other tests
* Fix minor document error of test.assertion (#33067)
* test pillar.items output (#33060)
* File and User test fixes for 2015.5 on Fedora23 (#33055)
* Fix file_test.test_symlink on 2015.5
* Fix failing user present test
* add test for installing package while using salt-call --local (#33025)
* add test for installing package while using salt-call --local
* fix pylint
* ssh docs: install py-2.6 for RHEL 5
* Bugfix: Restore boolean values from the repo configuration
* Add test data for repos
* Add repo config test
* Bugfix (follow-up): setting priority requires non-positive integer
* modules.npm: do not log npm --version at info level (#33084)
* salt-cloud: fix ipv6-only virtual machines (#32865)
* salt-cloud: fix ipv6-only virtual machines
* fix hostname for rsync fallback in scp_file function
* use 4 spaces instead of 2
* remove global variable, use direct socket call instead
* Use saltstack repo in buildpackage.py on CentOS 5 (#33080)
* Lower display of msgpack failure msg to debug (#33078)
Closes #33074
* cloud.query needs to define mapper.opts (#33098)
* clarify docs that map is designed to be run once. is not stateful (#33102)
* Moved _finger_fail method to parent class.
Method _finger_fail method from SAuth to AsyncAuth class to make method available
in both class and fix an issue where _finger_Fail is called inside AsyncAuth.
* Fix 33058 (#33099)
* Fix servermanager module
- Added check for 2008 version of windows
- Added Import-Module ServerManager to _pshell_json.
Apparently this needs to run each time we issue a
servermanager command.
* Fix list_available
* salt.utils.gitfs: fix formatting for warning messages (#33064)
* salt.utils.gitfs: fix formatting for warning messages
When git_pillar support was added to salt.utils.gitfs, the
recommendation globals had string formatting placeholders added to them,
but the locations where these values are referenced do not call
``.format()`` to properly replace them. This commit fixes that
oversight.
* Remove more gitfs and master-specific wording from log messages
* Add a check that the cmdline of the found proc matches (#33129)
* Doc mock decorators (#33132)
* Add mock function for mocking decorators
* Mock the stdlib user module because importing it will open the repl
* Fix broken parsing of usermgmt.conf on OpenBSD (#33135)
When creating a new user, if a group of the same name already exists,
the usermgmt.conf file is consulted to determine the primary group.
It's in these cases that the parsing bug is triggered.
This code change addresses several of the existing issues:
- The previous split statement explicitly specified a single space.
Since a config line may have any number of spaces and/or tabs
surrounding the entries, the resulting array's elements may be
incorrect.
- According to the man pages for usermgmt.conf, the "group" config
entry accpets a single parameter -- so we shouldn't iterate.
- The "val[1]" was returning the 2nd letter of each word and not the
second word on the config line as intended.
* Move salt-ssh thin dir location to /var/tmp (#33130)
* Move salt-ssh thin dir location to /var/tmp
Closes #32771
* Remove performance penelty language
* If cache_jobs: True is set, populate the local job cache when running salt-call (#33100)
* If cache_jobs: True is set, populate the local job cache
Fixes #32834
Allows a masterless minion to query the job cache.
* Refactor cache_jobs functionality to be DRY
* Skipping salt-call --local test
* Back-port #31769 to 2015.8 (#33139)
* Handle empty acl_name in linux_acl state
Calls to setfacl interpret an empty group or user name to mean to be the
owner of the file they're operating on. For example, for a directory
owned by group 'admin', the ACL 'default:group::rwx' is equivalent to
'default:group:admin:rwx'.
The output of the getfacl execution module returns ACLs in the format of
'group:admin:rwx' instead of 'group::rwx'. This commit changes the
acl.present state to look for the owner of the file if the acl_name
paremeter is empty.
* Fix acl.present/acl.absent changing default ACLs
The behaviour of the acl.present and acl.absent is to check the data
structure returned by getfacl contains a key by the name of acl_type.
However, this data structure does not contain any default ACLs if none
exist, so this check will fail. We omit the check if a default ACL was
passed into the state functions.
Unfortunately, the call to modfacl may fail if the user passes in an
acl_type such as 'default:random'. In this case the state will appear to
succeed, but do nothing.
This fixes the state module to allow setting default ACLs on files which
have none.
* Fix regression in 2016.3 HEAD when version is specified (#33146)
Resolves #33013.
* Hash fileclients by opts (#33142)
* Hash fileclients by opts
There was an issue whereby the cache of the fileclient was being overwritten
by dueling minion instances in multimaster mode. This protects them by hashing
by the id of opts.
Closes #25040
* Silly typo!
* Remove tests which do not test any actual functionality or are too tightly coupled to the implementation
* Strip ldap fqdn (#33127)
* Add option to strip off domain names on computer names that come from LDAP/AD
* Add strip_domains option for ldap.
* Add documentation for auth.ldap.minion_stripdomains.
* [2015.5] Update to latest bootstrap script v2016.05.10 (#33155)
* [2015.8] Update to latest bootstrap script v2016.05.10 (#33156)
* [2016.3] Update to latest bootstrap script v2016.05.10 (#33157)
* add 2015.5.11 release notes (#33160)
* add 2015.8.9 release notes (#33161)
* Pip fix (#33180)
* fix pip!!
* make it work with old pip as well
* Added resiliency
* Don't need to check, just get the right name
* [2015.5] Update to latest bootstrap script v2016.05.11 (#33185)
2016-05-12 14:53:39 +00:00
|
|
|
else:
|
|
|
|
log.debug('The pkg: {0} is already installed on the machine'.format(pkg))
|
|
|
|
|
2012-09-30 09:59:07 +00:00
|
|
|
@skipIf(sys.platform.startswith('win'), 'This test does not apply on Win')
|
|
|
|
def test_user_delete_kw_output(self):
|
2012-12-04 19:14:35 +00:00
|
|
|
ret = self.run_call('-l quiet -d user.delete')
|
2012-09-30 09:59:07 +00:00
|
|
|
self.assertIn(
|
|
|
|
'salt \'*\' user.delete name remove=True force=True',
|
|
|
|
''.join(ret)
|
|
|
|
)
|
|
|
|
|
2014-04-24 14:56:58 +00:00
|
|
|
def test_salt_documentation_too_many_arguments(self):
|
|
|
|
'''
|
|
|
|
Test to see if passing additional arguments shows an error
|
|
|
|
'''
|
2014-04-24 15:04:51 +00:00
|
|
|
data = self.run_call('-d virtualenv.create /tmp/ve', catch_stderr=True)
|
2014-04-24 14:56:58 +00:00
|
|
|
self.assertIn('You can only get documentation for one method at one time', '\n'.join(data[1]))
|
|
|
|
|
2013-09-13 16:12:11 +00:00
|
|
|
def test_issue_6973_state_highstate_exit_code(self):
|
|
|
|
'''
|
|
|
|
If there is no tops/master_tops or state file matches
|
|
|
|
for this minion, salt-call should exit non-zero if invoked with
|
|
|
|
option --retcode-passthrough
|
|
|
|
'''
|
|
|
|
src = os.path.join(integration.FILES, 'file/base/top.sls')
|
|
|
|
dst = os.path.join(integration.FILES, 'file/base/top.sls.bak')
|
|
|
|
shutil.move(src, dst)
|
2014-07-02 20:40:08 +00:00
|
|
|
expected_comment = 'No states found for this minion'
|
2013-09-13 16:12:11 +00:00
|
|
|
try:
|
|
|
|
stdout, retcode = self.run_call(
|
|
|
|
'-l quiet --retcode-passthrough state.highstate',
|
|
|
|
with_retcode=True
|
|
|
|
)
|
|
|
|
finally:
|
|
|
|
shutil.move(dst, src)
|
|
|
|
self.assertIn(expected_comment, ''.join(stdout))
|
|
|
|
self.assertNotEqual(0, retcode)
|
|
|
|
|
2014-02-20 01:47:17 +00:00
|
|
|
@skipIf(sys.platform.startswith('win'), 'This test does not apply on Win')
|
2015-05-28 18:10:29 +00:00
|
|
|
@skipIf(True, 'to be reenabled when #23623 is merged')
|
2014-02-20 01:47:17 +00:00
|
|
|
def test_return(self):
|
2015-01-09 20:14:33 +00:00
|
|
|
self.run_call('cmd.run "echo returnTOmaster"')
|
|
|
|
jobs = [a for a in self.run_run('jobs.list_jobs')]
|
2014-02-20 01:47:17 +00:00
|
|
|
|
|
|
|
self.assertTrue(True in ['returnTOmaster' in j for j in jobs])
|
|
|
|
# lookback jid
|
|
|
|
first_match = [(i, j)
|
|
|
|
for i, j in enumerate(jobs)
|
|
|
|
if 'returnTOmaster' in j][0]
|
|
|
|
jid, idx = None, first_match[0]
|
|
|
|
while idx > 0:
|
2014-04-19 20:33:25 +00:00
|
|
|
jid = re.match("([0-9]+):", jobs[idx])
|
2014-02-20 01:47:17 +00:00
|
|
|
if jid:
|
2014-04-19 20:33:25 +00:00
|
|
|
jid = jid.group(1)
|
2014-02-20 01:47:17 +00:00
|
|
|
break
|
|
|
|
idx -= 1
|
|
|
|
assert idx > 0
|
|
|
|
assert jid
|
|
|
|
master_out = [
|
2015-01-09 20:14:33 +00:00
|
|
|
a for a in self.run_run('jobs.lookup_jid {0}'.format(jid))
|
2014-06-02 18:34:09 +00:00
|
|
|
]
|
2014-02-20 01:47:17 +00:00
|
|
|
self.assertTrue(True in ['returnTOmaster' in a for a in master_out])
|
|
|
|
|
2012-12-01 23:00:27 +00:00
|
|
|
@skipIf(sys.platform.startswith('win'), 'This test does not apply on Win')
|
|
|
|
def test_issue_2731_masterless(self):
|
2014-06-02 18:34:09 +00:00
|
|
|
root_dir = os.path.join(integration.TMP, 'issue-2731')
|
|
|
|
config_dir = os.path.join(root_dir, 'conf')
|
2012-12-01 23:00:27 +00:00
|
|
|
minion_config_file = os.path.join(config_dir, 'minion')
|
2014-06-02 18:34:09 +00:00
|
|
|
logfile = os.path.join(root_dir, 'minion_test_issue_2731')
|
|
|
|
|
|
|
|
if not os.path.isdir(config_dir):
|
|
|
|
os.makedirs(config_dir)
|
|
|
|
|
2014-11-26 23:30:18 +00:00
|
|
|
with salt.utils.fopen(self.get_config_file_path('master')) as fhr:
|
|
|
|
master_config = yaml.load(fhr.read())
|
|
|
|
|
2014-06-02 18:34:09 +00:00
|
|
|
master_root_dir = master_config['root_dir']
|
2012-12-05 21:24:19 +00:00
|
|
|
this_minion_key = os.path.join(
|
2016-08-02 11:43:23 +00:00
|
|
|
master_root_dir, 'pki', 'master', 'minions', 'minion_test_issue_2731'
|
2012-12-05 21:24:19 +00:00
|
|
|
)
|
2012-12-01 23:00:27 +00:00
|
|
|
|
|
|
|
minion_config = {
|
|
|
|
'id': 'minion_test_issue_2731',
|
|
|
|
'master': 'localhost',
|
|
|
|
'master_port': 64506,
|
2014-06-02 18:34:09 +00:00
|
|
|
'root_dir': master_root_dir,
|
2012-12-01 23:00:27 +00:00
|
|
|
'pki_dir': 'pki',
|
|
|
|
'cachedir': 'cachedir',
|
|
|
|
'sock_dir': 'minion_sock',
|
|
|
|
'open_mode': True,
|
2014-06-02 18:34:09 +00:00
|
|
|
'log_file': logfile,
|
2012-12-01 23:00:27 +00:00
|
|
|
'log_level': 'quiet',
|
2015-11-12 21:32:39 +00:00
|
|
|
'log_level_logfile': 'info',
|
|
|
|
'transport': self.master_opts['transport'],
|
2012-12-01 23:00:27 +00:00
|
|
|
}
|
2012-12-05 21:24:19 +00:00
|
|
|
try:
|
2016-08-21 11:22:26 +00:00
|
|
|
# Remove existing logfile
|
|
|
|
if os.path.isfile(logfile):
|
|
|
|
os.unlink(logfile)
|
|
|
|
|
|
|
|
start = datetime.now()
|
|
|
|
# Let's first test with a master running
|
|
|
|
|
|
|
|
with salt.utils.fopen(minion_config_file, 'w') as fh_:
|
|
|
|
fh_.write(
|
|
|
|
yaml.dump(minion_config, default_flow_style=False)
|
|
|
|
)
|
|
|
|
ret = self.run_script(
|
|
|
|
'salt-call',
|
|
|
|
'--config-dir {0} cmd.run "echo foo"'.format(
|
|
|
|
config_dir
|
|
|
|
)
|
2014-11-26 17:49:27 +00:00
|
|
|
)
|
2016-08-21 11:22:26 +00:00
|
|
|
try:
|
|
|
|
self.assertIn('local:', ret)
|
|
|
|
except AssertionError:
|
|
|
|
if os.path.isfile(minion_config_file):
|
|
|
|
os.unlink(minion_config_file)
|
|
|
|
# Let's remove our key from the master
|
|
|
|
if os.path.isfile(this_minion_key):
|
|
|
|
os.unlink(this_minion_key)
|
|
|
|
|
|
|
|
raise
|
|
|
|
|
|
|
|
# Calculate the required timeout, since next will fail.
|
|
|
|
# I needed this because after many attempts, I was unable to catch:
|
|
|
|
# WARNING: Master hostname: salt not found. Retrying in 30 seconds
|
|
|
|
ellapsed = datetime.now() - start
|
|
|
|
timeout = ellapsed.seconds + 3
|
|
|
|
|
|
|
|
# Now let's remove the master configuration
|
|
|
|
minion_config.pop('master')
|
|
|
|
minion_config.pop('master_port')
|
|
|
|
with salt.utils.fopen(minion_config_file, 'w') as fh_:
|
|
|
|
fh_.write(
|
|
|
|
yaml.dump(minion_config, default_flow_style=False)
|
|
|
|
)
|
|
|
|
|
|
|
|
out = self.run_script(
|
|
|
|
'salt-call',
|
|
|
|
'--config-dir {0} cmd.run "echo foo"'.format(
|
|
|
|
config_dir
|
|
|
|
),
|
|
|
|
timeout=timeout,
|
2012-12-05 21:24:19 +00:00
|
|
|
)
|
2012-12-01 23:00:27 +00:00
|
|
|
|
2016-08-21 11:22:26 +00:00
|
|
|
try:
|
|
|
|
self.assertIn(
|
|
|
|
'Process took more than {0} seconds to complete. '
|
|
|
|
'Process Killed!'.format(timeout),
|
|
|
|
out
|
|
|
|
)
|
|
|
|
except AssertionError:
|
|
|
|
if os.path.isfile(minion_config_file):
|
|
|
|
os.unlink(minion_config_file)
|
|
|
|
# Let's remove our key from the master
|
|
|
|
if os.path.isfile(this_minion_key):
|
|
|
|
os.unlink(this_minion_key)
|
|
|
|
|
|
|
|
raise
|
|
|
|
|
|
|
|
# Should work with --local
|
|
|
|
ret = self.run_script(
|
|
|
|
'salt-call',
|
|
|
|
'--config-dir {0} --local cmd.run "echo foo"'.format(
|
|
|
|
config_dir
|
|
|
|
),
|
|
|
|
timeout=15
|
|
|
|
)
|
|
|
|
try:
|
|
|
|
self.assertIn('local:', ret)
|
|
|
|
except AssertionError:
|
|
|
|
if os.path.isfile(minion_config_file):
|
|
|
|
os.unlink(minion_config_file)
|
|
|
|
# Let's remove our key from the master
|
|
|
|
if os.path.isfile(this_minion_key):
|
|
|
|
os.unlink(this_minion_key)
|
|
|
|
raise
|
|
|
|
|
|
|
|
# Should work with local file client
|
|
|
|
minion_config['file_client'] = 'local'
|
|
|
|
with salt.utils.fopen(minion_config_file, 'w') as fh_:
|
|
|
|
fh_.write(
|
|
|
|
yaml.dump(minion_config, default_flow_style=False)
|
|
|
|
)
|
|
|
|
ret = self.run_script(
|
|
|
|
'salt-call',
|
|
|
|
'--config-dir {0} cmd.run "echo foo"'.format(
|
|
|
|
config_dir
|
|
|
|
),
|
|
|
|
timeout=15
|
2014-11-26 17:49:27 +00:00
|
|
|
)
|
2013-01-13 07:01:30 +00:00
|
|
|
self.assertIn('local:', ret)
|
2012-12-05 21:24:19 +00:00
|
|
|
finally:
|
|
|
|
if os.path.isfile(minion_config_file):
|
|
|
|
os.unlink(minion_config_file)
|
|
|
|
# Let's remove our key from the master
|
|
|
|
if os.path.isfile(this_minion_key):
|
|
|
|
os.unlink(this_minion_key)
|
2012-12-01 23:00:27 +00:00
|
|
|
|
2013-10-15 21:09:37 +00:00
|
|
|
def test_issue_7754(self):
|
|
|
|
old_cwd = os.getcwd()
|
|
|
|
config_dir = os.path.join(integration.TMP, 'issue-7754')
|
|
|
|
if not os.path.isdir(config_dir):
|
|
|
|
os.makedirs(config_dir)
|
|
|
|
|
|
|
|
os.chdir(config_dir)
|
|
|
|
|
2014-11-26 17:49:27 +00:00
|
|
|
with salt.utils.fopen(self.get_config_file_path('minion'), 'r') as fh_:
|
|
|
|
minion_config = yaml.load(fh_.read())
|
2014-11-26 20:49:04 +00:00
|
|
|
minion_config['log_file'] = 'file:///dev/log/LOG_LOCAL3'
|
|
|
|
with salt.utils.fopen(os.path.join(config_dir, 'minion'), 'w') as fh_:
|
|
|
|
fh_.write(
|
|
|
|
yaml.dump(minion_config, default_flow_style=False)
|
|
|
|
)
|
2013-10-15 22:33:51 +00:00
|
|
|
ret = self.run_script(
|
2013-10-15 21:09:37 +00:00
|
|
|
'salt-call',
|
|
|
|
'--config-dir {0} cmd.run "echo foo"'.format(
|
|
|
|
config_dir
|
|
|
|
),
|
2014-01-19 06:44:45 +00:00
|
|
|
timeout=15,
|
|
|
|
catch_stderr=True,
|
|
|
|
with_retcode=True
|
2013-10-15 21:09:37 +00:00
|
|
|
)
|
|
|
|
try:
|
2014-01-19 06:44:45 +00:00
|
|
|
self.assertIn('local:', ret[0])
|
2013-10-15 21:09:37 +00:00
|
|
|
self.assertFalse(os.path.isdir(os.path.join(config_dir, 'file:')))
|
2014-01-19 06:44:45 +00:00
|
|
|
except AssertionError:
|
|
|
|
# We now fail when we're unable to properly set the syslog logger
|
|
|
|
self.assertIn(
|
|
|
|
'Failed to setup the Syslog logging handler', '\n'.join(ret[1])
|
|
|
|
)
|
|
|
|
self.assertEqual(ret[2], 2)
|
2013-10-15 21:09:37 +00:00
|
|
|
finally:
|
2015-07-28 11:07:04 +00:00
|
|
|
self.chdir(old_cwd)
|
2013-10-15 21:09:37 +00:00
|
|
|
if os.path.isdir(config_dir):
|
|
|
|
shutil.rmtree(config_dir)
|
|
|
|
|
2014-08-20 01:41:35 +00:00
|
|
|
def test_issue_15074_output_file_append(self):
|
|
|
|
output_file_append = os.path.join(integration.TMP, 'issue-15074')
|
|
|
|
try:
|
|
|
|
# Let's create an initial output file with some data
|
2016-06-28 21:10:11 +00:00
|
|
|
_ = self.run_script(
|
2014-08-20 01:41:35 +00:00
|
|
|
'salt-call',
|
2015-11-03 21:10:37 +00:00
|
|
|
'-c {0} --output-file={1} test.versions'.format(
|
2014-08-20 01:41:35 +00:00
|
|
|
self.get_config_dir(),
|
|
|
|
output_file_append
|
|
|
|
),
|
|
|
|
catch_stderr=True,
|
|
|
|
with_retcode=True
|
|
|
|
)
|
|
|
|
|
|
|
|
with salt.utils.fopen(output_file_append) as ofa:
|
|
|
|
output = ofa.read()
|
|
|
|
|
|
|
|
self.run_script(
|
|
|
|
'salt-call',
|
2015-11-03 21:10:37 +00:00
|
|
|
'-c {0} --output-file={1} --output-file-append test.versions'.format(
|
2014-08-20 01:41:35 +00:00
|
|
|
self.get_config_dir(),
|
|
|
|
output_file_append
|
|
|
|
),
|
|
|
|
catch_stderr=True,
|
|
|
|
with_retcode=True
|
|
|
|
)
|
|
|
|
with salt.utils.fopen(output_file_append) as ofa:
|
|
|
|
self.assertEqual(ofa.read(), output + output)
|
|
|
|
finally:
|
|
|
|
if os.path.exists(output_file_append):
|
|
|
|
os.unlink(output_file_append)
|
|
|
|
|
2014-08-20 01:28:13 +00:00
|
|
|
def test_issue_14979_output_file_permissions(self):
|
|
|
|
output_file = os.path.join(integration.TMP, 'issue-14979')
|
2014-11-22 10:54:39 +00:00
|
|
|
current_umask = os.umask(0o077)
|
2014-08-20 01:28:13 +00:00
|
|
|
try:
|
|
|
|
# Let's create an initial output file with some data
|
|
|
|
self.run_script(
|
|
|
|
'salt-call',
|
|
|
|
'-c {0} --output-file={1} -g'.format(
|
|
|
|
self.get_config_dir(),
|
|
|
|
output_file
|
|
|
|
),
|
|
|
|
catch_stderr=True,
|
|
|
|
with_retcode=True
|
|
|
|
)
|
|
|
|
stat1 = os.stat(output_file)
|
|
|
|
|
|
|
|
# Let's change umask
|
2014-11-22 10:54:39 +00:00
|
|
|
os.umask(0o777)
|
2014-08-20 01:28:13 +00:00
|
|
|
|
|
|
|
self.run_script(
|
|
|
|
'salt-call',
|
2014-09-23 18:52:48 +00:00
|
|
|
'-c {0} --output-file={1} --output-file-append -g'.format(
|
2014-08-20 01:28:13 +00:00
|
|
|
self.get_config_dir(),
|
|
|
|
output_file
|
|
|
|
),
|
|
|
|
catch_stderr=True,
|
|
|
|
with_retcode=True
|
|
|
|
)
|
|
|
|
stat2 = os.stat(output_file)
|
|
|
|
self.assertEqual(stat1.st_mode, stat2.st_mode)
|
2014-09-23 18:52:48 +00:00
|
|
|
# Data was appeneded to file
|
|
|
|
self.assertTrue(stat1.st_size < stat2.st_size)
|
|
|
|
|
|
|
|
# Let's remove the output file
|
|
|
|
os.unlink(output_file)
|
|
|
|
|
|
|
|
# Not appending data
|
|
|
|
self.run_script(
|
|
|
|
'salt-call',
|
|
|
|
'-c {0} --output-file={1} -g'.format(
|
|
|
|
self.get_config_dir(),
|
|
|
|
output_file
|
|
|
|
),
|
|
|
|
catch_stderr=True,
|
|
|
|
with_retcode=True
|
|
|
|
)
|
|
|
|
stat3 = os.stat(output_file)
|
|
|
|
# Mode must have changed since we're creating a new log file
|
|
|
|
self.assertNotEqual(stat1.st_mode, stat3.st_mode)
|
|
|
|
# Data was appended to file
|
|
|
|
self.assertEqual(stat1.st_size, stat3.st_size)
|
2014-08-20 01:28:13 +00:00
|
|
|
finally:
|
|
|
|
if os.path.exists(output_file):
|
|
|
|
os.unlink(output_file)
|
|
|
|
# Restore umask
|
|
|
|
os.umask(current_umask)
|
|
|
|
|
[develop] Merge forward from 2016.3 to develop (#33193)
* Add run_on_start docs to schedule.rst (#32958)
Fixes #22580
* Backport #33021 manually to 2015.5 (#33044)
* Saltfile with pillar tests (#33045)
* add file.managed with pillar data tests
* do not require git for other tests
* Fix minor document error of test.assertion (#33067)
* test pillar.items output (#33060)
* File and User test fixes for 2015.5 on Fedora23 (#33055)
* Fix file_test.test_symlink on 2015.5
* Fix failing user present test
* add test for installing package while using salt-call --local (#33025)
* add test for installing package while using salt-call --local
* fix pylint
* ssh docs: install py-2.6 for RHEL 5
* Bugfix: Restore boolean values from the repo configuration
* Add test data for repos
* Add repo config test
* Bugfix (follow-up): setting priority requires non-positive integer
* modules.npm: do not log npm --version at info level (#33084)
* salt-cloud: fix ipv6-only virtual machines (#32865)
* salt-cloud: fix ipv6-only virtual machines
* fix hostname for rsync fallback in scp_file function
* use 4 spaces instead of 2
* remove global variable, use direct socket call instead
* Use saltstack repo in buildpackage.py on CentOS 5 (#33080)
* Lower display of msgpack failure msg to debug (#33078)
Closes #33074
* cloud.query needs to define mapper.opts (#33098)
* clarify docs that map is designed to be run once. is not stateful (#33102)
* Moved _finger_fail method to parent class.
Method _finger_fail method from SAuth to AsyncAuth class to make method available
in both class and fix an issue where _finger_Fail is called inside AsyncAuth.
* Fix 33058 (#33099)
* Fix servermanager module
- Added check for 2008 version of windows
- Added Import-Module ServerManager to _pshell_json.
Apparently this needs to run each time we issue a
servermanager command.
* Fix list_available
* salt.utils.gitfs: fix formatting for warning messages (#33064)
* salt.utils.gitfs: fix formatting for warning messages
When git_pillar support was added to salt.utils.gitfs, the
recommendation globals had string formatting placeholders added to them,
but the locations where these values are referenced do not call
``.format()`` to properly replace them. This commit fixes that
oversight.
* Remove more gitfs and master-specific wording from log messages
* Add a check that the cmdline of the found proc matches (#33129)
* Doc mock decorators (#33132)
* Add mock function for mocking decorators
* Mock the stdlib user module because importing it will open the repl
* Fix broken parsing of usermgmt.conf on OpenBSD (#33135)
When creating a new user, if a group of the same name already exists,
the usermgmt.conf file is consulted to determine the primary group.
It's in these cases that the parsing bug is triggered.
This code change addresses several of the existing issues:
- The previous split statement explicitly specified a single space.
Since a config line may have any number of spaces and/or tabs
surrounding the entries, the resulting array's elements may be
incorrect.
- According to the man pages for usermgmt.conf, the "group" config
entry accpets a single parameter -- so we shouldn't iterate.
- The "val[1]" was returning the 2nd letter of each word and not the
second word on the config line as intended.
* Move salt-ssh thin dir location to /var/tmp (#33130)
* Move salt-ssh thin dir location to /var/tmp
Closes #32771
* Remove performance penelty language
* If cache_jobs: True is set, populate the local job cache when running salt-call (#33100)
* If cache_jobs: True is set, populate the local job cache
Fixes #32834
Allows a masterless minion to query the job cache.
* Refactor cache_jobs functionality to be DRY
* Skipping salt-call --local test
* Back-port #31769 to 2015.8 (#33139)
* Handle empty acl_name in linux_acl state
Calls to setfacl interpret an empty group or user name to mean to be the
owner of the file they're operating on. For example, for a directory
owned by group 'admin', the ACL 'default:group::rwx' is equivalent to
'default:group:admin:rwx'.
The output of the getfacl execution module returns ACLs in the format of
'group:admin:rwx' instead of 'group::rwx'. This commit changes the
acl.present state to look for the owner of the file if the acl_name
paremeter is empty.
* Fix acl.present/acl.absent changing default ACLs
The behaviour of the acl.present and acl.absent is to check the data
structure returned by getfacl contains a key by the name of acl_type.
However, this data structure does not contain any default ACLs if none
exist, so this check will fail. We omit the check if a default ACL was
passed into the state functions.
Unfortunately, the call to modfacl may fail if the user passes in an
acl_type such as 'default:random'. In this case the state will appear to
succeed, but do nothing.
This fixes the state module to allow setting default ACLs on files which
have none.
* Fix regression in 2016.3 HEAD when version is specified (#33146)
Resolves #33013.
* Hash fileclients by opts (#33142)
* Hash fileclients by opts
There was an issue whereby the cache of the fileclient was being overwritten
by dueling minion instances in multimaster mode. This protects them by hashing
by the id of opts.
Closes #25040
* Silly typo!
* Remove tests which do not test any actual functionality or are too tightly coupled to the implementation
* Strip ldap fqdn (#33127)
* Add option to strip off domain names on computer names that come from LDAP/AD
* Add strip_domains option for ldap.
* Add documentation for auth.ldap.minion_stripdomains.
* [2015.5] Update to latest bootstrap script v2016.05.10 (#33155)
* [2015.8] Update to latest bootstrap script v2016.05.10 (#33156)
* [2016.3] Update to latest bootstrap script v2016.05.10 (#33157)
* add 2015.5.11 release notes (#33160)
* add 2015.8.9 release notes (#33161)
* Pip fix (#33180)
* fix pip!!
* make it work with old pip as well
* Added resiliency
* Don't need to check, just get the right name
* [2015.5] Update to latest bootstrap script v2016.05.11 (#33185)
2016-05-12 14:53:39 +00:00
|
|
|
def tearDown(self):
|
|
|
|
'''
|
|
|
|
Teardown method to remove installed packages
|
|
|
|
'''
|
2016-06-28 21:10:11 +00:00
|
|
|
user = ''
|
|
|
|
user_info = self.run_call('--local grains.get username')
|
|
|
|
if user_info and isinstance(user_info, (list, tuple)) and isinstance(user_info[-1], six.string_types):
|
|
|
|
user = user_info[-1].strip()
|
|
|
|
if user == 'root':
|
|
|
|
for pkg in _PKGS_INSTALLED:
|
|
|
|
_ = self.run_call('--local pkg.remove {0}'.format(pkg))
|
|
|
|
super(CallTest, self).tearDown()
|
|
|
|
|
|
|
|
# pylint: disable=invalid-name
|
|
|
|
def test_exit_status_unknown_argument(self):
|
|
|
|
'''
|
|
|
|
Ensure correct exit status when an unknown argument is passed to salt-call.
|
|
|
|
'''
|
|
|
|
|
|
|
|
call = testprogram.TestProgramSaltCall(
|
|
|
|
name='unknown_argument',
|
|
|
|
parent_dir=self._test_dir,
|
|
|
|
)
|
|
|
|
# Call setup here to ensure config and script exist
|
|
|
|
call.setup()
|
|
|
|
stdout, stderr, status = call.run(
|
|
|
|
args=['--unknown-argument'],
|
|
|
|
catch_stderr=True,
|
|
|
|
with_retcode=True,
|
|
|
|
)
|
|
|
|
self.assert_exit_status(
|
|
|
|
status, 'EX_USAGE',
|
|
|
|
message='unknown argument',
|
|
|
|
stdout=stdout, stderr=stderr
|
|
|
|
)
|
|
|
|
|
|
|
|
def test_exit_status_correct_usage(self):
|
|
|
|
'''
|
|
|
|
Ensure correct exit status when salt-call starts correctly.
|
|
|
|
'''
|
|
|
|
|
|
|
|
call = testprogram.TestProgramSaltCall(
|
|
|
|
name='correct_usage',
|
|
|
|
parent_dir=self._test_dir,
|
|
|
|
)
|
|
|
|
# Call setup here to ensure config and script exist
|
|
|
|
call.setup()
|
|
|
|
stdout, stderr, status = call.run(
|
|
|
|
args=['--local', 'test.true'],
|
|
|
|
catch_stderr=True,
|
|
|
|
with_retcode=True,
|
|
|
|
)
|
|
|
|
self.assert_exit_status(
|
|
|
|
status, 'EX_OK',
|
|
|
|
message='correct usage',
|
|
|
|
stdout=stdout, stderr=stderr
|
|
|
|
)
|
|
|
|
|
2012-09-30 09:59:07 +00:00
|
|
|
|
2013-06-24 22:53:59 +00:00
|
|
|
if __name__ == '__main__':
|
2016-06-28 21:10:11 +00:00
|
|
|
integration.run_tests(CallTest)
|