コード例 #1
0
ファイル: ansible.py プロジェクト: jackheskett/kayobe
def install_galaxy_roles(parsed_args, force=False):
    """Install Ansible Galaxy role dependencies.

    Installs dependencies specified in kayobe, and if present, in kayobe
    configuration.

    :param parsed_args: Parsed command line arguments.
    :param force: Whether to force reinstallation of roles.
    """
    LOG.info("Installing galaxy role dependencies from kayobe")
    requirements = utils.get_data_files_path("requirements.yml")
    roles_destination = utils.get_data_files_path('ansible', 'roles')
    utils.galaxy_install(requirements, roles_destination, force=force)

    # Check for requirements in kayobe configuration.
    kc_reqs_path = os.path.join(parsed_args.config_path, "ansible",
                                "requirements.yml")
    if not utils.is_readable_file(kc_reqs_path)["result"]:
        LOG.info("Not installing galaxy role dependencies from kayobe config "
                 "- requirements.yml not present")
        return

    LOG.info("Installing galaxy role dependencies from kayobe config")
    # Ensure a roles directory exists in kayobe-config.
    kc_roles_path = os.path.join(parsed_args.config_path, "ansible", "roles")
    try:
        os.makedirs(kc_roles_path)
    except OSError as e:
        if e.errno != errno.EEXIST:
            raise exception.Error("Failed to create directory ansible/roles/ "
                                  "in kayobe configuration at %s: %s" %
                                  (parsed_args.config_path, str(e)))

    # Install roles from kayobe-config.
    utils.galaxy_install(kc_reqs_path, kc_roles_path, force=force)
コード例 #2
0
 def take_action(self, parsed_args):
     self.app.LOG.debug("Bootstrapping Kayobe control host")
     utils.galaxy_install("requirements.yml", "ansible/roles")
     playbooks = _build_playbook_list("bootstrap")
     self.run_kayobe_playbooks(parsed_args, playbooks)
     playbooks = _build_playbook_list("kolla-ansible")
     self.run_kayobe_playbooks(parsed_args, playbooks, tags="install")
コード例 #3
0
ファイル: commands.py プロジェクト: pforai/kayobe
 def take_action(self, parsed_args):
     self.app.LOG.debug("Bootstrapping Kayobe control host")
     utils.galaxy_install("requirements.yml", "ansible/roles")
     playbooks = _build_playbook_list("bootstrap")
     self.run_kayobe_playbooks(parsed_args, playbooks)
     playbooks = _build_playbook_list("kolla-ansible")
     self.run_kayobe_playbooks(parsed_args, playbooks, tags="install")
コード例 #4
0
ファイル: commands.py プロジェクト: autonomouse/kayobe
 def take_action(self, parsed_args):
     self.app.LOG.debug("Upgrading Kayobe control host")
     # Use force to upgrade roles.
     utils.galaxy_install("ansible/requirements.yml",
                          "ansible/roles",
                          force=True)
     playbooks = _build_playbook_list("bootstrap")
     self.run_kayobe_playbooks(parsed_args, playbooks)
     playbooks = _build_playbook_list("kolla-ansible")
     self.run_kayobe_playbooks(parsed_args, playbooks, tags="install")
コード例 #5
0
ファイル: test_utils.py プロジェクト: ssolkhon/kayobe
 def test_galaxy_install(self, mock_run):
     utils.galaxy_install("/path/to/role/file", "/path/to/roles")
     mock_run.assert_called_once_with([
         "ansible-galaxy", "install", "--roles-path", "/path/to/roles",
         "--role-file", "/path/to/role/file"
     ])
コード例 #6
0
ファイル: test_utils.py プロジェクト: pforai/kayobe
 def test_galaxy_install(self, mock_run):
     utils.galaxy_install("/path/to/role/file", "/path/to/roles")
     mock_run.assert_called_once_with(["ansible-galaxy", "install",
                                       "--roles-path", "/path/to/roles",
                                       "--role-file", "/path/to/role/file"])