예제 #1
0
    def apply(self):
        inventory_path = get_inventory_path(
            self.cluster_model.specification.name)

        # copy resources
        self.copy_resources()

        # create inventory
        inventory_creator = AnsibleInventoryCreator(self.cluster_model,
                                                    self.config_docs)
        inventory_creator.create()
        time.sleep(10)

        # generate vars
        ansible_vars_generator = AnsibleVarsGenerator(
            inventory_creator=inventory_creator)
        ansible_vars_generator.generate()

        # pre-flight to prepare machines
        self.pre_flight(inventory_path)

        # run roles
        enabled_roles = inventory_creator.get_enabled_roles()
        for role in enabled_roles:
            self.ansible_command.run_playbook(inventory=inventory_path,
                                              playbook_path=self.playbook_path(
                                                  to_role_name(role)))

        #post-flight after we are done
        self.post_flight(inventory_path)
예제 #2
0
    def upgrade(self):
        inventory_path = get_inventory_path_for_build(self.build_dir)

        # copy resources
        self.copy_resources()

        # upgrade inventory
        inventory_upgrade = AnsibleInventoryUpgrade(self.build_dir,
                                                    self.backup_build_dir)
        inventory_upgrade.upgrade()

        # generate vars
        ansible_vars_generator = AnsibleVarsGenerator(
            inventory_upgrade=inventory_upgrade)
        ansible_vars_generator.generate()

        # pre-flight to prepare machines
        self.pre_flight(inventory_path)

        # run image_registry playbook
        self.ansible_command.run_playbook(
            inventory=inventory_path,
            playbook_path=self.playbook_path('image_registry'))

        # run upgrade playbook
        self.ansible_command.run_playbook(
            inventory=inventory_path,
            playbook_path=self.playbook_path('upgrade'))

        #post-flight after we are done
        self.post_flight(inventory_path)