Skip to content

Commit

Permalink
Refactor templates -> files
Browse files Browse the repository at this point in the history
  • Loading branch information
hagzag committed Jan 29, 2017
1 parent 4381424 commit 44b4086
Show file tree
Hide file tree
Showing 46 changed files with 485 additions and 18 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,15 @@ All three repository types are combined with the following default values :
write_policy: allow_once # allow_once or allow
```

Docker, Pypi & Raw repository types:
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.

Expand Down
82 changes: 70 additions & 12 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ ldap_connections: []
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:
Expand Down Expand Up @@ -92,7 +91,6 @@ nexus_repos_maven_proxy:
- 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 Down Expand Up @@ -132,10 +130,6 @@ _nexus_repos_maven_defaults:
layout_policy: strict # strict or permissive
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
Expand Down Expand Up @@ -189,21 +183,85 @@ _nexus_repos_docker_defaults:
write_policy: allow_once # allow_once or allow

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

nexus_repos_docker_proxy:
- name: proxy-registry
- 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: registry-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)
}
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions files/groovy/create_repo_npm_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: 'npm-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_npm_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: 'npm-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_npm_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: 'npm-proxy',
online: true,
attributes: [
proxy : [
remoteUrl: parsed_args.remote_url,
contentMaxAge: 1440.0,
metadataMaxAge: 1440.0
],
httpclient: [
blocked: false,
autoBlock: true,
connection: [
useTrustStore: false
]
],
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)
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ configuration = new Configuration(
recipeName: 'pypi-hosted',
online: true,
attributes: [
maven : [
versionPolicy: parsed_args.version_policy.toUpperCase(),
layoutPolicy : parsed_args.layout_policy.toUpperCase()
],
storage: [
writePolicy: parsed_args.write_policy.toUpperCase(),
blobStoreName: parsed_args.blob_store,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 44b4086

Please sign in to comment.