Skip to content

Commit

Permalink
Adjust deprecations (#1)
Browse files Browse the repository at this point in the history
* First batch of c.g 2.0.0 deprecations.

* Remove use_tls and force from docker_image.

* More removals.

* Change community.general 3.0.0 deprecations to community.docker 2.0.0.

* Fix sanity.

* Fixing some bugs.

* Add PR URL to fragment.

ci_complete
ci_coverage

* Improve docs, remove superfluous code.
  • Loading branch information
felixfontein authored Oct 30, 2020
1 parent e69327f commit 01e47a6
Show file tree
Hide file tree
Showing 21 changed files with 67 additions and 870 deletions.
23 changes: 23 additions & 0 deletions changelogs/fragments/c.g-2.0.0-deprecations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
removed_features:
- "docker_image_facts - this alias is on longer availabe, use ``docker_image_info`` instead (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_image - the ``source`` option is now mandatory (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_image - the default of the ``build.pull`` option changed to ``false`` (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_image - the ``container_limits``, ``dockerfile``, ``http_timeout``, ``nocache``, ``rm``, ``path``, ``buildargs``, ``pull`` have been removed. Use the corresponding suboptions of ``build`` instead (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_image - the ``force`` option has been removed. Use the more specific ``force_*`` options instead (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_image - the ``use_tls`` option has been removed. Use ``tls`` and ``validate_certs`` instead (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_image - ``state=build`` has been removed. Use ``present`` instead (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_volume - the ``force`` option has been removed. Use ``recreate`` instead (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_volume - no longer returns ``ansible_facts`` (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_swarm - ``state=inspect`` has been removed. Use ``docker_swarm_info`` instead (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_network - the ``ipam_options`` option has been removed. Use ``ipam_config`` instead (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_network - no longer returns ``ansible_facts`` (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_service - no longer returns ``ansible_facts`` (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_swarm_service - the ``constraints`` option has been removed. Use ``placement.constraints`` instead (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_swarm_service - the ``limit_cpu`` and ``limit_memory`` options has been removed. Use the corresponding suboptions in ``limits`` instead (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_swarm_service - the ``log_driver`` and ``log_driver_options`` options has been removed. Use the corresponding suboptions in ``logging`` instead (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_swarm_service - the ``reserve_cpu`` and ``reserve_memory`` options has been removed. Use the corresponding suboptions in ``reservations`` instead (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_swarm_service - the ``restart_policy``, ``restart_policy_attempts``, ``restart_policy_delay`` and ``restart_policy_window`` options has been removed. Use the corresponding suboptions in ``restart_config`` instead (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_swarm_service - the ``update_delay``, ``update_parallelism``, ``update_failure_action``, ``update_monitor``, ``update_max_failure_ratio`` and ``update_order`` options has been removed. Use the corresponding suboptions in ``update_config`` instead (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_container - the default of ``networks_cli_compatible`` changed to ``true`` (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_container - no longer returns ``ansible_facts`` (https://github.com/ansible-collections/community.docker/pull/1)."
- "docker_container - the unused option ``trust_image_content`` has been removed (https://github.com/ansible-collections/community.docker/pull/1)."
8 changes: 0 additions & 8 deletions plugins/module_utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,14 +427,6 @@ def auth_params(self):
for key in DOCKER_COMMON_ARGS:
params[key] = self.module.params.get(key)

if self.module.params.get('use_tls'):
# support use_tls option in docker_image.py. This will be deprecated.
use_tls = self.module.params.get('use_tls')
if use_tls == 'encrypt':
params['tls'] = True
if use_tls == 'verify':
params['validate_certs'] = True

result = dict(
docker_host=self._get_value('docker_host', params['docker_host'], 'DOCKER_HOST',
DEFAULT_DOCKER_HOST),
Expand Down
9 changes: 1 addition & 8 deletions plugins/modules/docker_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,6 @@
services:
description:
- A dictionary mapping the service's name to a dictionary of containers.
- Note that facts are part of the registered vars since Ansible 2.8. For compatibility reasons, the facts
are also accessible directly. The service's name is the variable with which the container dictionary
can be accessed. Note that the returned facts will be removed in community.general 2.0.0.
returned: success
type: complex
contains:
Expand Down Expand Up @@ -705,7 +702,7 @@ def cmd_up(self):
start_deps = self.dependencies
service_names = self.services
detached = True
result = dict(changed=False, actions=[], ansible_facts=dict(), services=dict())
result = dict(changed=False, actions=[], services=dict())

up_options = {
u'--no-recreate': False,
Expand Down Expand Up @@ -809,7 +806,6 @@ def cmd_up(self):

for service in self.project.services:
service_facts = dict()
result['ansible_facts'][service.name] = service_facts
result['services'][service.name] = service_facts
for container in service.containers(stopped=True):
inspection = container.inspect()
Expand Down Expand Up @@ -1138,9 +1134,6 @@ def main():
supports_check_mode=True,
min_docker_api_version='1.20',
)
if client.module._name in ('docker_service', 'community.docker.docker_service'):
client.module.deprecate("The 'docker_service' module has been renamed to 'docker_compose'.",
version='2.0.0', collection_name='community.general') # was Ansible 2.12

try:
result = ContainerManager(client).exec_module()
Expand Down
64 changes: 20 additions & 44 deletions plugins/modules/docker_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
these options, it will be recreated instead. The options with default values which can cause this are I(auto_remove),
I(detach), I(init), I(interactive), I(memory), I(paused), I(privileged), I(read_only) and I(tty). This behavior
can be changed by setting I(container_default_behavior) to C(no_defaults), which will be the default value from
community.general 3.0.0 on.
community.docker 2.0.0 on.
options:
auto_remove:
Expand Down Expand Up @@ -89,7 +89,7 @@
containers which use different values for these options.
- The default value is C(compatibility), which will ensure that the default values
are used when the values are not explicitly specified by the user.
- From community.general 3.0.0 on, the default value will switch to C(no_defaults). To avoid
- From community.docker 2.0.0 on, the default value will switch to C(no_defaults). To avoid
deprecation warnings, please set I(container_default_behavior) to an explicit
value.
- This affects the I(auto_remove), I(detach), I(init), I(interactive), I(memory),
Expand Down Expand Up @@ -506,7 +506,7 @@
network_mode:
description:
- Connect the container to a network. Choices are C(bridge), C(host), C(none), C(container:<name|id>), C(<network_name>) or C(default).
- "*Note* that from community.general 3.0.0 on, if I(networks_cli_compatible) is C(true) and I(networks) contains at least one network,
- "*Note* that from community.docker 2.0.0 on, if I(networks_cli_compatible) is C(true) and I(networks) contains at least one network,
the default value for I(network_mode) will be the name of the first network in the I(networks) list. You can prevent this
by explicitly specifying a value for I(network_mode), like the default value C(default) which will be used by Docker if
I(network_mode) is not specified."
Expand All @@ -520,10 +520,9 @@
- List of networks the container belongs to.
- For examples of the data structure and usage see EXAMPLES below.
- To remove a container from one or more networks, use the I(purge_networks) option.
- Note that as opposed to C(docker run ...), M(community.docker.docker_container) does not remove the default
network if I(networks) is specified. You need to explicitly use I(purge_networks) to enforce
the removal of the default network (and all other networks not explicitly mentioned in I(networks)).
Alternatively, use the I(networks_cli_compatible) option, which will be enabled by default from community.general 2.0.0 on.
- If I(networks_cli_compatible) is set to C(false), this will not remove the default network if I(networks) is specified.
This is different from the behavior of C(docker run ...). You need to explicitly use I(purge_networks) to enforce
the removal of the default network (and all other networks not explicitly mentioned in I(networks)) in that case.
type: list
elements: dict
suboptions:
Expand Down Expand Up @@ -553,24 +552,24 @@
elements: str
networks_cli_compatible:
description:
- "When networks are provided to the module via the I(networks) option, the module
behaves differently than C(docker run --network): C(docker run --network other)
will create a container with network C(other) attached, but the default network
not attached. This module with I(networks: {name: other}) will create a container
with both C(default) and C(other) attached. If I(purge_networks) is set to C(yes),
the C(default) network will be removed afterwards."
- "If I(networks_cli_compatible) is set to C(yes), this module will behave as
- "If I(networks_cli_compatible) is set to C(yes) (default), this module will behave as
C(docker run --network) and will *not* add the default network if I(networks) is
specified. If I(networks) is not specified, the default network will be attached."
- "When I(networks_cli_compatible) is set to C(no) and networks are provided to the module
via the I(networks) option, the module behaves differently than C(docker run --network):
C(docker run --network other) will create a container with network C(other) attached,
but the default network not attached. This module with I(networks: {name: other}) will
create a container with both C(default) and C(other) attached. If I(purge_networks) is
set to C(yes), the C(default) network will be removed afterwards."
- "*Note* that docker CLI also sets I(network_mode) to the name of the first network
added if C(--network) is specified. For more compatibility with docker CLI, you
explicitly have to set I(network_mode) to the name of the first network you're
adding. This behavior will change for community.general 3.0.0: then I(network_mode) will
adding. This behavior will change for community.docker 2.0.0: then I(network_mode) will
automatically be set to the first network name in I(networks) if I(network_mode)
is not specified, I(networks) has at least one entry and I(networks_cli_compatible)
is C(true)."
- Current value is C(no). A new default of C(yes) will be set in community.general 2.0.0.
type: bool
default: true
oom_killer:
description:
- Whether or not to disable OOM Killer for the container.
Expand Down Expand Up @@ -744,12 +743,6 @@
the docker daemon will always use the container's configured C(StopTimeout)
value if it has been configured.
type: int
trust_image_content:
description:
- If C(yes), skip image verification.
- The option has never been used by the module. It will be removed in community.general 3.0.0.
type: bool
default: no
tmpfs:
description:
- Mount a tmpfs directory.
Expand Down Expand Up @@ -1050,9 +1043,6 @@
container:
description:
- Facts representing the current state of the container. Matches the docker inspection output.
- Note that facts are part of the registered vars since Ansible 2.8. For compatibility reasons, the facts
are also accessible directly as C(docker_container). Note that the returned fact will be removed in
community.general 2.0.0.
- Before 2.3 this was C(ansible_docker_container) but was renamed in 2.3 to C(docker_container) due to
conflicts with the connection plugin.
- Empty if I(state) is C(absent)
Expand Down Expand Up @@ -1285,7 +1275,6 @@ def __init__(self, client):
self.stop_signal = None
self.stop_timeout = None
self.tmpfs = None
self.trust_image_content = None
self.tty = None
self.user = None
self.uts = None
Expand Down Expand Up @@ -2618,7 +2607,6 @@ def __init__(self, client):
self.results['diff'] = self.diff

if self.facts:
self.results['ansible_facts'] = {'docker_container': self.facts}
self.results['container'] = self.facts

def wait_for_state(self, container_id, complete_states=None, wait_states=None, accept_removal=False, max_wait=None):
Expand Down Expand Up @@ -3075,7 +3063,7 @@ class AnsibleDockerClientContainer(AnsibleDockerClient):
# A list of module options which are not docker container properties
__NON_CONTAINER_PROPERTY_OPTIONS = tuple([
'env_file', 'force_kill', 'keep_volumes', 'ignore_image', 'name', 'pull', 'purge_networks',
'recreate', 'restart', 'state', 'trust_image_content', 'networks', 'cleanup', 'kill_signal',
'recreate', 'restart', 'state', 'networks', 'cleanup', 'kill_signal',
'output_logs', 'paused', 'removal_wait_timeout'
] + list(DOCKER_COMMON_ARGS.keys()))

Expand Down Expand Up @@ -3263,8 +3251,8 @@ def __init__(self, **kwargs):
self.module.params['container_default_behavior'] = 'compatibility'
self.module.deprecate(
'The container_default_behavior option will change its default value from "compatibility" to '
'"no_defaults" in community.general 3.0.0. To remove this warning, please specify an explicit value for it now',
version='3.0.0', collection_name='community.general' # was Ansible 2.14
'"no_defaults" in community.docker 2.0.0. To remove this warning, please specify an explicit value for it now',
version='2.0.0', collection_name='community.docker' # was Ansible 2.14 / community.general 3.0.0
)
if self.module.params['container_default_behavior'] == 'compatibility':
old_default_values = dict(
Expand Down Expand Up @@ -3376,7 +3364,7 @@ def main():
aliases=dict(type='list', elements='str'),
links=dict(type='list', elements='str'),
)),
networks_cli_compatible=dict(type='bool'),
networks_cli_compatible=dict(type='bool', default=True),
oom_killer=dict(type='bool'),
oom_score_adj=dict(type='int'),
output_logs=dict(type='bool', default=False),
Expand All @@ -3401,8 +3389,6 @@ def main():
stop_timeout=dict(type='int'),
sysctls=dict(type='dict'),
tmpfs=dict(type='list', elements='str'),
trust_image_content=dict(type='bool', default=False, removed_in_version='2.0.0',
removed_from_collection='community.general'), # was Ansible 2.12
tty=dict(type='bool'),
ulimits=dict(type='list', elements='str'),
user=dict(type='str'),
Expand All @@ -3424,16 +3410,6 @@ def main():
supports_check_mode=True,
min_docker_api_version='1.20',
)
if client.module.params['networks_cli_compatible'] is None and client.module.params['networks']:
client.module.deprecate(
'Please note that docker_container handles networks slightly different than docker CLI. '
'If you specify networks, the default network will still be attached as the first network. '
'(You can specify purge_networks to remove all networks not explicitly listed.) '
'This behavior will change in community.general 2.0.0. You can change the behavior now by setting '
'the new `networks_cli_compatible` option to `yes`, and remove this warning by setting '
'it to `no`',
version='2.0.0', collection_name='community.general', # was Ansible 2.12
)
if client.module.params['networks_cli_compatible'] is True and client.module.params['networks'] and client.module.params['network_mode'] is None:
client.module.deprecate(
'Please note that the default value for `network_mode` will change from not specified '
Expand All @@ -3444,7 +3420,7 @@ def main():
'Please make sure that the value you set to `network_mode` equals the inspection result '
'for existing containers, otherwise the module will recreate them. You can find out the '
'correct value by running "docker inspect --format \'{{.HostConfig.NetworkMode}}\' <container_name>"',
version='3.0.0', collection_name='community.general', # was Ansible 2.14
version='2.0.0', collection_name='community.docker', # was Ansible 2.14 / community.general 3.0.0
)

try:
Expand Down
Loading

0 comments on commit 01e47a6

Please sign in to comment.