AdaptiveConsulting / nexus-casc-plugin

Configuration as code plugin for Sonatype Nexus Repository Manager
MIT License
48 stars 21 forks source link

Set the admin credentials using this plugin #19

Closed carlosrbcunha closed 3 years ago

carlosrbcunha commented 3 years ago

During the initial config we always need to perform extra operations to get inside the container and get the initial password file. After that we use REST API to configure the nexus instance. Like many of the tools present in the DevOps landscape we should have a way to inject the admin password . Using this plugin that might me a way, for instance, reading it from an environment variable or even from the plugin configuration file.

bdellegrazie commented 3 years ago

H @carlosrbcunha this is already natively supported by Nexus.

The docker-compose example in this project shows how to inject the admin password via a Docker secret - an environment variable could also be used. You need to set: NEXUS_SECURITY_RANDOMPASSWORD=false in the container's environment and then you can replace it as we've done in the example file.

The definition of "johndoe" is an administrator:

    - username: johndoe
      firstName: John
      lastName: Doe
      password: "${file:/run/secrets/password_johndoe}"
      updateExistingPassword: true
      email: johndoe@example.org
      roles:
        - source: "default"
          role: nx-admin

Administrators have nx-admin as a role.