|
124 | 124 | with_dependencies:
|
125 | 125 | description:
|
126 | 126 | - Defines whether to install plugin dependencies.
|
127 |
| - - In earlier versions, this option had no effect when a specific C(version) was set. |
128 |
| - - Since community.general 11.1.0, dependencies are also installed for versioned plugins. |
| 127 | + - In earlier versions, this option had no effect when a specific O(version) was set. |
| 128 | + Since community.general 11.1.0, dependencies are also installed for versioned plugins. |
129 | 129 | type: bool
|
130 | 130 | default: true
|
131 | 131 |
|
@@ -519,7 +519,10 @@ def _install_dependencies(self):
|
519 | 519 | dep_params = self.params.copy()
|
520 | 520 | dep_params['name'] = dep_name
|
521 | 521 | dep_params['version'] = dep_version
|
522 |
| - dep_module = self.module |
| 522 | + dep_module = AnsibleModule( |
| 523 | + argument_spec=self.module.argument_spec, |
| 524 | + supports_check_mode=self.module.check_mode |
| 525 | + ) |
523 | 526 | dep_module.params = dep_params
|
524 | 527 | dep_plugin = JenkinsPlugin(dep_module)
|
525 | 528 | if not dep_plugin.install():
|
@@ -687,27 +690,27 @@ def _get_latest_compatible_plugin_version(self, plugin_name=None):
|
687 | 690 | cache_path = "{}/ansible_jenkins_plugin_cache.json".format(self.params['jenkins_home'])
|
688 | 691 |
|
689 | 692 | try: # Check if file is saved localy
|
690 |
| - with open(cache_path, "r") as f: |
| 693 | + if os.path.exists(cache_path): |
691 | 694 | file_mtime = os.path.getmtime(cache_path)
|
692 |
| - now = time.time() |
693 |
| - if now - file_mtime < 86400: |
694 |
| - plugin_data = json.load(f) |
695 |
| - else: |
696 |
| - raise FileNotFoundError("Cache file is outdated.") |
697 |
| - except Exception: |
698 |
| - response, info = fetch_url(self.module, "https://updates.jenkins.io/current/plugin-versions.json") # Get list of plugins and their dependencies |
699 |
| - |
700 |
| - if info['status'] != 200: |
701 |
| - self.module.fail_json(msg="Failed to fetch plugin-versions.json", details=info) |
| 695 | + else: |
| 696 | + file_mtime = 0 |
702 | 697 |
|
703 |
| - try: |
| 698 | + now = time.time() |
| 699 | + if now - file_mtime >= 86400: |
| 700 | + response, info = fetch_url(self.module, "https://updates.jenkins.io/current/plugin-versions.json") |
| 701 | + if info['status'] != 200: |
| 702 | + self.module.fail_json(msg="Failed to fetch plugin-versions.json", details=info) |
704 | 703 | plugin_data = json.loads(to_native(response.read()), object_pairs_hook=OrderedDict)
|
705 | 704 |
|
706 | 705 | # Save it to file for next time
|
707 | 706 | with open(cache_path, "w") as f:
|
708 | 707 | json.dump(plugin_data, f)
|
709 |
| - except Exception as e: |
710 |
| - self.module.fail_json(msg="Failed to parse plugin-versions.json", details=to_native(e)) |
| 708 | + |
| 709 | + with open(cache_path, "r") as f: |
| 710 | + plugin_data = json.load(f) |
| 711 | + |
| 712 | + except Exception as e: |
| 713 | + self.module.fail_json(msg="Failed to parse plugin-versions.json", details=to_native(e)) |
711 | 714 |
|
712 | 715 | plugin_versions = plugin_data.get("plugins", {}).get(name)
|
713 | 716 | if not plugin_versions:
|
|
0 commit comments