From cce68def8ba40a8364d8ef6f0060b0de1d58029a Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 20 Dec 2021 20:22:29 +0100 Subject: [PATCH] fix gitlab_project avatar_path open when undefined bug (#3926) (#3927) (#3928) * fix gitlab_project avatar_path open when undefined bug (#3926) * remove changelog fragment (cherry picked from commit 11fcf661bfabd1809f80a4fa289d377b23ad34cd) Co-authored-by: Josh --- plugins/modules/source_control/gitlab/gitlab_project.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/modules/source_control/gitlab/gitlab_project.py b/plugins/modules/source_control/gitlab/gitlab_project.py index b29c38c0e9..ca17861bbf 100644 --- a/plugins/modules/source_control/gitlab/gitlab_project.py +++ b/plugins/modules/source_control/gitlab/gitlab_project.py @@ -299,10 +299,11 @@ class GitLabProject(object): project = self.create_project(namespace, project_options) # add avatar to project - try: - project.avatar = open(options['avatar_path'], 'rb') - except IOError as e: - self._module.fail_json(msg='Cannot open {0}: {1}'.format(options['avatar_path'], e)) + if options['avatar_path']: + try: + project.avatar = open(options['avatar_path'], 'rb') + except IOError as e: + self._module.fail_json(msg='Cannot open {0}: {1}'.format(options['avatar_path'], e)) changed = True else: