コード例 #1
0
    def main(self):
        # load molecule defaults
        self._config.load_defaults_file()

        # merge in any molecule config files found (eg: ~/.configs/molecule/config.yml)
        self._config.merge_molecule_config_files()

        # init command doesn't need to load molecule.yml
        if self._args.get('<command>') == 'init':
            return  # exits program

        # merge in molecule.yml
        self._config.merge_molecule_file()

        # concatentate file names and paths within config so they're more convenient to use
        self._config.build_easy_paths()

        # get defaults for inventory/ansible.cfg from molecule if none are specified
        self._config.update_ansible_defaults()

        self._state = self._load_state_file()

        try:
            self._provisioner = provisioners.get_provisioner(self)
        except provisioners.InvalidProviderSpecified:
            print("\n{}Invalid provider '{}'\n".format(
                colorama.Fore.RED, self._args['--provider'],
                colorama.Fore.RESET))
            self._args['--provider'] = None
            self._args['--platform'] = None
            self._provisioner = provisioners.get_provisioner(self)
            self._print_valid_providers()
            sys.exit(1)
        except provisioners.InvalidPlatformSpecified:
            print("\n{}Invalid platform '{}'\n".format(
                colorama.Fore.RED, self._args['--platform'],
                colorama.Fore.RESET))
            self._args['--provider'] = None
            self._args['--platform'] = None
            self._provisioner = provisioners.get_provisioner(self)
            self._print_valid_platforms()
            sys.exit(1)

        if not os.path.exists(self._config.config['molecule']['molecule_dir']):
            os.makedirs(self._config.config['molecule']['molecule_dir'])

        # updates instances config with full machine names
        self._config.populate_instance_names(self._env['MOLECULE_PLATFORM'])
        if self._args.get('--debug'):
            utilities.debug(
                'RUNNING CONFIG',
                yaml.dump(self._config.config,
                          default_flow_style=False,
                          indent=2))

        self._write_state_file()
コード例 #2
0
ファイル: core.py プロジェクト: conorsch/molecule
    def main(self):
        # load molecule defaults
        self._config.load_defaults_file()

        # merge in any molecule config files found (eg: ~/.configs/molecule/config.yml)
        self._config.merge_molecule_config_files()

        # init command doesn't need to load molecule.yml
        if self._args.get('<command>') == 'init':
            return  # exits program

        # merge in molecule.yml
        self._config.merge_molecule_file()

        # concatentate file names and paths within config so they're more convenient to use
        self._config.build_easy_paths()

        # get defaults for inventory/ansible.cfg from molecule if none are specified
        self._config.update_ansible_defaults()

        self._state = self._load_state_file()

        try:
            self._provisioner = provisioners.get_provisioner(self)
        except provisioners.InvalidProviderSpecified:
            print("\n{}Invalid provider '{}'\n".format(
                colorama.Fore.RED, self._args['--provider'],
                colorama.Fore.RESET))
            self._args['--provider'] = None
            self._args['--platform'] = None
            self._provisioner = provisioners.get_provisioner(self)
            self._print_valid_providers()
            sys.exit(1)
        except provisioners.InvalidPlatformSpecified:
            print("\n{}Invalid platform '{}'\n".format(
                colorama.Fore.RED, self._args['--platform'],
                colorama.Fore.RESET))
            self._args['--provider'] = None
            self._args['--platform'] = None
            self._provisioner = provisioners.get_provisioner(self)
            self._print_valid_platforms()
            sys.exit(1)

        if not os.path.exists(self._config.config['molecule']['molecule_dir']):
            os.makedirs(self._config.config['molecule']['molecule_dir'])

        # updates instances config with full machine names
        self._config.populate_instance_names(self._env['MOLECULE_PLATFORM'])
        if self._args.get('--debug'):
            utilities.debug('RUNNING CONFIG',
                            yaml.dump(self._config.config,
                                      default_flow_style=False,
                                      indent=2))

        self._write_state_file()
コード例 #3
0
    def test_inventory_generation(self):
        self._mock_molecule._provisioner = provisioners.get_provisioner(self._mock_molecule)
        self._mock_molecule._provisioner.destroy()
        self._mock_molecule._provisioner.up()

        self._mock_molecule._create_inventory_file()

        self.book = self._mock_molecule._provisioner.ansible_connection_params
        self.book['playbook'] = 'tests/playbook.yml'
        self.book['inventory'] = 'tests/ansible_inventory'

        self.ansible = AnsiblePlaybook(self.book)

        self.assertEqual((None, ''), self.ansible.execute())
コード例 #4
0
    def test_inventory_generation(self):
        self._mock_molecule._provisioner = provisioners.get_provisioner(
            self._mock_molecule)
        self._mock_molecule._provisioner.destroy()
        self._mock_molecule._provisioner.up()

        self._mock_molecule._create_inventory_file()

        self.book = self._mock_molecule._provisioner.ansible_connection_params
        self.book['playbook'] = 'tests/playbook.yml'
        self.book['inventory'] = 'tests/ansible_inventory'

        self.ansible = AnsiblePlaybook(self.book)

        self.assertEqual((None, ''), self.ansible.execute())
コード例 #5
0
 def test_get_provisioner(self):
     self.assertEqual(provisioners.get_provisioner(self._mock_molecule).name, 'docker')
コード例 #6
0
 def test_get_provisioner(self):
     self.assertEqual(
         provisioners.get_provisioner(self._mock_molecule).name, 'docker')