Skip to content

Commit

Permalink
Merge pull request #5 from hagzag/master
Browse files Browse the repository at this point in the history
Adding Docker,Pypi, Raw, NPM, Bower repository options [ false by default ], move templates/groovy -> files/groovy
  • Loading branch information
samherve committed Jan 30, 2017
2 parents f2fcb66 + 44b4086 commit 1d9154f
Show file tree
Hide file tree
Showing 55 changed files with 955 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/
*.iml
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ All configuration can be updated by re-running the role, except for the [blobsto

## Requirements

- This has only been tested on CentOS 7
- This has only been tested on CentOS 7 + Ubuntu 16.04 (Xenial)
- Oracle Java 8 (mandatory)
- Apache HTTPD (optional, used to setup a SSL reverse-proxy)

Expand Down Expand Up @@ -195,6 +195,17 @@ All three repository types are combined with the following default values :
write_policy: allow_once # allow_once or allow
```

Docker, Pypi, Raw, Rubygems, Bower, NPM repository types:
see `defaults/main/yml` for three options:

nexus_config_pypi: false
nexus_config_docker: false
nexus_config_raw: false
nexus_config_rubygems: false
nexus_config_bower: false
nexus_config_npm: false

These are all false unless you override them from playbook / group_var / cli, these all utlize the same mechanisem as maven.

## Dependencies

Expand Down
148 changes: 146 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ httpd_setup_enable: false
httpd_ssl_certificate_file: 'files/nexus.vm.crt'
httpd_ssl_certificate_key_file: 'files/nexus.vm.key'


ldap_connections: []
# example ldap config :
# - ldap_name: 'My Company LDAP' # used as a key to update the ldap config
Expand All @@ -40,6 +39,13 @@ ldap_connections: []
# ldap_group_member_attribute: 'memberUid'
# ldap_group_member_format: '${username}'

nexus_config_pypi: false
nexus_config_docker: false
nexus_config_raw: false
nexus_config_rubygems: false
nexus_config_bower: false
nexus_config_npm: false

# also see _nexus_privilege_defaults below
nexus_privileges:
- name: all-repos-read # used as key to update a privilege
Expand Down Expand Up @@ -84,6 +90,7 @@ nexus_repos_maven_proxy:
layout_policy: permissive
- name: jboss
remote_url: 'https://repository.jboss.org/nexus/content/groups/public-jboss/'

# example with a login/password :
# - name: secret-remote-repo
# remote_url: 'https://company.com/repo/secure/private/go/away'
Expand All @@ -101,6 +108,7 @@ nexus_repos_maven_group:
- central
- jboss


nexus_scheduled_tasks: []
# example task to compact blobstore :
# - name: compact-blobstore
Expand All @@ -120,4 +128,140 @@ _nexus_repos_maven_defaults:
strict_content_validation: true
version_policy: release # release, snapshot or mixed
layout_policy: strict # strict or permissive
write_policy: allow_once # allow_once or allow
write_policy: allow_once # allow_once or allow

# pypi support ...
_nexus_repos_pypi_defaults:
blob_store: default # Note : cannot be updated once the repo has been created
strict_content_validation: true
version_policy: release # release, snapshot or mixed
layout_policy: strict # strict or permissive
write_policy: allow_once # allow_once or allow

nexus_repos_pypi_hosted:
- name: pypi-internal
version_policy: release
write_policy: allow_once

nexus_repos_pypi_group:
- name: pypi-all
member_repos:
- pypi-internal
- pypi

nexus_repos_pypi_proxy:
- name: pypi
remote_url: 'https://pypi.python.org/'

# raw repo support

_nexus_repos_raw_defaults:
blob_store: default # Note : cannot be updated once the repo has been created
strict_content_validation: true
version_policy: release # release, snapshot or mixed
layout_policy: strict # strict or permissive
write_policy: allow_once # allow_once or allow

nexus_repos_raw_proxy:
- name: jenkins-mirror
remote_url: 'http://mirrors.jenkins-ci.org/'
- name: ubuntu-archive
remote_url: 'http://archive.ubuntu.com/ubuntu/dists/'

nexus_repos_raw_group:
- name: raw-all
member_repos:
- jenkins-mirror
- ubuntu-archive

# Docker support
_nexus_repos_docker_defaults:
blob_store: default # Note : cannot be updated once the repo has been created
strict_content_validation: true
version_policy: release # release, snapshot or mixed
layout_policy: strict # strict or permissive
write_policy: allow_once # allow_once or allow

nexus_repos_docker_hosted:
- name: docker-hosted
http_port: 9080
v1_enabled: True

nexus_repos_docker_proxy:
- name: docker-proxy
http_port: 9081
v1_enabled: True
index_type: "HUB"
proxy_url: "https://registry-1.docker.io"
use_nexus_certificates_to_access_index: false

nexus_repos_docker_group:
- name: docker-group
http_port: 9082
v1_enabled: True

# RubyGems support
_nexus_repos_rubygems_defaults:
blob_store: default # Note : cannot be updated once the repo has been created
strict_content_validation: true
write_policy: allow_once # allow_once or allow

nexus_repos_rubygems_hosted:
- name: rubygems-hosted
blob_store: default

nexus_repos_rubygems_group:
- name: rubygems
blob_store: default
member_repos:
- rubygems-hosted
- rubygems-proxy

nexus_repos_rubygems_proxy:
- name: rubygems-proxy
blob_store: default
remote_url: https://rubygems.org

# Bower support
_nexus_repos_bower_defaults:
blob_store: default # Note : cannot be updated once the repo has been created
strict_content_validation: true
write_policy: allow_once # allow_once or allow

nexus_repos_bower_hosted:
- name: bower-internal
blob_store: default

nexus_repos_bower_group:
- name: bower-all
blob_store: default
member_repos:
- bower-internal
- bower-proxy

nexus_repos_bower_proxy:
- name: bower-proxy
blob_store: default
remote_url: http://bower.herokuapp.com

# npm support
_nexus_repos_npm_defaults:
blob_store: default # Note : cannot be updated once the repo has been created
strict_content_validation: true
write_policy: allow_once # allow_once or allow

nexus_repos_npm_hosted:
- name: npm-internal
blob_store: default

nexus_repos_npm_group:
- name: npm-all
blob_store: default
member_repos:
- npm-internal
- npm-proxy

nexus_repos_npm_proxy:
- name: npm-proxy
blob_store: default
remote_url: https://registry.npmjs.org
File renamed without changes.
30 changes: 30 additions & 0 deletions files/groovy/create_repo_bower_group.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import groovy.json.JsonSlurper
import org.sonatype.nexus.repository.config.Configuration

parsed_args = new JsonSlurper().parseText(args)

configuration = new Configuration(
repositoryName: parsed_args.name,
recipeName: 'bower-group',
online: true,
attributes: [
group : [
memberNames: parsed_args.member_repos
],
storage: [
blobStoreName: parsed_args.blob_store,
strictContentTypeValidation: Boolean.valueOf(parsed_args.strict_content_validation)
]
]
)

def existingRepository = repository.getRepositoryManager().get(parsed_args.name)

if (existingRepository != null) {
existingRepository.stop()
configuration.attributes['storage']['blobStoreName'] = existingRepository.configuration.attributes['storage']['blobStoreName']
existingRepository.update(configuration)
existingRepository.start()
} else {
repository.getRepositoryManager().create(configuration)
}
28 changes: 28 additions & 0 deletions files/groovy/create_repo_bower_hosted.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import groovy.json.JsonSlurper
import org.sonatype.nexus.repository.config.Configuration

parsed_args = new JsonSlurper().parseText(args)

configuration = new Configuration(
repositoryName: parsed_args.name,
recipeName: 'bower-hosted',
online: true,
attributes: [
storage: [
writePolicy: parsed_args.write_policy.toUpperCase(),
blobStoreName: parsed_args.blob_store,
strictContentTypeValidation: Boolean.valueOf(parsed_args.strict_content_validation)
]
]
)

def existingRepository = repository.getRepositoryManager().get(parsed_args.name)

if (existingRepository != null) {
existingRepository.stop()
configuration.attributes['storage']['blobStoreName'] = existingRepository.configuration.attributes['storage']['blobStoreName']
existingRepository.update(configuration)
existingRepository.start()
} else {
repository.getRepositoryManager().create(configuration)
}
49 changes: 49 additions & 0 deletions files/groovy/create_repo_bower_proxy.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import groovy.json.JsonSlurper
import org.sonatype.nexus.repository.config.Configuration

parsed_args = new JsonSlurper().parseText(args)

authentication = parsed_args.remote_username == null ? null : [
type: 'username',
username: parsed_args.remote_username,
password: parsed_args.remote_password
]

configuration = new Configuration(
repositoryName: parsed_args.name,
recipeName: 'bower-proxy',
online: true,
attributes: [
bower: [
rewritePackageUrls: true
],
proxy: [
remoteUrl: parsed_args.remote_url,
contentMaxAge: 1440.0,
metadataMaxAge: 1440.0
],
httpclient: [
blocked: false,
autoBlock: true
],
storage: [
blobStoreName: parsed_args.blob_store,
strictContentTypeValidation: Boolean.valueOf(parsed_args.strict_content_validation)
],
negativeCache: [
enabled: true,
timeToLive: 1440.0
]
]
)

def existingRepository = repository.getRepositoryManager().get(parsed_args.name)

if (existingRepository != null) {
existingRepository.stop()
configuration.attributes['storage']['blobStoreName'] = existingRepository.configuration.attributes['storage']['blobStoreName']
existingRepository.update(configuration)
existingRepository.start()
} else {
repository.getRepositoryManager().create(configuration)
}
38 changes: 38 additions & 0 deletions files/groovy/create_repo_docker_group.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import groovy.json.JsonSlurper
import org.sonatype.nexus.repository.config.Configuration

parsed_args = new JsonSlurper().parseText(args)

configuration = new Configuration(
repositoryName: parsed_args.name,
recipeName: 'docker-group',
online: true,
attributes: [
docker: [
httpPort: parsed_args.http_port,
v1Enabled : parsed_args.v1_enabled
],
group: [
memberNames: [
"private-registry",
"proxy-registry"
]
],
storage: [
writePolicy: parsed_args.write_policy.toUpperCase(),
blobStoreName: parsed_args.blob_store,
strictContentTypeValidation: Boolean.valueOf(parsed_args.strict_content_validation)
]
]
)

def existingRepository = repository.getRepositoryManager().get(parsed_args.name)

if (existingRepository != null) {
existingRepository.stop()
configuration.attributes['storage']['blobStoreName'] = existingRepository.configuration.attributes['storage']['blobStoreName']
existingRepository.update(configuration)
existingRepository.start()
} else {
repository.getRepositoryManager().create(configuration)
}
32 changes: 32 additions & 0 deletions files/groovy/create_repo_docker_hosted.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import groovy.json.JsonSlurper
import org.sonatype.nexus.repository.config.Configuration

parsed_args = new JsonSlurper().parseText(args)

configuration = new Configuration(
repositoryName: parsed_args.name,
recipeName: 'docker-hosted',
online: true,
attributes: [
docker: [
httpPort: parsed_args.http_port,
v1Enabled : parsed_args.v1_enabled
],
storage: [
writePolicy: parsed_args.write_policy.toUpperCase(),
blobStoreName: parsed_args.blob_store,
strictContentTypeValidation: Boolean.valueOf(parsed_args.strict_content_validation)
]
]
)

def existingRepository = repository.getRepositoryManager().get(parsed_args.name)

if (existingRepository != null) {
existingRepository.stop()
configuration.attributes['storage']['blobStoreName'] = existingRepository.configuration.attributes['storage']['blobStoreName']
existingRepository.update(configuration)
existingRepository.start()
} else {
repository.getRepositoryManager().create(configuration)
}
Loading

0 comments on commit 1d9154f

Please sign in to comment.