All Downloads are FREE. Search and download functionalities are using the official Maven repository.

co.escapeideas.maven.ansible.Ansible Maven / Gradle / Ivy

package co.escapeideas.maven.ansible;

import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

import java.io.IOException;
import java.util.List;

/**
 * Goal that runs an Ansible command
 *
 * @author tmullender on 22/10/14.
 */
@Mojo( name = "ansible", defaultPhase = LifecyclePhase.PRE_INTEGRATION_TEST, requiresProject = false)
public class Ansible extends AbstractAnsibleMojo {

    /**
     * The executable to use for this execution, defaults to ansible
     */
    @Parameter( defaultValue = "ansible", required = true )
    private String executable;

    /**
     * Run asynchronously, failing after this number of seconds
     */
    @Parameter
    private Integer background;

    /**
     * Pattern for matching hosts to run the module against, defaults to localhost
     */
    @Parameter( defaultValue = "localhost", required = true )
    private String hosts;

    /**
     * Module arguments
     */
    @Parameter
    private String moduleArgs;

    /**
     * Module name to execute, defaults to ping
     */
    @Parameter( defaultValue = "ping", required = true )
    private String moduleName;

    /**
     * The poll interval if using background
     */
    @Parameter
    private Integer pollInterval;

    @Override
    protected String getArgument() throws IOException {
        return hosts;
    }

    @Override
    protected String getExecutable() {
        return executable;
    }

    @Override
    protected void addOptions(final List command) {
        super.addOptions(command);
        command.addAll(createOption("-B", background));
        command.addAll(createOption("-a", moduleArgs));
        command.addAll(createOption("-m", moduleName));
        command.addAll(createOption("-P", pollInterval));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy