1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

docker_image: stop pulling by default on build (#53911)

* Prepare to change default of build.pull from yes to no in Ansible 2.12.

* Specify build.pull.

* Add changelog.

* Fix bad indent.
This commit is contained in:
Felix Fontein 2019-03-18 06:34:07 +01:00 committed by ansibot
parent 4c2a3bfed5
commit 50d56ca89d
3 changed files with 27 additions and 9 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- "docker_image - the default for ``build.pull`` will change from ``yes`` to ``no`` in Ansible 2.12. Please update your playbooks/roles now."

View file

@ -75,8 +75,8 @@ options:
pull:
description:
- When building an image downloads any updates to the FROM image in Dockerfile.
- The default is currently C(yes). This will change to C(no) in Ansible 2.12.
type: bool
default: yes
rm:
description:
- Remove intermediate containers after build.
@ -200,8 +200,8 @@ options:
description:
- When building an image downloads any updates to the FROM image in Dockerfile.
- Please use I(build.pull) instead. This option will be removed in Ansible 2.12.
- The default is currently C(yes). This will change to C(no) in Ansible 2.12.
type: bool
default: yes
version_added: "2.1"
push:
description:
@ -773,7 +773,7 @@ def main():
network=dict(type='str'),
nocache=dict(type='bool', default=False),
path=dict(type='path', required=True),
pull=dict(type='bool', default=True),
pull=dict(type='bool'),
rm=dict(type='bool', default=True),
args=dict(type='dict'),
)),
@ -794,7 +794,7 @@ def main():
name=dict(type='str', required=True),
nocache=dict(type='bool', default=False, removedin_version='2.12'),
path=dict(type='path', aliases=['build_path'], removedin_version='2.12'),
pull=dict(type='bool', default=True, removedin_version='2.12'),
pull=dict(type='bool', removedin_version='2.12'),
push=dict(type='bool', default=False),
repository=dict(type='str'),
rm=dict(type='bool', default=True, removedin_version='2.12'),
@ -851,7 +851,7 @@ def main():
)
for option, build_option in build_options.items():
default_value = None
if option in ('pull', 'rm'):
if option in ('rm', ):
default_value = True
elif option in ('nocache', ):
default_value = False
@ -863,9 +863,13 @@ def main():
client.module.params['build'][build_option] = client.module.params[option]
client.module.warn('Please specify build.%s instead of %s. The %s option '
'has been renamed and will be removed in Ansible 2.12.' % (build_option, option, option))
if client.module.params['source'] == 'build' and \
(not client.module.params['build'] or not client.module.params['build'].get('path')):
client.module.fail('If "source" is set to "build", the "build.path" option must be specified.')
if client.module.params['source'] == 'build':
if (not client.module.params['build'] or not client.module.params['build'].get('path')):
client.module.fail('If "source" is set to "build", the "build.path" option must be specified.')
if client.module.params['build']['pull'] is None:
client.module.warn("The default for build.pull is currently 'yes', but will be changed to 'no' in Ansible 2.12. "
"Please set build.pull explicitly to the value you need.")
client.module.params['build']['pull'] = True # TODO: change to False in Ansible 2.12
if client.module.params['state'] == 'present' and client.module.params['source'] is None:
# Autodetection. To be removed in Ansible 2.12.

View file

@ -21,6 +21,7 @@
TEST1: val1
TEST2: val2
TEST3: "True"
pull: no
source: build
register: buildargs_1
@ -33,6 +34,7 @@
TEST1: val1
TEST2: val2
TEST3: "True"
pull: no
source: build
register: buildargs_2
@ -65,6 +67,7 @@
path: "{{ role_path }}/files"
container_limits:
memory: 4000
pull: no
source: build
ignore_errors: yes
register: container_limits_1
@ -77,6 +80,7 @@
container_limits:
memory: 5000000
memswap: 7000000
pull: no
source: build
register: container_limits_2
@ -107,6 +111,7 @@
build:
path: "{{ role_path }}/files"
dockerfile: "MyDockerfile"
pull: no
source: build
register: dockerfile_1
@ -136,6 +141,7 @@
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
pull: no
repository: "{{ registry_address }}/test/{{ iname }}"
source: build
register: repository_1
@ -145,6 +151,7 @@
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
pull: no
repository: "{{ registry_address }}/test/{{ iname }}"
source: build
register: repository_2
@ -178,6 +185,7 @@
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
pull: no
source: build
- name: force (changed)
@ -186,6 +194,7 @@
build:
path: "{{ role_path }}/files"
dockerfile: "MyDockerfile"
pull: no
source: build
force_source: yes
register: force_1
@ -196,6 +205,7 @@
build:
path: "{{ role_path }}/files"
dockerfile: "MyDockerfile"
pull: no
source: build
force_source: yes
register: force_2
@ -257,6 +267,7 @@
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
pull: no
source: build
register: path_1
@ -264,7 +275,8 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ role_path }}/files"
pull: no
source: build
register: path_2