Ejemplo n.º 1
0
def test_prepare_config_command():
    rc = AnsibleCfgConfig()
    rc.prepare_ansible_config_command('list', config_file='/tmp/ansible.cfg')
    expected_command = [
        get_executable_path('ansible-config'), 'list', '-c', '/tmp/ansible.cfg'
    ]
    assert rc.command == expected_command
    assert rc.runner_mode == 'subprocess'
Ejemplo n.º 2
0
def test_prepare_plugin_list_command():
    rc = DocConfig()
    rc.prepare_plugin_list_command(list_files=True,
                                   plugin_type='module',
                                   playbook_dir='/tmp/test',
                                   module_path='/test/module')
    expected_command = [
        get_executable_path('ansible-doc'), '-F', '-t', 'module',
        '--playbook-dir', '/tmp/test', '-M', '/test/module'
    ]
    assert rc.command == expected_command
    assert rc.runner_mode == 'subprocess'
    assert rc.execution_mode == BaseExecutionMode.ANSIBLE_COMMANDS
Ejemplo n.º 3
0
def test_prepare_inventory_command():
    rc = InventoryConfig()
    inventories = ['/tmp/inventory1', '/tmp/inventory2']
    rc.prepare_inventory_command('list',
                                 inventories,
                                 response_format='yaml',
                                 playbook_dir='/tmp',
                                 vault_ids='1234',
                                 vault_password_file='/tmp/password')
    expected_command = [get_executable_path('ansible-inventory'), '--list', '-i', '/tmp/inventory1', '-i', '/tmp/inventory2', '--yaml', '--playbook-dir'] + \
                       ['/tmp', '--vault-id', '1234', '--vault-password-file', '/tmp/password']
    assert rc.command == expected_command
    assert rc.runner_mode == 'subprocess'
Ejemplo n.º 4
0
    def __init__(self, runner_mode=None, **kwargs):
        # runner params
        self.runner_mode = runner_mode if runner_mode else 'subprocess'
        if self.runner_mode not in ['pexpect', 'subprocess']:
            raise ConfigurationError(
                "Invalid runner mode {0}, valid value is either 'pexpect' or 'subprocess'"
                .format(self.runner_mode))

        if kwargs.get("process_isolation"):
            self._ansible_doc_exec_path = "ansible-doc"
        else:
            self._ansible_doc_exec_path = get_executable_path("ansible-doc")

        self.execution_mode = BaseExecutionMode.ANSIBLE_COMMANDS
        super(DocConfig, self).__init__(**kwargs)
Ejemplo n.º 5
0
def test_prepare_plugin_docs_command():
    rc = DocConfig()
    plugin_names = ['copy', 'file']
    plugin_type = 'module'
    rc.prepare_plugin_docs_command(plugin_names,
                                   plugin_type=plugin_type,
                                   snippet=True,
                                   playbook_dir='/tmp/test')
    expected_command = [
        get_executable_path('ansible-doc'), '-s', '-t', 'module',
        '--playbook-dir', '/tmp/test', 'copy', 'file'
    ]
    assert rc.command == expected_command
    assert rc.runner_mode == 'subprocess'
    assert rc.execution_mode == BaseExecutionMode.ANSIBLE_COMMANDS