* apt: If the cache object fails to lost due to a corrupt file, try to update the cache until it is fixed.
* Append -q to the update parameters
* Remove unused variable
* Use a string that doesn't rely on internationalization
* Use py24 exception style
* Use get_exception
Fixes#2951
* updated `find_job` method to find by exact match of job, when no matching header comment is found
* note this fallback injects a header comment for later calls to `update_job` or `remove_job`
* abstracted header comment building to `do_comment` method
Fixes#3256
In the description of the find module return value, the sample dict
has its key=value strings converted to key=value: None in the
web documentation. This commit updates the sample output to a 'real'
dict.
Minor additional edit in the description: "return list *of* files".
* Use the `to_native` conversion method to convert a command output to the
appropriate form when looking for branch names in the command output,
therefore avoiding a `TypeError` in Python 3.
In python3, response fields are title cased whereas in python2 they were
not. We return these fields to the module's caller so we need to
normalize all of them to be lower case.
This reverts the lowercase check from 454f741ef5
as that one was only targetted as a single field.
Records whether existing cron file (or CRONCMD output) has a terminating newline, and ensures a trailing newline is written as necessary EVEN IF NO CHANGE WAS MADE to the target env/job
Fixes#2316
make format function 'format only'
added platform dependant info, when it is available
avoid rechecking same info
added comments to each info gathering section
(cherry picked from commit a79acf73d7eb79b76d808ff8a1d6c505dfd9ec82)
builddep only requires a source package to be in the repos but our code
was checking for a binary package before running buiddep. Reversing the
order makes it work correctly.
Fixes#4519
* Only change to short IDs for delete
If the user specifies long IDs, use them for all commands except for
deleting a key. Need to use short IDs there because of an upstream
apt_key bug. Fixed in apt_key 1.10 (fix is present in Ubuntu 16.04 but
not Ubuntu 14.0 or some Debians).
Fixes#5237
* Check that apt-key really erased the key
When erasing a key, apt-key does not understand how to process subkeys.
This update explicitly checks that the key_id is no longer present and
throws an error if it is. It also hints at subkeys being a possible
problem in the error message and the documentation.
Fixes#5119
* Fix apt_key check mode with long ids
apt-key can be given a key id longer than 16 chars to more accurately
define what key to download. However, we can use a maximum of 16
chars to verify whether a key is installed or not. So we need to use
different lengths for the id depending on what we're doing with it.
Fixes#2622
Also:
* Some style cleanups
* Use get_bin_path to find the path to apt-key and then use that when
invoking apt-key
* Return a nice user error message if the key was not found on the
keyserver
* Make file and keyring parameters type='path' so envars and tilde are
expanded
* Make authorized_key preserve key order
Track the ordering of keys in the original file (rank)
and try to preserve it when writing out updates.
Fixes#4780
Comparing to the output of run_command() needs to use native strings
Also fix imports: We were relying on them coming from the import of
basic. A few (like yaml) weren't imported at all.
* Add option for number parameter to generate manually provisioned clusters from a base name
* Refactor code to work with starting and stopped when number is specified
* Update docs
* Fix documentation error breaking Travis
* Fixes for async gce operations
* Fix documentation
* base_name from parameter to alias for name and fixes for renaming variables
* Fix breaking change on gce.py
* Fix bugs with name parameter
* Fix comments for Github build checks
* Add logic to set changed appropriately for cluster provisioning
The last fix allowing multiple definitions of the same option key (for
permitopen support) introduced a set() which removed the guaranteed
ordering of the options.
This change restores ordering. The change is larger than simply
removing the set because we do need to handle the non-dict semantics
around keys not being unique in the data structure. The new code make
use of __setitem__() and items() to do its work. Trying to use
getitem() or keys() should be looked upon with suspicion as neither of
those follow dictionary semantics and it is quite possible the coder
doesn't realize this. The next time we need to touch or enhance the
keydict code it should probably be rewritten to not pretend to extend
the dictionary interface.
* Add separate checkout and update parameters
This brings the svn module in line with the git module for controlling
individual update and checkout functionality based on whether the
directory exists or not.
It also allows specifying `no` for both to pull the remote revision
without performing a checkout
* Update version-added for new parameters
* Add separate clone parameter
This brings the hg module in line with the git module for controlling
individual update and checkout functionality based on whether the
directory exists or not.
It also allows specifying `no` for both to pull the remote revision
without performing a checkout
* Reflect the right added ver for the hg clone arg
Support the new native YAML format in the CloudFormation API. This means
the existing `template_format` parameter is deprecated. This commit also
adds a warning for the deprecated parameter.
* Run validate-modules from devel
Use a clean dir for checkout
typo
Correct path
validate-modules requires mock and voluptuous==0.8.8
typo
Ensure script is running
Remove testing debug
Install Ansible only once
Install ansible and validate_modules requirements
Now that we no longer pip install Ansible we need to manually install
it's dependencies
Debug
Dependencies are listed in ansible/ansible
debug
submodules
typo
typo
working
* Matt's feedback
* Use mktemp to checkout and delete directory after running
* Single quotes
the docker container module's `exposed_ports` was slightly ambigous.
Use the official Docker documentation to define what an `exposed port`
is.
Resolves: ansible/ansible-modules-core#5303
Signed-off-by: Daniel Andrei Minca <mandrei17@gmail.com>
Since dict.keys return a dictkeys under python 3, we hav to cast it
to a list to avoid traceback:
Traceback (most recent call last):
File "/tmp/ansible_sh16ejbd/ansible_module_authorized_key.py", line 496, in <module>
main()
File "/tmp/ansible_sh16ejbd/ansible_module_authorized_key.py", line 490, in main
results = enforce_state(module, module.params)
File "/tmp/ansible_sh16ejbd/ansible_module_authorized_key.py", line 410, in enforce_state
parsed_new_key = parsekey(module, new_key)
File "/tmp/ansible_sh16ejbd/ansible_module_authorized_key.py", line 308, in parsekey
options = parseoptions(module, options)
File "/tmp/ansible_sh16ejbd/ansible_module_authorized_key.py", line 259, in parseoptions
options_dict[key] = value
File "/tmp/ansible_sh16ejbd/ansible_module_authorized_key.py", line 164, in __setitem__
self.itemlist.append(key)
AttributeError: 'dict_keys' object has no attribute 'append'
Yet another fix for https://github.com/ansible/ansible/pull/18053
- Don't rewrite the result; this is causing 'changed=true' on update
- Move AWSRetry import to top since it's a decorator, and is needed at definition-time
- removed star-imports, which wasn't possible in Ansible 1.x
- boto doesn't have any of the modern features (most notably, changesets), so this rewrite goes all-in on boto3.
- tags are updateable, at least in boto3. Fix documentation.
- staying with "ansible yaml to json conversion" because I'm trying to keep this scoped properly. The next PR will have AWS-native yaml support.
- documented the output. Tried to leave it backwards-compatible but the changes to 'events' might break someone's flow. However, the existing data wasn't terribly useful so I don't assume it will hurt.
- split up the code into functions. This should make unit testing possible.
- added forward-facing code: 'six' for iterating, started using AWSRetry, common tag conversion.
- add todo list
- Pass `exception` parameter to fail_json
Since the module use re and os, we need to import them.
And rather than importing '*', we should limit to the
only object/function needed, so we can more easily refactor
later.
The implementation is fairly simple, we force the rc= parameter to not be zero so that the check in _executor/task_result.py_ correctly determines that it failed. Without this change Ansible would report the task to be ok (despite failed=True and msg=Some_error_message) although Ansible stops and the summary output reports a failed task.
This fixes#4214, #4384 and also relates to ansible/ansible#12070, ansible/ansible#16006, ansible/ansible##16597, ansible/ansible#17208 and ansible/ansible#17252
This fixes a bug where the module fails to verify tags. I added a conditional statement in `verify_commit_sign()` that checks if `version` argument is a tag, if so, use `git verify-tag` instead.
Test suite block on:
Traceback (most recent call last):
File "/tmp/ansible_fhootp1e/ansible_module_authorized_key.py", line 496, in <module>
main()
File "/tmp/ansible_fhootp1e/ansible_module_authorized_key.py", line 490, in main
results = enforce_state(module, module.params)
File "/tmp/ansible_fhootp1e/ansible_module_authorized_key.py", line 410, in enforce_state
parsed_new_key = parsekey(module, new_key)
File "/tmp/ansible_fhootp1e/ansible_module_authorized_key.py", line 308, in parsekey
options = parseoptions(module, options)
File "/tmp/ansible_fhootp1e/ansible_module_authorized_key.py", line 253, in parseoptions
if options_dict.has_key(key):
AttributeError: 'keydict' object has no attribute 'has_key'
With keydict being a subclass of dict.
In python 3, filter return a iterator and so result in this traceback:
Traceback (most recent call last):
File \"/tmp/ansible_kzu72kz5/ansible_module_subversion.py\", line 264, in <module>
main()
File \"/tmp/ansible_kzu72kz5/ansible_module_subversion.py\", line 243, in main
local_mods = svn.has_local_mods()
File \"/tmp/ansible_kzu72kz5/ansible_module_subversion.py\", line 178, in has_local_mods
return len(filter(regex.match, lines)) > 0
TypeError: object of type 'filter' has no len()
The keys returned by user objects for default domain and
default project are respectively default_domain_id and
default_project_id.
We need to gather those IDs in case the user passed names, so we
can then compare with the user object on the needs_update helper
function.
Since handler.files_in_archive is a list of files coming from
various executables output, that's a bytes list, and we use it
with dest who is a str. So we need to convert that to native
type.
On python 3, bools is a list of bytes:
>>> rc,bools = selinux.security_get_boolean_names()
>>> 'virt_use_nfs' in bools
False
>>> bools
[b'abrt_anon_write', b'abrt_handle_event', ...]
earlier versions of eos do not support configuration sessions. this change
will now check if sessions are supported and if not will fallback to
not using config sessions
fixes#4909
This fixes two issues. First, it fixes an issue with the junos_config
module not properly recognizing a file with set commands. The second
bug would cause the diff_config() function to raise an exception due
to a blank line when splitting the config
* Fix imports on nxos_bgp* modules
* Fix imports on nxos_evpn* modules
* Cleanup issues for nxos_facts
* Shuffle imports for nxos_template
* Fix imports on nxos_ospf* modules
* Fix nxos_hsrp
As get_hsrp_groups_in_devices is not actually called anywhere, I presume this
change is reasonable.
* Fix imports on nxos_interface* modules
* Update nxos_static_route imports
* update nxos_vrf
* Update nxos_config imports
dopy 0.3.7 makes use of six but doesn't list it as a requirement. This
means that people installing with pip won't get six installed, leading
to errors. Upstream released dopy-0.3.7a to address that but pip thinks
that is an alpha release. pip does not install alpha releases by
default so users aren't helped by that.
This change makes ansible emit a good error message in this case.
Fixes#4613
The comment argument can be at most 60 characters per the IOS XR command
line. If a comment is > 60 characters, the module will now gracefully error
and return a well formed message.
fixes 5146
on python3, this means that we don't get bytes back by default. We
probably do want bytes here so modify our call to run_command so we get
bytes instead of text.
* Restart EC2 instances with multiple network interfaces
A previous bug, #3234, caused instances with multiple ENI's to fail when being
started or stopped because sourceDestCheck is a per-interface attribute, but we
use the boto global access to it (which only works when there's a single ENI).
This patch handles a variant of that bug that only surfaced when restarting an
instance, and catches the same type of exception.
* Default termination_protection to None instead of False
AWS defaults the value of termination_protection to False, so we don't
need to explicitly send `False` when the user hasn't specified a
termination protection level. Before this patch, the below pair of tasks
would:
1. Create an instance (enabling termination_protection)
2. Restart that instance (disabling termination_protection)
Now, the default None value would prevent the restart task from
disabling termination_protection.
```
- name: make an EC2 instance
ec2:
vpc_subnet_id: {{ subnet }}
instance_type: t2.micro
termination_protection: yes
exact_count: 1
count_tag:
Name: TestInstance
instance_tags:
Name: TestInstance
group_id: {{ group }}
image: ami-7172b611
wait: yes
- name: restart a protected EC2 instance
ec2:
vpc_subnet_id: {{ subnet }}
state: restarted
instance_tags:
Name: TestInstance
group_id: {{ group }}
image: ami-7172b611
wait: yes
```
The Conditional instance will now raise the AddConditionError and this
change instructs eos_command to catch the error and return a nicely formed
error message
Per #3877, the code to wait for spot instance requests to finish would
hang for the full wait time if any spot request failed for any reason.
This commit introduces status checks for spot requests, so if the
request fails, finishes, or is cancelled the task will fail/succeed
accordingly.
One edge case introduced here is tha if a user terminates the instance
associated with the request manually it won't fail the play, under the
presumption that the user *wants* the instance terminated.
The junos_command module wasn't properly parsing strings to apply
conditionals due to the return value not being converted to json
before the results where handed to the runner.
This change is in response to issue #1497 where the apt module would not properly updating the apt cache in some situations and never returned a state change on cache update when the module was used without or without an item to be installed or upgraded.
The change simply allows the apt module to update the cache when update_cache option is used without or without a set cache_valid_time.
If cache_valid_time is set and the on disk mtime for apt cache is ">" the provided amount of seconds, which now has a default of 0, the apt cache will be updated. Additionally if no upgrade, package, or deb is installed or changed but the apt cache is updated the module will return a changed state which will help users to know that the state of the environment has changed due to a task operation, even if it was only an apt cache update.
fixes#1497
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
The junos_config module will generate an exception if a 'delete ...' config
command is attempted to be loaded into a device configuration. This change
will first check to see if the delete command is valid and filter it out
of the change set if it is not valid.
fixes#5040
A value for the project_id parameter to shade's create_network()
call was always being sent, even if no value for 'project' was
supplied. This was breaking folks with older versions of shade
(< 1.6).
Fixes PR https://github.com/ansible/ansible-modules-core/issues/3567
* dict.iteritems does not exist in Python 3
Now just dict.items
six.iteritems handles the change
* Addresses point 1
Unsure if this is a good idea or not.
* Addresses point 2
This shouldn't have any particular change, just marks load_comments as abstract
* Remove unused import
Addresses point 3
* Clarify invalid subset error message
Addresses point 4
The junos_command expects commands to be returned as xml by default but
`show configuration [options]` will return text not xml. This fix
will set the output format for any command that starts with `show
configuration` to text
fixes#4628
The return string from the commands was not being passed through the
jxmlease library and therefore being returned as a string instead of a
json data structure. This also adds back the missing xml key in the
return that includes the raw xml string.
fixes#5001
This fixes a condition where an exception is raised when collecting `interface`
facts and the transport is set to nxapi in the nxos_nxapi module.
fixesansible/ansible#17691
* Fixing bind mount on Linux
* The latest update from jtyr doesn't pass integration tests.
Manually select the changes that are necessary to fix the bug with
unmounting
When setting state=absent the nxos_nxapi module would always try to remove
the configuration regardless of the current state of the device. This will
fix that problem.
This also updates the docstring to correctly reflect https as default=no
fixes#4955
depends on ansible/ansible#17728
Fixes#4063.
Tar does not use this parameter on extraction (-x) or diff (-d)(the
only two cases where it is passed in unarchive). It only uses it on
creation:
https://www.gnu.org/software/tar/manual/html_section/tar_33.html
Providing `unarchive` with a file mode of `0755` (octal) makes it pass
the argument `--mode 493` (493 = 0755 in decimal) to `tar`, which then
fails while verifying it (because it contains an invalid octal char
'9'). Not passing the parameter to tar solves the issue.
* Add support for password aging on Solaris
* Fix shadow file editing when {MIN,MAX,WARN}WEEKS is not set in /etc/default/passwd
* Un-break with python3
* _Really_ un-break with python3
* Pip: handle parsing different pip commands
* Pip: use 'pip list' when available
* Pip: explicitly check which command is used
* Pip: add error checking when fetching packages
* fixed docstring referencing old arguments
* changed out lxml for xml library to avoid import errors
* fixed issue when trying to confirm a commit will end up a NOOP
* fixed issue for passing replace argument to load_config method
* fixes exception thrown when sending commands to device
* fixes exception thrown when retrieving current resource instance
* fixes issue where netconf would be configured in some instances when state
was set to absent
* now returns the command string sent to the remote device
* fixes argument name to be netconf_port with alias to listens_on
Rather than just checking whether a package with the right
name is installed, use `local_nvra` to check whether the
version/release/arch differs too.
Remove `local_name` as it is a shortcut too far.
Fixes#3807Fixes#4529
ansible-doc -vvvv -l show this warning:
[WARNING]: While constructing a mapping from /home/misc/checkout/git/ansible/lib/ansible/modules/core/network/junos/junos_config.py,
line 88, column 5, found a duplicate dict key (required). Using last defined value only.
The eos_eapi module would not configure the port if the protocol wasn't
configured as reported in #4905. This changes the behavior to now allow
the port to be configured independently
fixes#4905
The AWS API requires that any termination policy list that includes
`Default` must end with Default. The attribute sorting caused any list
of attributes to be lexically sorted, so a list like
`["OldestLaunchConfiguration", "Default"]` would be changed to
`["Default", "OldestLaunchConfiguration"]` because default is earlier
alphabetically. This caused calls to fail with BotoServerError per #4069
This commit also adds proper tracebacks to all botoservererror fail_json
calls.
Closes#4069
* added Py2.4 and YAML Documentation fixes
* added no_log for password
* incorporated additional review comments
* remove type for options block
* fix type for pn_multiprotocol
CERN maintains its own fork of "Scientific Linux",
which identifies as "Scientific Linux CERN SLC".
This commit lets Ansible know that this is again
another variant of RHEL.
- Use range instead of xrange.
- Use python3-apt package for python 3.
- Eliminate unsupported for/else/raise usage.
- Use list on dict.items when modifying dict.
- Update requirements documentation.
Also made non-intrustive style fixes (adding blank lines).
Previously calculation of the number of instances that have been
terminated assumed all instances were in the first reservation returned
by AWS. If this is not the case the calculated number of instances
terminated never reaches the number of instances and the module always
times out. By unpacking the instances we get an accurate number and the
module correctly exits.
Currently instances with multiple ENI's can't be started or stopped
because sourceDestCheck is a per-interface attribute, but we use the
boto global access to it (which only works when there's a single ENI).
This patch handles multiple ENI's and applies the sourcedestcheck across
all interfaces the same way.
Fixes#3234
The session keyword is no longer needed or supported in the load_config()
method for eos. This fixes an issue in eos_template where the session
keyword was still being sent.
* remove redundant if submodules_updated
* speed up git by reducing remote commands
* run fetch only once
* run ls-remote less
* don't run ls-remote if one would run fetch anyhow
* remove unnecessary remote_branch check in clone
* kept if depth and version given
* fix fetch on old git versions
The daemonizing code here is taken from an ActiveState recipe, which
includes changing to / as a general best practice. While that is
normally true to allow for deleting the directory that the daemon
process started in, in this case it is not relevant as this is not
intended to be an actual long-running daemon.
Issue ansible/ansible#17466
* Added Solaris support to the mount module.
* Added checking so that if a non-standard fstab file is specified it will
still work in Solaris without breaking existing functionality.
* Added a check to avoid writing duplicate vfstab entries on Solaris
* Added "version_added" to new boot option
This means we will have to unarchive the complete archive if a single change is found.
Unfortunately we cannot fix this for `unzip`, the only hope is a pure-python reimplementation.
This fixes problems reported in the comments of #3810
os.getlogin() returns the user logged in on the controlling terminal. However
'crontab' only looks for the login name of the process' real user id which
pwd.getpwuid(os.getuid())[0] does provide.
While in most cases there is no difference, the former might fail under certain
circumstances (e.g. a lxc container connected by attachment without login),
throwing the error 'OSError: [Errno 25] Inappropriate ioctl for device'.
* 'before' and 'after' are now only applied to 'lines'
* remove update argument
* update doc strings
* add path argument when performing config difference