diff --git a/changelogs/fragments/70887_galaxy_token.yml b/changelogs/fragments/70887_galaxy_token.yml new file mode 100644 index 00000000000..2f8d49a33e0 --- /dev/null +++ b/changelogs/fragments/70887_galaxy_token.yml @@ -0,0 +1,2 @@ +minor_changes: +- galaxy - handle token as dict while loading from yaml file (https://github.com/ansible/ansible/issues/70887). diff --git a/lib/ansible/galaxy/token.py b/lib/ansible/galaxy/token.py index 7231c8f9a45..52bff211aeb 100644 --- a/lib/ansible/galaxy/token.py +++ b/lib/ansible/galaxy/token.py @@ -120,7 +120,7 @@ class GalaxyToken(object): def _read(self): action = 'Opened' if not os.path.isfile(self.b_file): - # token file not found, create and chomd u+rw + # token file not found, create and chmod u+rw open(self.b_file, 'w').close() os.chmod(self.b_file, S_IRUSR | S_IWUSR) # owner has +rw action = 'Created' @@ -130,6 +130,10 @@ class GalaxyToken(object): display.vvv('%s %s' % (action, to_text(self.b_file))) + if config and not isinstance(config, dict): + display.vvv('Galaxy token file %s malformed, unable to read it' % to_text(self.b_file)) + return {} + return config or {} def set(self, token):