diff --git a/cloud/docker/docker.py b/cloud/docker/docker.py index 6308bd94efe..1bd49b0f66d 100644 --- a/cloud/docker/docker.py +++ b/cloud/docker/docker.py @@ -298,7 +298,19 @@ options: required: false default: null version_added: "2.0" - + cap_add: + description: + - Add capabilities for the container. Requires docker-py >= 0.5.0. + required: false + default: false + version_added: "2.0" + cap_drop: + description: + - Drop capabilities for the container. Requires docker-py >= 0.5.0. + required: false + default: false + aliases: [] + version_added: "2.0" author: - "Cove Schneider (@cove)" - "Joshua Conner (@joshuaconner)" @@ -557,6 +569,8 @@ class DockerManager(object): 'log_driver': ((1, 2, 0), '1.18'), 'host_config': ((0, 7, 0), '1.15'), 'cpu_set': ((0, 6, 0), '1.14'), + 'cap_add': ((0, 5, 0), '1.14'), + 'cap_drop': ((0, 5, 0), '1.14'), # Clientside only 'insecure_registry': ((0, 5, 0), '0.0') } @@ -1328,7 +1342,8 @@ class DockerManager(object): optionals = {} for optional_param in ('dns', 'volumes_from', 'restart_policy', - 'restart_policy_retry', 'pid', 'extra_hosts', 'log_driver'): + 'restart_policy_retry', 'pid', 'extra_hosts', 'log_driver', + 'cap_add', 'cap_drop'): optionals[optional_param] = self.module.params.get(optional_param) if optionals['dns'] is not None: @@ -1363,6 +1378,14 @@ class DockerManager(object): log_config.type = optionals['log_driver'] params['log_config'] = log_config + if optionals['cap_add'] is not None: + self.ensure_capability('cap_add') + params['cap_add'] = optionals['cap_add'] + + if optionals['cap_drop'] is not None: + self.ensure_capability('cap_drop') + params['cap_drop'] = optionals['cap_drop'] + return docker.utils.create_host_config(**params) def create_containers(self, count=1): @@ -1616,6 +1639,8 @@ def main(): insecure_registry = dict(default=False, type='bool'), log_driver = dict(default=None, choices=['json-file', 'none', 'syslog']), cpu_set = dict(default=None), + cap_add = dict(default=None, type='list'), + cap_drop = dict(default=None, type='list'), read_only = dict(default=False, type='bool'), ), required_together = ( diff --git a/cloud/google/gce_net.py b/cloud/google/gce_net.py index 93844901117..3ae1635ded7 100644 --- a/cloud/google/gce_net.py +++ b/cloud/google/gce_net.py @@ -75,7 +75,7 @@ options: aliases: [] state: description: - - desired state of the persistent disk + - desired state of the network or firewall required: false default: "present" choices: ["active", "present", "absent", "deleted"] @@ -264,7 +264,7 @@ def main(): if fw: gce.ex_destroy_firewall(fw) changed = True - if name: + elif name: json_output['name'] = name network = None try: diff --git a/files/copy.py b/files/copy.py index b7f333cead6..ad56800764b 100644 --- a/files/copy.py +++ b/files/copy.py @@ -63,21 +63,13 @@ options: force: description: - the default is C(yes), which will replace the remote file when contents - are different than the source. If C(no), the file will only be transferred + are different than the source. If C(no), the file will only be transferred if the destination does not exist. version_added: "1.1" required: false choices: [ "yes", "no" ] default: "yes" aliases: [ "thirsty" ] - validate: - description: - - The validation command to run before copying into place. The path to the file to - validate is passed in via '%s' which must be present as in the visudo example below. - The command is passed securely so shell features like expansion and pipes won't work. - required: false - default: "" - version_added: "1.2" directory_mode: description: - When doing a recursive copy set the mode for the directories. If this is not set we will use the system @@ -86,6 +78,7 @@ options: required: false version_added: "1.5" extends_documentation_fragment: files +extends_documentation_fragment: validate author: - "Ansible Core Team" - "Michael DeHaan" diff --git a/files/lineinfile.py b/files/lineinfile.py index 6bcfb3b3060..777f0a498a9 100644 --- a/files/lineinfile.py +++ b/files/lineinfile.py @@ -31,6 +31,7 @@ author: - "Daniel Hokka Zakrissoni (@dhozac)" - "Ahti Kitsik (@ahtik)" extends_documentation_fragment: files +extends_documentation_fragment: validate short_description: Ensure a particular line is in a file, or replace an existing line using a back-referenced regular expression. description: @@ -116,16 +117,6 @@ options: description: - Create a backup file including the timestamp information so you can get the original file back if you somehow clobbered it incorrectly. - validate: - required: false - description: - - validation to run before copying into place. - Use %s in the command to indicate the current file to validate. - The command is passed securely so shell features like - expansion and pipes won't work. - required: false - default: None - version_added: "1.4" others: description: - All arguments accepted by the M(file) module also work here. diff --git a/files/replace.py b/files/replace.py index fa0142823ea..dea2c32a54f 100644 --- a/files/replace.py +++ b/files/replace.py @@ -27,6 +27,7 @@ DOCUMENTATION = """ module: replace author: "Evan Kaufman (@EvanK)" extends_documentation_fragment: files +extends_documentation_fragment: validate short_description: Replace all instances of a particular string in a file using a back-referenced regular expression. description: @@ -61,12 +62,6 @@ options: description: - Create a backup file including the timestamp information so you can get the original file back if you somehow clobbered it incorrectly. - validate: - required: false - description: - - validation to run before copying into place - required: false - default: None others: description: - All arguments accepted by the M(file) module also work here. diff --git a/files/template.py b/files/template.py index a1dc72c27bd..120917f49c2 100644 --- a/files/template.py +++ b/files/template.py @@ -38,15 +38,6 @@ options: required: false choices: [ "yes", "no" ] default: "no" - validate: - description: - - The validation command to run before copying into place. - - The path to the file to validate is passed in via '%s' which must be present as in the visudo example below. - - validation to run before copying into place. The command is passed - securely so shell features like expansion and pipes won't work. - required: false - default: "" - version_added: "1.2" force: description: - the default is C(yes), which will replace the remote file when contents @@ -62,6 +53,7 @@ author: - Ansible Core Team - Michael DeHaan extends_documentation_fragment: files +extends_documentation_fragment: validate ''' EXAMPLES = ''' diff --git a/packaging/language/pip.py b/packaging/language/pip.py index ec0bf93979c..8bbae35038d 100644 --- a/packaging/language/pip.py +++ b/packaging/language/pip.py @@ -155,7 +155,7 @@ def _get_cmd_options(module, cmd): words = stdout.strip().split() cmd_options = [ x for x in words if x.startswith('--') ] return cmd_options - + def _get_full_name(name, version=None): if version is None: @@ -356,7 +356,8 @@ def main(): rc, out_pip, err_pip = module.run_command(cmd, path_prefix=path_prefix, cwd=this_dir) out += out_pip err += err_pip - if rc == 1 and state == 'absent' and 'not installed' in out_pip: + if rc == 1 and state == 'absent' and \ + ('not installed' in out_pip or 'not installed' in err_pip): pass # rc is 1 when attempting to uninstall non-installed package elif rc != 0: _fail(module, cmd, out, err) diff --git a/source_control/hg.py b/source_control/hg.py index 47b23d26fd5..285bc6f1729 100644 --- a/source_control/hg.py +++ b/source_control/hg.py @@ -65,6 +65,13 @@ options: required: false default: "no" choices: [ "yes", "no" ] + update: + required: false + default: "yes" + choices: [ "yes", "no" ] + version_added: "2.0" + description: + - If C(no), do not retrieve new revisions from the origin repository executable: required: false default: null @@ -210,6 +217,7 @@ def main(): revision = dict(default=None, aliases=['version']), force = dict(default='no', type='bool'), purge = dict(default='no', type='bool'), + update = dict(default='yes', type='bool'), executable = dict(default=None), ), ) @@ -218,6 +226,7 @@ def main(): revision = module.params['revision'] force = module.params['force'] purge = module.params['purge'] + update = module.params['update'] hg_path = module.params['executable'] or module.get_bin_path('hg', True) hgrc = os.path.join(dest, '.hg/hgrc') @@ -234,6 +243,9 @@ def main(): (rc, out, err) = hg.clone() if rc != 0: module.fail_json(msg=err) + elif not update: + # Just return having found a repo already in the dest path + before = hg.get_revision() elif hg.at_revision: # no update needed, don't pull before = hg.get_revision() diff --git a/web_infrastructure/django_manage.py b/web_infrastructure/django_manage.py index 2637446d6f3..b3cabfe01b5 100644 --- a/web_infrastructure/django_manage.py +++ b/web_infrastructure/django_manage.py @@ -90,7 +90,7 @@ notes: - I(virtualenv) (U(http://www.virtualenv.org)) must be installed on the remote host if the virtualenv parameter is specified. - This module will create a virtualenv if the virtualenv parameter is specified and a virtualenv does not already exist at the given location. - This module assumes English error messages for the 'createcachetable' command to detect table existence, unfortunately. - - To be able to use the migrate command, you must have south installed and added as an app in your settings + - To be able to use the migrate command with django versions < 1.7, you must have south installed and added as an app in your settings - To be able to use the collectstatic command, you must have enabled staticfiles in your settings requirements: [ "virtualenv", "django" ] author: "Scott Anderson (@tastychutney)" @@ -163,7 +163,7 @@ def syncdb_filter_output(line): return ("Creating table " in line) or ("Installed" in line and "Installed 0 object" not in line) def migrate_filter_output(line): - return ("Migrating forwards " in line) or ("Installed" in line and "Installed 0 object" not in line) + return ("Migrating forwards " in line) or ("Installed" in line and "Installed 0 object" not in line) or ("Applying" in line) def collectstatic_filter_output(line): return "0 static files" not in line diff --git a/windows/win_stat.ps1 b/windows/win_stat.ps1 index 10101a62b30..51c9c827093 100644 --- a/windows/win_stat.ps1 +++ b/windows/win_stat.ps1 @@ -19,6 +19,11 @@ $params = Parse-Args $args; +function Date_To_Timestamp($start_date, $end_date) +{ + Write-Output (New-TimeSpan -Start $start_date -End $end_date).TotalSeconds +} + $path = Get-Attr $params "path" $FALSE; If ($path -eq $FALSE) { @@ -36,6 +41,7 @@ If (Test-Path $path) { Set-Attr $result.stat "exists" $TRUE; $info = Get-Item $path; + $epoch_date = Get-Date -Date "01/01/1970" If ($info.Directory) # Only files have the .Directory attribute. { Set-Attr $result.stat "isdir" $FALSE; @@ -45,6 +51,12 @@ If (Test-Path $path) { Set-Attr $result.stat "isdir" $TRUE; } + Set-Attr $result.stat "extension" $info.Extension; + Set-Attr $result.stat "attributes" $info.Attributes.ToString(); + Set-Attr $result.stat "owner" $info.GetAccessControl().Owner; + Set-Attr $result.stat "creationtime" (Date_To_Timestamp $epoch_date $info.CreationTime); + Set-Attr $result.stat "lastaccesstime" (Date_To_Timestamp $epoch_date $info.LastAccessTime); + Set-Attr $result.stat "lastwritetime" (Date_To_Timestamp $epoch_date $info.LastWriteTime); } Else {