Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
fix bug in docker_plugins module
Browse files Browse the repository at this point in the history
  • Loading branch information
bodsch committed Nov 15, 2023
1 parent d366f01 commit 14fe4c8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
26 changes: 13 additions & 13 deletions library/docker_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ def run(self):
if self.state == "test":
"""
"""
plugin_config_file = os.path.join(self.docker_data_root, "plugins", plugin_id, "config.json")
if plugin_id:
plugin_config_file = os.path.join(self.docker_data_root, "plugins", plugin_id, "config.json")

if not os.path.exists(plugin_config_file):
self.module.log(msg=f"The plugin {self.plugin_alias} is not installed under the expected data-root path {self.docker_data_root}.")
if not os.path.exists(plugin_config_file):
self.module.log(msg=f"The plugin {self.plugin_alias} is not installed under the expected data-root path {self.docker_data_root}.")

return dict(
changed = False,
Expand Down Expand Up @@ -128,19 +129,18 @@ def check_plugin(self):
try:
p_list = self.docker_client.plugins.list()

self.module.log(msg=f" p_list : {p_list}")

for plugin in p_list:
installed_plugin_enabled = plugin.enabled

# if plugin.name == self.plugin_alias:
installed_plugin_name = plugin.name
installed_plugin_shortname = plugin.name.split(':')[0]
installed_plugin_version = plugin.name.split(':')[1]
installed_plugin_id = plugin.id
installed_plugin_short_id = plugin.short_id

break
if installed_plugin_shortname == self.plugin_alias:
installed_plugin_name = plugin.name
installed_plugin_shortname = plugin.name.split(':')[0]
installed_plugin_version = plugin.name.split(':')[1]
installed_plugin_id = plugin.id
installed_plugin_short_id = plugin.short_id

break

except docker.errors.APIError as e:
error = str(e)
Expand Down Expand Up @@ -407,7 +407,7 @@ def __read_docker_config(self, config_file="/etc/docker/daemon.json"):
def __write_plugin_information(self, data):
"""
"""
self.module.log(msg=f" write information to '{self.plugin_information_file}'")
self.module.log(msg=f"persist plugin information in '{self.plugin_information_file}'")

with open(self.plugin_information_file, 'w') as fp:
json_data = json.dumps(data, indent=2, sort_keys=False)
Expand Down
4 changes: 2 additions & 2 deletions molecule/dockerd-with-client-config/requirements.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

- name: snakeoil
src: bodsch.snakeoil
version: 1.3.1
src: https://github.com/bodsch/ansible-snakeoil
version: 1.5.0

...
2 changes: 1 addition & 1 deletion molecule/dockerd-with-plugin/requirements.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

- name: loki
src: bodsch.loki
src: https://github.com/bodsch/ansible-loki
version: 2.1.0

...
4 changes: 2 additions & 2 deletions molecule/dockerd-with-tls/requirements.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

- name: snakeoil
src: bodsch.snakeoil
version: 1.3.1
src: https://github.com/bodsch/ansible-snakeoil
version: 1.5.0

...

0 comments on commit 14fe4c8

Please sign in to comment.