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

View file

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