Esempio n. 1
0
    def test__run_playbook_ansible_interpreter_override(self, execute_mock):
        self.config(group='ansible', playbooks_path='/path/to/playbooks')
        self.config(group='ansible', config_file_path='/path/to/config')
        self.config(group='ansible', verbosity=3)
        self.config(group='ansible',
                    default_python_interpreter='/usr/bin/python3')
        self.config(group='ansible', ansible_extra_args='--timeout=100')
        self.node.driver_info['ansible_python_interpreter'] = (
            '/usr/bin/python4')
        extra_vars = {'foo': 'bar'}

        ansible_deploy._run_playbook(self.node, 'deploy',
                                     extra_vars, '/path/to/key',
                                     tags=['spam'], notags=['ham'])

        execute_mock.assert_called_once_with(
            'env', 'ANSIBLE_CONFIG=/path/to/config',
            'ansible-playbook', '/path/to/playbooks/deploy', '-i',
            '/path/to/playbooks/inventory', '-e',
            mock.ANY, '--tags=spam', '--skip-tags=ham',
            '--private-key=/path/to/key', '-vvv', '--timeout=100')

        all_vars = execute_mock.call_args[0][7]
        self.assertEqual({"ansible_python_interpreter": "/usr/bin/python4",
                          "ironic": {"foo": "bar"}},
                         json.loads(all_vars))
Esempio n. 2
0
    def test__run_playbook_default_verbosity_nodebug(self, execute_mock):
        self.config(group='ansible', playbooks_path='/path/to/playbooks')
        self.config(group='ansible', config_file_path='/path/to/config')
        self.config(debug=False)
        extra_vars = {'foo': 'bar'}

        ansible_deploy._run_playbook(self.node, 'deploy', extra_vars,
                                     '/path/to/key')

        execute_mock.assert_called_once_with(
            'env', 'ANSIBLE_CONFIG=/path/to/config', 'ansible-playbook',
            '/path/to/playbooks/deploy', '-i', '/path/to/playbooks/inventory',
            '-e', '{"ironic": {"foo": "bar"}}', '--private-key=/path/to/key')
Esempio n. 3
0
    def test__run_playbook(self, execute_mock):
        self.config(group='ansible', playbooks_path='/path/to/playbooks')
        self.config(group='ansible', config_file_path='/path/to/config')
        self.config(group='ansible', verbosity=3)
        self.config(group='ansible', ansible_extra_args='--timeout=100')
        extra_vars = {'foo': 'bar'}

        ansible_deploy._run_playbook(self.node, 'deploy',
                                     extra_vars, '/path/to/key',
                                     tags=['spam'], notags=['ham'])

        execute_mock.assert_called_once_with(
            'env', 'ANSIBLE_CONFIG=/path/to/config',
            'ansible-playbook', '/path/to/playbooks/deploy', '-i',
            '/path/to/playbooks/inventory', '-e', '{"ironic": {"foo": "bar"}}',
            '--tags=spam', '--skip-tags=ham',
            '--private-key=/path/to/key', '-vvv', '--timeout=100')