示例#1
0
 def _install_roles_from_file(plugin_path):
     # Ansible Galaxy - install roles from file
     for req_file in ['requirements.yml', 'requirements.yaml']:
         galaxy_reqs_file = os.path.join(plugin_path, req_file)
         if not os.path.isfile(galaxy_reqs_file):
             continue
         LOG.debug("Installing Galaxy "
                   "requirements... ({})".format(galaxy_reqs_file))
         from ansible.cli.galaxy import GalaxyCLI
         from ansible.errors import AnsibleError
         glxy_cli = GalaxyCLI(['install'])
         glxy_cli.parse()
         glxy_cli.options.role_file = galaxy_reqs_file
         try:
             glxy_cli.execute_install()
         except AnsibleError as e:
             raise IRFailedToAddPlugin(e.message)
     else:
         LOG.debug("Galaxy requirements files weren't found.")