예제 #1
0
    def compose_command(self, task):
        self.proc = process.Ansible(self.entry_point, task, self.MODULE)

        if self.ONE_LINE:
            self.proc.options["--one-line"] = process.NO_VALUE
        if self.BECOME:
            self.proc.options["--become"] = process.NO_VALUE

        extra = self.get_extra_vars(task)
        if extra:
            self.proc.options["--extra-vars"] = process.jsonify(extra)
예제 #2
0
    def compose_command(self, task):
        self.proc = process.AnsiblePlaybook(self.entry_point, task)
        self.proc.args.append(str(self.get_filename(self.playbook_filename)))
        self.proc.options["-vvv"] = process.NO_VALUE

        if self.BECOME:
            self.proc.options["--become"] = process.NO_VALUE

        extra = self.get_extra_vars(task)
        if extra:
            self.proc.options["--extra-vars"] = process.jsonify(extra)
예제 #3
0
    def compose_command(self, task):
        self.proc = process.AnsiblePlaybook(self.entry_point, task)
        self.proc.args.append(str(self.get_filename(self.playbook_filename)))
        self.proc.options["-vvv"] = process.NO_VALUE

        if self.BECOME:
            self.proc.options["--become"] = process.NO_VALUE

        extra = self.get_extra_vars(task)
        if extra:
            self.proc.options["--extra-vars"] = process.jsonify(extra)
예제 #4
0
    def compose_command(self, task):
        self.proc = process.Ansible(self.entry_point, task, self.MODULE)

        if self.ONE_LINE:
            self.proc.options["--one-line"] = process.NO_VALUE
        if self.BECOME:
            self.proc.options["--become"] = process.NO_VALUE

        extra = self.get_extra_vars(task)
        if extra:
            self.proc.options["--extra-vars"] = process.jsonify(extra)
예제 #5
0
def compose_commandline(path, playbook_config):
    destpath = path.joinpath("execute.sh")
    faketask = task.PlaybookPluginTask(
        playbook_config.playbook_id, playbook_config._id, None)

    plugin = plugins.get_public_playbook_plugins()[playbook_config.playbook_id]
    plugin = plugin()
    plugin.compose_command(faketask)
    proc = plugin.proc

    proc.env = {}
    proc.options["--inventory-file"] = "inventory.yaml"
    extras = json.loads(proc.options["--extra-vars"])
    extras["decapod_common_playbooks"] = "../common_playbooks"
    extras["fetch_directory"] = "fetch_directory"
    extras = patch_plugin_paths(extras, plugin)
    proc.options["--extra-vars"] = process.jsonify(extras)
    proc.command = "ansible-playbook"
    proc.args = [
        path.joinpath("plugin", plugin.playbook_filename)
        .relative_to(path).as_posix()
    ]

    shell_script = """\
    #!/bin/bash
    set +e
    cd "$(dirname "$0")"

    {0}

    cd - >/dev/null 2>&1
    """.format(proc.printable_commandline)
    shell_script = textwrap.dedent(shell_script)

    destpath.write_text(shell_script)
    destpath.chmod(0o755)
예제 #6
0
def compose_commandline(path, playbook_config):
    destpath = path.joinpath("execute.sh")
    faketask = task.PlaybookPluginTask(playbook_config.playbook_id,
                                       playbook_config._id, None)

    plugin = plugins.get_public_playbook_plugins()[playbook_config.playbook_id]
    plugin = plugin()
    plugin.compose_command(faketask)
    proc = plugin.proc

    proc.env = {}
    proc.options["--inventory-file"] = "inventory.yaml"
    extras = json.loads(proc.options["--extra-vars"])
    extras["decapod_common_playbooks"] = "../common_playbooks"
    extras["fetch_directory"] = "fetch_directory"
    extras = patch_plugin_paths(extras, plugin)
    proc.options["--extra-vars"] = process.jsonify(extras)
    proc.command = "ansible-playbook"
    proc.args = [
        path.joinpath("plugin",
                      plugin.playbook_filename).relative_to(path).as_posix()
    ]

    shell_script = """\
    #!/bin/bash
    set +e
    cd "$(dirname "$0")"

    {0}

    cd - >/dev/null 2>&1
    """.format(proc.printable_commandline)
    shell_script = textwrap.dedent(shell_script)

    destpath.write_text(shell_script)
    destpath.chmod(0o755)
예제 #7
0
def test_jsonify():
    assert process.jsonify({"a": 1}) == "{\"a\":1}"