Commit 05d72e10b08237cbbe63e8bd12499df6c9bafdea

Authored by Sergio Oliveira
1 parent bd2a20e1

Fixed problem when trying to install modules with _ in the name

Showing 1 changed file with 8 additions and 4 deletions   Show diff stats
puppet/bootstrap.py
... ... @@ -17,6 +17,9 @@ except ImportError:
17 17 pkg_res = ['apt-get', 'install', 'python-pkg-resources', '-y']
18 18 subprocess.call(pkg_res)
19 19 from pkg_resources import parse_requirements
  20 +finally:
  21 + from pkg_resources import to_filename
  22 +
20 23  
21 24 PUPPET_TARGET_VERSION = "3.6.2"
22 25 PUPPET_DIR = os.path.join(os.path.dirname(__file__))
... ... @@ -70,11 +73,12 @@ def install_puppet_modules():
70 73  
71 74 for module in parse_requirements(modules_requirements):
72 75 current_cmd, compare, version, version_comparison = '', '', '', None
73   - if module.project_name in modules_installed:
  76 + module_name = to_filename(module.project_name).replace('_', '-', 1)
  77 + if module_name in modules_installed:
74 78 if module.specs:
75 79 compare, version = module.specs[0]
76 80  
77   - tmp_version = modules_installed[module.project_name]
  81 + tmp_version = modules_installed[module_name]
78 82 installed_version = StrictVersion(tmp_version)
79 83 required_version = StrictVersion(version)
80 84  
... ... @@ -95,10 +99,10 @@ def install_puppet_modules():
95 99 current_cmd = 'install'
96 100  
97 101 if version and compare and '>' not in compare:
98   - run(current_cmd, module.project_name, version)
  102 + run(current_cmd, module_name, version)
99 103 else:
100 104 if not version_comparison or version_comparison < 0:
101   - run(current_cmd, module.project_name)
  105 + run(current_cmd, module_name)
102 106  
103 107  
104 108 def iscentos(distro):
... ...