Skip to content

Commit

Permalink
Merge pull request #13 from l3ender/doc-updates
Browse files Browse the repository at this point in the history
Doc updates
  • Loading branch information
l3ender authored Nov 20, 2022
2 parents 29a85dd + e84e2c8 commit b89bc7d
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 89 deletions.
10 changes: 10 additions & 0 deletions Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# declaration of NEXUS_VERSION must appear before first FROM command
# see: https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
ARG NEXUS_VERSION=latest

FROM sonatype/nexus3:$NEXUS_VERSION

ARG DEPLOY_DIR=/opt/sonatype/nexus/deploy/
USER root
COPY nexus-repository-ansiblegalaxy/target/nexus-repository-ansiblegalaxy-*-bundle.kar ${DEPLOY_DIR}
USER nexus
104 changes: 22 additions & 82 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@
<!-- generated with nexus-format-archetype version 1.0.48 on Dec 27, 2020 -->
# Nexus Repository Ansible Galaxy Format


# Table Of Contents
## Table Of Contents

* [Developing](#developing)
* [Requirements](#requirements)
* [Download](#download)
* [Building](#building)
* [Using Ansible Galaxy with Nexus Repository Manager 3](#using-ansiblegalaxy-with-nexus-repository-manager-3)
* [Compatibility with Nexus Repository Manager 3 Versions](#compatibility-with-nexus-repository-manager-3-versions)
* [Features Implemented In This Plugin](#features-implemented-in-this-plugin)
Expand All @@ -37,56 +33,11 @@

## Developing

### Requirements

* [Apache Maven 3.3.3+](https://maven.apache.org/install.html)
* [Java 8](https://adoptopenjdk.net)
* Network access to https://repository.sonatype.org/content/groups/sonatype-public-grid

Also, there is a good amount of information available at [Bundle Development](https://help.sonatype.com/display/NXRM3/Bundle+Development).

You may also find it helpful to configure your IDE to use the [Sonatype Code style](https://github.com/sonatype/codestyle).

### Download

Pre-compiled plugin files can be found on the [releases page](https://github.com/l3ender/nexus-repository-ansiblegalaxy/releases).

### Building

To build the project and generate the bundle use Maven:
```bash
mvn clean package -PbuildKar
```

If everything checks out, the bundle for ansiblegalaxy should be available in the `target` folder.

#### Build with Docker

```bash
docker build -t nexus-repository-ansiblegalaxy .
```

#### Run as a Docker container

```bash
docker run -d -p 8081:8081 --name nexus-repository-ansiblegalaxy nexus-repository-ansiblegalaxy
```

For further information like how to persist volumes check out [the GitHub repo for our official image](https://github.com/sonatype/docker-nexus3).

After allowing some time to spin up, the application will be available from your browser at http://localhost:8081.

To read the generated admin password for your first login to the web UI, you can use the command below against the running docker container:

```bash
docker exec -it nexus-repository-ansiblegalaxy cat /nexus-data/admin.password && echo
```

For simplicity, you should check `Enable anonymous access` in the prompts following your first login.
[View development documentation to get started](docs/developing.md)

## Using Ansible Galaxy With Nexus Repository Manager 3

[We have detailed instructions on how to get started here!](docs/ansiblegalaxy_user_documentation.md)
[See instructions on how to get started!](docs/ansiblegalaxy_user_documentation.md)

## Compatibility with Nexus Repository Manager 3 Versions

Expand All @@ -105,7 +56,7 @@ plugin and send us a PR after testing it out!

All released versions can be found on [the releases page](https://github.com/l3ender/nexus-repository-ansiblegalaxy/releases).

## Features Implemented In This Plugin
## Features Implemented In This Plugin

| Feature | Implemented |
|---------|----------------------|
Expand All @@ -128,39 +79,37 @@ Be sure to [configure the `ansible-galaxy` client](docs/ansiblegalaxy_user_docum

## Installing the plugin

There are a range of options for installing the ansiblegalaxy plugin. You'll need to build it first, and
then install the plugin with the options shown below:
There are a range of options for installing the ansiblegalaxy plugin. You'll need to build it first, and then install the plugin with the options shown below.

### Easiest Install

Thanks to some upstream work in Nexus Repository, it's become a LOT easier to install a plugin. To install the `ansiblegalaxy` plugin, follow these steps:
To install the `ansiblegalaxy` plugin, follow these steps:

* Build the plugin with `mvn clean package -PbuildKar`
* Copy the `nexus-repository-ansiblegalaxy-*-bundle.kar` file from your `target` folder to the `deploy` folder for your Nexus Repository installation.
* Download the plugin from [the releases page](https://github.com/l3ender/nexus-repository-ansiblegalaxy/releases) or build from source as described on the [development documentation](docs/developing.md).
* Copy the `nexus-repository-ansiblegalaxy-*-bundle.kar` file from the downloaded location (or from `target` folder, if building from source) to the `deploy` folder for your Nexus Repository installation.

Once you've done this, go ahead and either restart Nexus Repo, or go ahead and start it if it wasn't running to begin with.

You should see `ansiblegalaxy (proxy)` in the available Repository Recipes to use, if all has gone according to plan :)
You should now see `ansiblegalaxy (proxy)` in the available Repository Recipes.

### Temporary Install

Installations done via the Karaf console will be wiped out with every restart of Nexus Repository. This is a
good installation path if you are just testing or doing development on the plugin.
Installations can be done via the Karaf console and will be wiped out with every restart of Nexus Repository. This is a good installation path if you are just testing or doing development on the plugin.

* Enable Nexus Repo console: edit `<nexus_dir>/bin/nexus.vmoptions` and change `karaf.startLocalConsole` to `true`.

More details here: [Bundle Development](https://help.sonatype.com/display/NXRM3/Bundle+Development+Overview)

* Run Nexus Repo console:
```
```bash
# sudo su - nexus
$ cd <nexus_dir>/bin
$ ./nexus run
> bundle:install file:///tmp/nexus-repository-ansiblegalaxy-*.jar
> bundle:list
```
(look for org.sonatype.nexus.plugins:nexus-repository-ansiblegalaxy ID, should be the last one)
```
```bash
> bundle:start <org.sonatype.nexus.plugins:nexus-repository-ansiblegalaxy ID>
```

Expand All @@ -170,52 +119,43 @@ For more permanent installs of the nexus-repository-ansiblegalaxy plugin, follow

* Copy the bundle (nexus-repository-ansiblegalaxy-*.jar) into <nexus_dir>/deploy

This will cause the plugin to be loaded with each restart of Nexus Repository. As well, this folder is monitored
by Nexus Repository and the plugin should load within 60 seconds of being copied there if Nexus Repository
is running. You will still need to start the bundle using the karaf commands mentioned in the temporary install.
This will cause the plugin to be loaded with each restart of Nexus Repository. As well, this folder is monitored by Nexus Repository and the plugin should load within 60 seconds of being copied there if Nexus Repository is running. You will still need to start the bundle using the karaf commands mentioned in the temporary install.

### (most) Permanent Install

If you are trying to use the ansiblegalaxy plugin permanently, it likely makes more sense to do the following:
If you are trying to use the ansiblegalaxy plugin permanently, it makes more sense to do the following:

* Copy the bundle into `<nexus_dir>/system/org/sonatype/nexus/plugins/nexus-repository-ansiblegalaxy/0.2.1/nexus-repository-ansiblegalaxy-0.2.1.jar`
* Make the following additions marked with + to `<nexus_dir>/system/org/sonatype/nexus/assemblies/nexus-core-feature/3.x.y/nexus-core-feature-3.x.y-features.xml`
* Make the following additions marked with + to `<nexus_dir>/system/org/sonatype/nexus/assemblies/nexus-core-feature/3.x.y/nexus-core-feature-3.x.y-features.xml`:

```
<feature prerequisite="false" dependency="false">wrap</feature>
+ <feature prerequisite="false" dependency="false">nexus-repository-ansiblegalaxy</feature>
```
to the `<feature name="nexus-core-feature" description="org.sonatype.nexus.assemblies:nexus-core-feature" version="3.x.y.xy">` section below the last (above is an example, the exact last one may vary).

And
And add the following as the last feature:
```
+ <feature name="nexus-repository-ansiblegalaxy" description="org.sonatype.nexus.plugins:nexus-repository-ansiblegalaxy" version="0.2.1">
+ <details>org.sonatype.nexus.plugins:nexus-repository-ansiblegalaxy</details>
+ <bundle>mvn:org.sonatype.nexus.plugins/nexus-repository-ansiblegalaxy/0.2.1</bundle>
+ </feature>
</features>
```
as the last feature.

This will cause the plugin to be loaded and started with each startup of Nexus Repository.

## The Fine Print

It is worth noting that this is **NOT SUPPORTED** by Sonatype, and is a contribution of ours
to the open source community (read: you!)
It is worth noting that this is **NOT SUPPORTED** by Sonatype, and is a contribution of ours to the open source community (read: you!)

Don't worry, using this community item does not "void your warranty". In a worst case scenario, you may be asked
by the Sonatype Support team to remove the community item in order to determine the root cause of any issues.
Don't worry, using this community item does not "void your warranty". In a worst case scenario, you may be asked by the Sonatype Support team to remove the community item in order to determine the root cause of any issues.

Remember:

* Use this contribution at the risk tolerance that you have
* Do NOT file Sonatype support tickets related to Ansible Galaxy support in regard to this plugin
* DO file issues here on GitHub, so that the community can pitch in

Phew, that was easier than I thought. Last but not least of all:

Have fun creating and using this plugin and the Nexus platform, we are glad to have you here!
* Use this contribution at the risk tolerance that you have.
* Do NOT file Sonatype support tickets related to Ansible Galaxy support in regard to this plugin.
* DO file issues here on GitHub, so that the community can pitch in.

## Getting help

Expand All @@ -229,7 +169,7 @@ Looking to contribute to our code but need some help? There's a few ways to get

There a still some rough edges around writing integration tests, which are noted below. Please report any problems you find.

The project has a format module, and an “IT” module. This allows the format module to be bundled up and used by the IT framework classes in the “it” module.
The project has a "format" module, and an "IT" module. This allows the "format" module to be bundled up and used by the IT framework classes in the "it" module.

In this project, the sub module [nexus-repository-ansiblegalaxy](nexus-repository-ansiblegalaxy) is the "format" module, while the sub module[nexus-repository-ansiblegalaxy-it](nexus-repository-ansiblegalaxy-it) is the "it" module.

Expand Down
14 changes: 7 additions & 7 deletions docs/ansiblegalaxy_user_documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
-->

### Overview
## Ansible Galaxy Configuration

[Ansible Galaxy](https://galaxy.ansible.com/) provides a way to install community collections and roles for Ansible.

Expand All @@ -23,11 +23,11 @@ You can create a proxy repository in Nexus Repository Manager (NXRM) that will c
[https://galaxy.ansible.com/](https://galaxy.ansible.com/). Then, you can make the `ansible-galaxy` client use your Nexus Repository Proxy
instead of the remote repository.

### Installation
## Installation

See [installing the plugin](../README.md#installing-the-plugin).
Ensure the plugin is installed in your Nexus environment (see [installing the plugin](../README.md#installing-the-plugin)).

### Repository configuration
## Repository configuration

To proxy an Ansible Galaxy repository, you simply create a new 'ansiblegalaxy (proxy)' as documented in
[Repository Management](https://help.sonatype.com/repomanager3/configuration/repository-management) in
Expand All @@ -37,7 +37,7 @@ detail. Minimal configuration steps are:
- Define URL for 'Remote storage' - e.g. [https://galaxy.ansible.com/](https://galaxy.ansible.com/)
- Select a `Blob store` for `Storage`

### Configuring the `ansible-galaxy` client
## Configuring the `ansible-galaxy` client

You must set the Galaxy API endpoint/server when using the client, either by:
* provide the `-s API_SERVER` or `--server API_SERVER` argument for each installation command.
Expand All @@ -47,7 +47,7 @@ See the following resources for additional detail:
* [Ansible documentation on configuring the `ansible-galaxy` client](https://docs.ansible.com/ansible/latest/galaxy/user_guide.html#configuring-the-ansible-galaxy-client).
* [Ansible configuration documentation](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#galaxy-server).

### Usage
## Usage

Using the `ansible-galaxy` client, you can now download packages from your NXRM Ansible Galaxy proxy:

Expand All @@ -57,7 +57,7 @@ ansible-galaxy collection install azure.azcollection -s http://localhost:8081/re

The command above tells ansible-galaxy to fetch (and install) packages from your NXRM Ansible Galaxy proxy. The NXRM Ansible Galaxy proxy will download any missing packages from the remote Ansible Galaxy repository, and cache the packages on the NXRM Ansible Galaxy proxy. The next time any client requests the same package from your NXRM Ansible Galaxy proxy, the already cached package will be returned to the client.

### Role installation support
## Role installation support

Due to [a bug](https://github.com/ansible/ansible/issues/73103) in Ansible prior to version 2.12, `ansible-galaxy` would download roles directly from Github.com, even if the `download_url` for the role specified a different location. This resulted in artifacts not being downloaded through Nexus when using this repository format.

Expand Down
86 changes: 86 additions & 0 deletions docs/developing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Developing

## Table Of Contents
* [Requirements](#requirements)
* [Download](#download)
* [Building](#building)
* [Installing](#installing)
* [Testing](#testing)

## Requirements

* [Apache Maven 3.3.3+](https://maven.apache.org/install.html)
* [Java 8](https://adoptopenjdk.net)
* Network access to https://repository.sonatype.org/content/groups/sonatype-public-grid

Also, there is a good amount of information available at [Bundle Development](https://help.sonatype.com/display/NXRM3/Bundle+Development).

You may also find it helpful to configure your IDE to use the [Sonatype Code style](https://github.com/sonatype/codestyle).

## Download

Pre-compiled plugin files can be found on the [releases page](https://github.com/l3ender/nexus-repository-ansiblegalaxy/releases).

## Building

To build the project and generate the bundle use Maven:
```bash
mvn clean package -PbuildKar
```

If everything checks out, the bundle for ansiblegalaxy should be available in the `target` folder.

### Build Docker image

To build a Nexus Docker image with this plugin bundled, run the following:

```bash
docker build -t nexus-repository-ansiblegalaxy .
```

The above will require the Docker build process to download Maven dependencies for each build. To simplify the build process during development, use the following instead:

```bash
mvn clean package -PbuildKar
docker build -f Dockerfile-dev -t nexus-repository-ansiblegalaxy .
```

### Run as a Docker container

After building the Docker image, you can run as follows:

```bash
docker run -d -p 8081:8081 --name nexus-repository-ansiblegalaxy nexus-repository-ansiblegalaxy
```

For further information like how to persist volumes check out [the GitHub repo for our official image](https://github.com/sonatype/docker-nexus3).

After allowing some time to spin up, the application will be available from your browser at http://localhost:8081.

To read the generated admin password for your first login to the web UI, you can use the command below against the running docker container:

```bash
docker exec -it nexus-repository-ansiblegalaxy cat /nexus-data/admin.password && echo
```

For simplicity, you should check `Enable anonymous access` in the prompts following your first login.

## Installing

See [installing the plugin](../README.md#installing-the-plugin).

## Testing

Configure `ansible-galaxy` to use your local Nexus server, such as:

```bash
ansible-galaxy collection install azure.azcollection -s http://localhost:8081/repository/ansible/
```

See [Ansible Galaxy Configuration documentation](docs/ansiblegalaxy_user_documentation.md) for more detail.

It may be helpful to install Ansible into a virtual environment. Full detail on doing so is outside the scope of this documentation, but the following command may be useful, which creates a local virtual environment and install Ansible:

```bash
python3 -m venv venv && . venv/bin/activate && pip3 install --upgrade pip && pip3 install wheel && pip3 install ansible
```

0 comments on commit b89bc7d

Please sign in to comment.