2

I seek a method of application autosetup with security domain and module named Database.

Please someone advise me, how to add a section in standalone.xml or domain.xml at the deployment (maven) or setup (runtime) phase for purpose of initial setup simplifying?

1 Answers1

5

You can use a WildFly Maven Plugin (wildfly-maven-plugin). The wildfly-maven-plugin is used to deploy, redeploy, undeploy or run your application. You can also deploy or undeploy artifacts, such as JDBC drivers, and add or remove resources. There is also the ability to execute CLI commands.

Eg. (execute commands from a CLI script)

<project>
    ...
    <build>
        ...
        <plugins>
            ...
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>1.0.2.Final</version>
                <configuration>
                    <execute-commands>
                        <scripts>
                            <script>config.cli</script>
                        </scripts>
                    </execute-commands>
                </configuration>
            </plugin>
            ...
        </plugins>
        ...
    </build>
...
</project>

config.cli add a security domain:

batch
# Configure the security domain
/subsystem=security/security-domain=my-security/:add(cache-type=default)
/subsystem=security/security-domain=my-security/authentication=classic:add(login-modules=[{"code"=>"Database", "flag"=>"required", "module-options"=>[("dsJndiName"=>"java:jboss/datasources/myDS"),("principalsQuery"=>"SELECT PASSWORD FROM USERS WHERE USERNAME = ?"), ("rolesQuery"=>"SELECT R.NAME, 'Roles' FROM USERS_ROLES UR INNER JOIN ROLES R ON R.ID = UR.ROLE_ID INNER JOIN USERS U ON U.ID = UR.USER_ID WHERE U.USERNAME = ?")]}])
# Run the batch commands
run-batch
# Reload the server configuration
:reload

I hope this help.

Federico Sierra
  • 5,118
  • 2
  • 23
  • 36
  • But what about binary (module) files? How will all the slaves get these? Do you use an external script, or, can the Master host-controller somehow push these out to the slaves? – Gregor Jan 27 '15 at 18:00
  • @gregor For a deployment (eg jar, war, etc) you can use a command `deploy test.war --all-server-groups` or `deploy test.war --server-groups=test-server-group` for specific server group. In case other modules like jdbc driver the recommended way to install a JDBC driver into WildFly 8 is to deploy it as a regular JAR deployment. The reason for this is that when you run WildFly 8 in domain mode, deployments are automatically propagated to all servers to which the deployment applies. For new modules like third-party libs you need create a new module in each server. – Federico Sierra Jan 27 '15 at 19:33