Installéieren an konfiguréieren Nexus Sonatype mat der Infrastruktur als Code Approche

Sonatype Nexus ass eng integréiert Plattform duerch déi Entwéckler kënnen Proxy, späicheren a verwalten Java (Maven) Ofhängegkeeten, Docker, Python, Ruby, NPM, Bower Biller, RPM Packagen, gitlfs, Apt, Go, Nuget, a verdeelen hir Software Sécherheet.

Firwat braucht Dir Sonatype Nexus?

  • Fir privat Artefakte ze späicheren;
  • Fir Cache Artefakte déi vum Internet erofgeluede ginn;

Artefakte ënnerstëtzt am Basis Sonatype Nexus Package:

  • Java, Maven (jar)
  • Docker
  • Python (Pip)
  • Rubin (gem)
  • NPM
  • Bauer
  • Yum (rpm)
  • gitlfs
  • Matière
  • Apt (deb)
  • Go
  • Nuget

Gemeinschaft ënnerstëtzt Artefakte:

  • Komponist
  • Conan
  • CPAN
  • ELPA
  • Helm
  • P2
  • R

Installatioun Sonatype Nexus benotzt https://github.com/ansible-ThoTeam/nexus3-oss

Ufuerderunge

  • Liest iwwer d'Benotzung vun Ansible um Internet.
  • Installéiert ansibel pip install ansible op der Aarbechtsstatioun wou d'Spillbuch leeft.
  • Installéieren geerlingguy.java op der Aarbechtsstatioun wou d'Spillbuch leeft.
  • Installéieren geerlingguy.apache op der Aarbechtsstatioun wou d'Spillbuch leeft.
  • Dës Roll gouf getest op CentOS 7, Ubuntu Xenial (16.04) a Bionic (18.04), Debian Jessie a Stretch
  • jmespath D'Bibliothéik muss op der Aarbechtsstatioun installéiert ginn, wou d'Spillbuch leeft. Fir ze installéieren: sudo pip install -r requirements.txt
  • Späichert d'Playbook-Datei (Beispill hei ënnen) an d'nexus.yml Datei
  • Run Nexus Installatioun ansible-playbook -i host nexus.yml

Beispill ansible-Playbook fir Nexus ouni LDAP mat Maven (Java), Docker, Python, Ruby, NPM, Bower, RPM a gitlfs Repositories z'installéieren.

---
- name: Nexus
  hosts: nexus
  become: yes

  vars:
    nexus_timezone: 'Asia/Omsk'
    nexus_admin_password: "admin123"
    nexus_public_hostname: 'apatsev-nexus-playbook'
    httpd_setup_enable: false
    nexus_privileges:
      - name: all-repos-read
        description: 'Read & Browse access to all repos'
        repository: '*'
        actions:
          - read
          - browse
      - name: company-project-deploy
        description: 'Deployments to company-project'
        repository: company-project
        actions:
          - add
          - edit
    nexus_roles:
      - id: Developpers # maps to the LDAP group
        name: developers
        description: All developers
        privileges:
          - nx-search-read
          - all-repos-read
          - company-project-deploy
        roles: []
    nexus_local_users:
      - username: jenkins # used as key to update
        first_name: Jenkins
        last_name: CI
        email: [email protected]
        password: "s3cr3t"
        roles:
          - Developpers # role ID here
    nexus_blobstores:
      - name: company-artifacts
        path: /var/nexus/blobs/company-artifacts
    nexus_scheduled_tasks:
      - name: compact-blobstore
        cron: '0 0 22 * * ?'
        typeId: blobstore.compact
        taskProperties:
          blobstoreName: 'company-artifacts'

    nexus_repos_maven_proxy:
      - name: central
        remote_url: 'https://repo1.maven.org/maven2/'
        layout_policy: permissive
      - name: jboss
        remote_url: 'https://repository.jboss.org/nexus/content/groups/public-jboss/'
      - name: vaadin-addons
        remote_url: 'https://maven.vaadin.com/vaadin-addons/'
      - name: jaspersoft
        remote_url: 'https://jaspersoft.artifactoryonline.com/jaspersoft/jaspersoft-repo/'
        version_policy: mixed
    nexus_repos_maven_hosted:
      - name: company-project
        version_policy: mixed
        write_policy: allow
        blob_store: company-artifacts
    nexus_repos_maven_group:
      - name: public
        member_repos:
          - central
          - jboss
          - vaadin-addons
          - jaspersoft

    # Yum. Change nexus_config_yum to true for create yum repository
    nexus_config_yum: true
    nexus_repos_yum_hosted:
      - name: private_yum_centos_7
        repodata_depth: 1
    nexus_repos_yum_proxy:
      - name: epel_centos_7_x86_64
        remote_url: http://download.fedoraproject.org/pub/epel/7/x86_64
        maximum_component_age: -1
        maximum_metadata_age: -1
        negative_cache_ttl: 60
      - name: centos-7-os-x86_64
        remote_url: http://mirror.centos.org/centos/7/os/x86_64/
        maximum_component_age: -1
        maximum_metadata_age: -1
        negative_cache_ttl: 60
    nexus_repos_yum_group:
      - name: yum_all
        member_repos:
          - private_yum_centos_7
          - epel_centos_7_x86_64

    # NPM. Change nexus_config_npm to true for create npm repository
    nexus_config_npm: true
    nexus_repos_npm_hosted: []
    nexus_repos_npm_group:
      - name: npm-public
        member_repos:
          - npm-registry
    nexus_repos_npm_proxy:
      - name: npm-registry
        remote_url: https://registry.npmjs.org/
        negative_cache_enabled: false

    # Docker. Change nexus_config_docker to true for create docker repository
    nexus_config_docker: true
    nexus_repos_docker_hosted:
      - name: docker-hosted
        http_port: "{{ nexus_docker_hosted_port }}"
        v1_enabled: True
    nexus_repos_docker_proxy:
      - name: docker-proxy
        http_port: "{{ nexus_docker_proxy_port }}"
        v1_enabled: True
        index_type: "HUB"
        remote_url: "https://registry-1.docker.io"
        use_nexus_certificates_to_access_index: false
        maximum_component_age: 1440
        maximum_metadata_age: 1440
        negative_cache_enabled: true
        negative_cache_ttl: 1440
    nexus_repos_docker_group:
      - name: docker-group
        http_port: "{{ nexus_docker_group_port }}"
        v1_enabled: True
        member_repos:
          - docker-hosted
          - docker-proxy

    # Bower. Change nexus_config_bower to true for create bower repository
    nexus_config_bower: true
    nexus_repos_bower_hosted:
      - name: bower-hosted
    nexus_repos_bower_proxy:
      - name: bower-proxy
        index_type: "proxy"
        remote_url: "https://registry.bower.io"
        use_nexus_certificates_to_access_index: false
        maximum_component_age: 1440
        maximum_metadata_age: 1440
        negative_cache_enabled: true
        negative_cache_ttl: 1440
    nexus_repos_bower_group:
      - name: bower-group
        member_repos:
          - bower-hosted
          - bower-proxy

    # Pypi. Change nexus_config_pypi to true for create pypi repository
    nexus_config_pypi: true
    nexus_repos_pypi_hosted:
      - name: pypi-hosted
    nexus_repos_pypi_proxy:
      - name: pypi-proxy
        index_type: "proxy"
        remote_url: "https://pypi.org/"
        use_nexus_certificates_to_access_index: false
        maximum_component_age: 1440
        maximum_metadata_age: 1440
        negative_cache_enabled: true
        negative_cache_ttl: 1440
    nexus_repos_pypi_group:
      - name: pypi-group
        member_repos:
          - pypi-hosted
          - pypi-proxy

    # rubygems. Change nexus_config_rubygems to true for create rubygems repository
    nexus_config_rubygems: true
    nexus_repos_rubygems_hosted:
      - name: rubygems-hosted
    nexus_repos_rubygems_proxy:
      - name: rubygems-proxy
        index_type: "proxy"
        remote_url: "https://rubygems.org"
        use_nexus_certificates_to_access_index: false
        maximum_component_age: 1440
        maximum_metadata_age: 1440
        negative_cache_enabled: true
        negative_cache_ttl: 1440
    nexus_repos_rubygems_group:
      - name: rubygems-group
        member_repos:
          - rubygems-hosted
          - rubygems-proxy

    # gitlfs. Change nexus_config_gitlfs to true for create gitlfs repository
    nexus_config_gitlfs: true
    nexus_repos_gitlfs_hosted:
      - name: gitlfs-hosted

  roles:
    - { role: geerlingguy.java }
    # Debian/Ubuntu only
    # - { role: geerlingguy.apache, apache_create_vhosts: no, apache_mods_enabled: ["proxy_http.load", "headers.load"], apache_remove_default_vhost: true, tags: ["geerlingguy.apache"] }
    # RedHat/CentOS only
    - { role: geerlingguy.apache, apache_create_vhosts: no, apache_remove_default_vhost: true, tags: ["geerlingguy.apache"] }
    - { role: ansible-thoteam.nexus3-oss, tags: ['ansible-thoteam.nexus3-oss'] }

Screenshots:

Installéieren an konfiguréieren Nexus Sonatype mat der Infrastruktur als Code Approche

Installéieren an konfiguréieren Nexus Sonatype mat der Infrastruktur als Code Approche

Variabel Rollen

Roll Variablen

Variablen mat Standardwäerter (kuckt default/main.yml):

Allgemeng Verännerlechen

    nexus_version: ''
    nexus_timezone: 'UTC'

Par défaut installéiert d'Roll déi lescht verfügbar Versioun vum Nexus. Dir kënnt d'Versioun fixéieren andeems Dir d'Variabel ännert nexus_version. Gesinn verfügbare Versiounen op https://www.sonatype.com/download-oss-sonatype.

Wann Dir op eng méi nei Versioun ännert, probéiert d'Roll Är Nexus Installatioun ze aktualiséieren.

Wann Dir eng méi al Versioun vum Nexus benotzt wéi déi lescht, sollt Dir suergen datt Dir keng Feature benotzt déi net an der installéierter Verëffentlechung verfügbar sinn (zum Beispill, Hosting Yum Repositories ass verfügbar fir Nexus méi wéi 3.8.0, git lfs repo fir Nexus méi wéi 3.3.0 etc.)

nexus timezone ass den Numm vun der Java Zäitzone, déi nëtzlech ka sinn a Kombinatioun mat de folgende Cron Ausdréck fir nexus_scheduled Aufgaben.

Nexus Hafen a Kontext Wee

    nexus_default_port: 8081
    nexus_default_context_path: '/'

Den Hafen a Kontextwee vum Java Verbindungsprozess. nexus_default_context_path muss e Forward Slash enthalen wann se agestallt ass, zB: nexus_default_context_path: '/nexus/'.

Nexus OS Benotzer a Grupp

    nexus_os_group: 'nexus'
    nexus_os_user: 'nexus'

De Benotzer an d'Grupp, déi benotzt gi fir Nexus-Dateien ze besëtzen an de Service auszeféieren, gëtt vun der Roll erstallt wann een fehlt.

    nexus_os_user_home_dir: '/home/nexus'

Erlaabt den Default Heemverzeechnes fir den Nexus Benotzer z'änneren

Nexus Instanz Verzeichnungen

    nexus_installation_dir: '/opt'
    nexus_data_dir: '/var/nexus'
    nexus_tmp_dir: "{{ (ansible_os_family == 'RedHat') | ternary('/var/nexus-tmp', '/tmp/nexus') }}"

Nexus Kataloge.

  • nexus_installation_dir enthält installéiert ausführbar Dateien
  • nexus_data_dir enthält all Konfiguratioun, Repositories an erofgeluede Artefakte. Benotzerdefinéiert blobstore Weeër nexus_data_dir kann personaliséiert ginn, gesinn ënnert nexus_blobstores.
  • nexus_tmp_dir enthält all temporär Dateien. De Standardwee fir Redhat gouf geplënnert /tmp fir potenziell Problemer mat automateschen Botzenprozeduren ze iwwerwannen. Kuckt #168.

Nexus JVM Memory Verwendung konfiguréieren

    nexus_min_heap_size: "1200M"
    nexus_max_heap_size: "{{ nexus_min_heap_size }}"
    nexus_max_direct_memory: "2G"

Dëst sinn d'Standardastellunge fir Nexus. Weg änneren net dës Wäerter Wann Dir net gelies hutt Nexus System Ufuerderunge Erënnerung Rubrik a verstinn net wat se maachen.

Als zweet Warnung, hei ass en Auszuch aus dem uewe genannten Dokument:

Et ass net recommandéiert d'JVM Heap Erënnerung iwwer déi recommandéiert Wäerter ze erhéijen an engem Versuch d'Performance ze verbesseren. Dëst kann eigentlech de Géigendeel Effekt hunn, doraus zu onnéideg Aarbecht fir de Betribssystem.

Administrator Passwuert

    nexus_admin_password: 'changeme'

De "Admin" Kont Passwuert fir d'Konfiguratioun. Dëst funktionnéiert nëmmen op der éischter Standardinstallatioun. Kuckt w.e.g. [Admin Passwuert änneren no der éischter Installatioun] (# change-admin-password-after-first-install) wann Dir et spéider mat enger Roll wëllt änneren.

Et ass staark recommandéiert Äert Passwuert net am Kloertext am Spillbuch ze späicheren, mee [ansible-Vault Verschlësselung] (https://docs.ansible.com/ansible/latest/user_guide/vault.html) (entweder inline oder an enger separater Datei gelueden mat z.B. include_vars)

Anonym Zougang par défaut

    nexus_anonymous_access: false

Anonymen Zougang ass par défaut deaktivéiert. Liest méi iwwer anonym Zougang.

Ëffentlech Hostnumm

    nexus_public_hostname: 'nexus.vm'
    nexus_public_scheme: https

De komplett qualifizéierten Domain Numm a Schema (https oder http) ënner deem d'Nexus Instanz fir seng Clienten verfügbar ass.

API Zougang fir dës Roll

    nexus_api_hostname: localhost
    nexus_api_scheme: http
    nexus_api_validate_certs: "{{ nexus_api_scheme == 'https' }}"
    nexus_api_context_path: "{{ nexus_default_context_path }}"
    nexus_api_port: "{{ nexus_default_port }}"

Dës Variablen kontrolléieren wéi d'Roll mat der Nexus API fir d'Bestëmmung verbënnt.
Nëmmen fir fortgeschratt Benotzer. Dir wëllt dës Standardastellungen wahrscheinlech net änneren

Astellung vun engem Reverse Proxy

    httpd_setup_enable: false
    httpd_server_name: "{{ nexus_public_hostname }}"
    httpd_default_admin_email: "[email protected]"
    httpd_ssl_certificate_file: 'files/nexus.vm.crt'
    httpd_ssl_certificate_key_file: 'files/nexus.vm.key'
    # httpd_ssl_certificate_chain_file: "{{ httpd_ssl_certificate_file }}"
    httpd_copy_ssl_files: true

Installéieren SSL Reverse Proxy.
Fir dëst ze maachen, musst Dir httpd installéieren. Notiz: wann fir httpd_setup_enable setzen Wäerttrue, Nexus Kontakter 127.0.0.1:8081, also Net ass direkt zougänglech iwwer HTTP-Port 8081 vun der externer IP Adress.

De Standard Hostnumm benotzt ass nexus_public_hostname. Wann Dir verschidden Nimm aus irgendege Grënn braucht, kënnt Dir astellen httpd_server_name mat enger anerer Bedeitung.

С httpd_copy_ssl_files: true (par défaut) sollen déi uewe genannte Certificaten an Ärem Playbook Verzeichnis existéieren a ginn op de Server kopéiert an an Apache konfiguréiert.

Wann Dir existent Certificaten um Server benotze wëllt, installéieren httpd_copy_ssl_files: false a gitt déi folgend Variabelen:

    # These specifies to the vhost where to find on the remote server file
    # system the certificate files.
    httpd_ssl_cert_file_location: "/etc/pki/tls/certs/wildcard.vm.crt"
    httpd_ssl_cert_key_location: "/etc/pki/tls/private/wildcard.vm.key"
    # httpd_ssl_cert_chain_file_location: "{{ httpd_ssl_cert_file_location }}"

httpd_ssl_cert_chain_file_location ass fakultativ a sollt net agesat ginn wann Dir d'Kettedatei net wëllt personaliséieren

    httpd_default_admin_email: "[email protected]"

Setzt d'Standardadmin E-Mailadress un

LDAP Configuratioun

LDAP Verbindungen a Sécherheetsräich sinn als Standard behënnert

    nexus_ldap_realm: false
    ldap_connections: []

LDAP Verbindungen, all Element gesäit esou aus:

    nexus_ldap_realm: true
    ldap_connections:
      - ldap_name: 'My Company LDAP' # used as a key to update the ldap config
        ldap_protocol: 'ldaps' # ldap or ldaps
        ldap_hostname: 'ldap.mycompany.com'
        ldap_port: 636
        ldap_use_trust_store: false # Wether or not to use certs in the nexus trust store
        ldap_search_base: 'dc=mycompany,dc=net'
        ldap_auth: 'none' # or simple
        ldap_auth_username: 'username' # if auth = simple
        ldap_auth_password: 'password' # if auth = simple
        ldap_user_base_dn: 'ou=users'
        ldap_user_filter: '(cn=*)' # (optional)
        ldap_user_object_class: 'inetOrgPerson'
        ldap_user_id_attribute: 'uid'
        ldap_user_real_name_attribute: 'cn'
        ldap_user_email_attribute: 'mail'
        ldap_user_subtree: false
        ldap_map_groups_as_roles: false
        ldap_group_base_dn: 'ou=groups'
        ldap_group_object_class: 'posixGroup'
        ldap_group_id_attribute: 'cn'
        ldap_group_member_attribute: 'memberUid'
        ldap_group_member_format: '${username}'
        ldap_group_subtree: false

Beispill LDAP Konfiguratioun fir anonym Authentifikatioun (anonym Bindung), dëst ass och eng "minimal" Konfiguratioun:

    nexus_ldap_realm: true
    ldap_connection:
      - ldap_name: 'Simplest LDAP config'
        ldap_protocol: 'ldaps'
        ldap_hostname: 'annuaire.mycompany.com'
        ldap_search_base: 'dc=mycompany,dc=net'
        ldap_port: 636
        ldap_use_trust_store: false
        ldap_user_id_attribute: 'uid'
        ldap_user_real_name_attribute: 'cn'
        ldap_user_email_attribute: 'mail'
        ldap_user_object_class: 'inetOrgPerson'

Beispill LDAP Konfiguratioun fir einfach Authentifikatioun (mat DSA Kont):

    nexus_ldap_realm: true
    ldap_connections:
      - ldap_name: 'LDAP config with DSA'
        ldap_protocol: 'ldaps'
        ldap_hostname: 'annuaire.mycompany.com'
        ldap_port: 636
        ldap_use_trust_store: false
        ldap_auth: 'simple'
        ldap_auth_username: 'cn=mynexus,ou=dsa,dc=mycompany,dc=net'
        ldap_auth_password: "{{ vault_ldap_dsa_password }}" # better keep passwords in an ansible vault
        ldap_search_base: 'dc=mycompany,dc=net'
        ldap_user_base_dn: 'ou=users'
        ldap_user_object_class: 'inetOrgPerson'
        ldap_user_id_attribute: 'uid'
        ldap_user_real_name_attribute: 'cn'
        ldap_user_email_attribute: 'mail'
        ldap_user_subtree: false

Beispill LDAP Konfiguratioun fir einfach Authentifikatioun (mat DSA Kont) + Gruppen als Rollen mapéiert:

    nexus_ldap_realm: true
    ldap_connections
      - ldap_name: 'LDAP config with DSA'
        ldap_protocol: 'ldaps'
        ldap_hostname: 'annuaire.mycompany.com'
        ldap_port: 636
        ldap_use_trust_store: false
        ldap_auth: 'simple'
        ldap_auth_username: 'cn=mynexus,ou=dsa,dc=mycompany,dc=net'
        ldap_auth_password: "{{ vault_ldap_dsa_password }}" # better keep passwords in an ansible vault
        ldap_search_base: 'dc=mycompany,dc=net'
        ldap_user_base_dn: 'ou=users'
        ldap_user_object_class: 'inetOrgPerson'
        ldap_user_id_attribute: 'uid'
        ldap_user_real_name_attribute: 'cn'
        ldap_user_email_attribute: 'mail'
        ldap_map_groups_as_roles: true
        ldap_group_base_dn: 'ou=groups'
        ldap_group_object_class: 'groupOfNames'
        ldap_group_id_attribute: 'cn'
        ldap_group_member_attribute: 'member'
        ldap_group_member_format: 'uid=${username},ou=users,dc=mycompany,dc=net'
        ldap_group_subtree: false

Beispill LDAP Konfiguratioun fir einfach Authentifikatioun (mat DSA Kont) + Gruppen dynamesch als Rollen mapéiert:

    nexus_ldap_realm: true
    ldap_connections:
      - ldap_name: 'LDAP config with DSA'
        ldap_protocol: 'ldaps'
        ldap_hostname: 'annuaire.mycompany.com'
        ldap_port: 636
        ldap_use_trust_store: false
        ldap_auth: 'simple'
        ldap_auth_username: 'cn=mynexus,ou=dsa,dc=mycompany,dc=net'
        ldap_auth_password: "{{ vault_ldap_dsa_password }}" # better keep passwords in an ansible vault
        ldap_search_base: 'dc=mycompany,dc=net'
        ldap_user_base_dn: 'ou=users'
        ldap_user_object_class: 'inetOrgPerson'
        ldap_user_id_attribute: 'uid'
        ldap_user_real_name_attribute: 'cn'
        ldap_user_email_attribute: 'mail'
        ldap_map_groups_as_roles: true
        ldap_map_groups_as_roles_type: 'dynamic'
        ldap_user_memberof_attribute: 'memberOf'

Privilegien

    nexus_privileges:
      - name: all-repos-read # used as key to update a privilege
        # type: <one of application, repository-admin, repository-content-selector, repository-view, script or wildcard>
        description: 'Read & Browse access to all repos'
        repository: '*'
        actions: # can be add, browse, create, delete, edit, read or  * (all)
          - read
          - browse
        # pattern: pattern
        # domain: domain
        # script_name: name

Lëscht Privilegien fir Astellungen. Kuckt d'Dokumentatioun an d'GUI fir z'iwwerpréiwen wéi eng Variabelen ofhängeg vum Privilegart agestallt musse ginn.

Dës Elementer si mat de folgende Standardwäerter kombinéiert:

    _nexus_privilege_defaults:
      type: repository-view
      format: maven2
      actions:
        - read

Rollen (bannen Nexus heescht dat)

    nexus_roles:
      - id: Developpers # can map to a LDAP group id, also used as a key to update a role
        name: developers
        description: All developers
        privileges:
          - nx-search-read
          - all-repos-read
        roles: [] # references to other role names

Lëscht Rollen fir Astellungen.

Benotzer

    nexus_local_users: []
      # - username: jenkins # used as key to update
      #   state: present # default value if ommited, use 'absent' to remove user
      #   first_name: Jenkins
      #   last_name: CI
      #   email: [email protected]
      #   password: "s3cr3t"
      #   roles:
      #     - developers # role ID

Lokal (net-LDAP) Benotzer / Konten Lëscht fir am Nexus ze kreéieren.

Lëscht vun lokalen (net-LDAP) Benotzer/Konten fir am Nexus ze kreéieren.

      nexus_ldap_users: []
      # - username: j.doe
      #   state: present
      #   roles:
      #     - "nx-admin"

Ldap Kaart vun Benotzer / Rollen. Staat absent wäert Rollen aus engem bestehend Benotzer ewechhuelen wann et schonn existéiert.
Ldap Benotzer ginn net geläscht. Probéiert eng Roll fir en net existente Benotzer ze setzen wäert zu engem Feeler féieren.

Inhalt selectors

  nexus_content_selectors:
  - name: docker-login
    description: Selector for docker login privilege
    search_expression: format=="docker" and path=~"/v2/"

Fir méi Informatiounen iwwer den Inhaltselektor, kuckt Dokumentatioun.

Fir den Inhaltselektor ze benotzen, füügt en neie Privileg mat type: repository-content-selector an relevantcontentSelector

- name: docker-login-privilege
  type: repository-content-selector
  contentSelector: docker-login
  description: 'Login to Docker registry'
  repository: '*'
  actions:
  - read
  - browse

Blobstores a Repositories

    nexus_delete_default_repos: false

Läschen d'Repositories vun der Nexus installéieren initial Standardkonfiguratioun. Dëse Schrëtt gëtt nëmme bei der éischter Installatioun ausgefouert (wann nexus_data_dir eidel festgestallt gouf).

Ewechzehuelen Repositories aus der Standard Default Configuratioun fir Nexus. Dëse Schrëtt gëtt nëmme während der éischter Installatioun duerchgefouert (wann nexus_data_dir eidel).

    nexus_delete_default_blobstore: false

Läschen der Default blobstore vun der Nexus installéieren initial Default Configuratioun. Dëst kann nëmme gemaach ginn wann nexus_delete_default_repos: true an all konfiguréiert Repositories (kuckt hei ënnen) hunn eng explizit blob_store: custom. Dëse Schrëtt gëtt nëmme bei der éischter Installatioun ausgefouert (wann nexus_data_dir eidel festgestallt gouf).

Ewechhuele vu Bloblagerung (binär Artefakte) ass Standard aus der initialer Konfiguratioun ausgeschalt. Fir Bloblagerung (binär Artefakte) ze läschen, auszeschalten nexus_delete_default_repos: true. Dëse Schrëtt gëtt nëmme während der éischter Installatioun duerchgefouert (wann nexus_data_dir eidel).

    nexus_blobstores: []
    # example blobstore item :
    # - name: separate-storage
    #   type: file
    #   path: /mnt/custom/path
    # - name: s3-blobstore
    #   type: S3
    #   config:
    #     bucket: s3-blobstore
    #     accessKeyId: "{{ VAULT_ENCRYPTED_KEY_ID }}"
    #     secretAccessKey: "{{ VAULT_ENCRYPTED_ACCESS_KEY }}"

Blobstores kréeieren. E Blobstore Wee an e Repository Blobstore kënnen net no der initialer Erstellung aktualiséiert ginn (all Update hei gëtt bei der Re-Provisionéierung ignoréiert).

Blobstore op S3 konfiguréieren gëtt als Komfort geliwwert an ass net Deel vun den automatiséierten Tester déi mir op travis lafen. Notéiert w.e.g. datt d'Späichere op S3 nëmme recommandéiert ass fir Fäll déi op AWS ofgesat ginn.

Schafung Blobstores. De Späicherwee an de Späicherrepository kënnen net no der éischter Erstellung aktualiséiert ginn (all Update hei gëtt ignoréiert wann se erëm installéiert ginn).

D'Bloblagerung op S3 opzestellen gëtt als Komfort zur Verfügung gestallt. Notéiert w.e.g. datt S3-Speicherung nëmme recommandéiert ass fir Fäll op AWS ofgesat.

    nexus_repos_maven_proxy:
      - name: central
        remote_url: 'https://repo1.maven.org/maven2/'
        layout_policy: permissive
        # maximum_component_age: -1
        # maximum_metadata_age: 1440
        # negative_cache_enabled: true
        # negative_cache_ttl: 1440
      - name: jboss
        remote_url: 'https://repository.jboss.org/nexus/content/groups/public-jboss/'
        # maximum_component_age: -1
        # maximum_metadata_age: 1440
        # negative_cache_enabled: true
        # negative_cache_ttl: 1440
    # example with a login/password :
    # - name: secret-remote-repo
    #   remote_url: 'https://company.com/repo/secure/private/go/away'
    #   remote_username: 'username'
    #   remote_password: 'secret'
    #   # maximum_component_age: -1
    #   # maximum_metadata_age: 1440
    #   # negative_cache_enabled: true
    #   # negative_cache_ttl: 1440

Uewen ass e Beispill Konfiguratioun Proxy Server Maven.

    nexus_repos_maven_hosted:
      - name: private-release
        version_policy: release
        write_policy: allow_once  # one of "allow", "allow_once" or "deny"

Maven gehost Repositories Configuratioun. Negativ Cache-Configuratioun ass fakultativ a gëtt Standard op déi uewe genannte Wäerter wa se ewechgelooss ginn.

Configuratioun gehost Repositories Maven. Déi negativ Cache Konfiguratioun (-1) ass fakultativ a gëtt Standard op déi uewe genannte Wäerter wann net spezifizéiert.

    nexus_repos_maven_group:
      - name: public
        member_repos:
          - central
          - jboss

Configuratioun Gruppen Maven.

All dräi Repositorytypen gi mat de folgende Standardwäerter kombinéiert:

    _nexus_repos_maven_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 # one of "allow", "allow_once" or "deny"
      maximum_component_age: -1  # Nexus gui default. For proxies only
      maximum_metadata_age: 1440  # Nexus gui default. For proxies only
      negative_cache_enabled: true # Nexus gui default. For proxies only
      negative_cache_ttl: 1440 # Nexus gui default. For proxies only

Docker, Pypi, Raw, Rubygems, Bower, NPM, Git-LFS an yum Repository Typen:
gesinn defaults/main.yml fir dës Optiounen:

Docker, Pypi, Raw, Rubygems, Bower, NPM, Git-LFS an yum Repositories sinn par défaut deaktivéiert:
Kuckt defaults/main.yml fir dës Optiounen:

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

Notéiert w.e.g. datt Dir vläicht gewësse Sécherheetsberäicher aktivéiere musst wann Dir aner Aarte vu Repositories wéi Maven benotze wëllt. Dëst ass par défaut falsch

nexus_nuget_api_key_realm: false
nexus_npm_bearer_token_realm: false
nexus_docker_bearer_token_realm: false  # required for docker anonymous access

Remote User Realm kann och aktivéiert ginn benotzt

nexus_rut_auth_realm: true

an den Titel kann duerch Definitioun personaliséiert ginn

nexus_rut_auth_header: "CUSTOM_HEADER"

Geplangte Aufgaben

    nexus_scheduled_tasks: []
    #  #  Example task to compact blobstore :
    #  - name: compact-docker-blobstore
    #    cron: '0 0 22 * * ?'
    #    typeId: blobstore.compact
    #    task_alert_email: [email protected]  # optional
    #    taskProperties:
    #      blobstoreName: {{ nexus_blob_names.docker.blob }} # all task attributes are stored as strings by nexus internally
    #  #  Example task to purge maven snapshots
    #  - name: Purge-maven-snapshots
    #    cron: '0 50 23 * * ?'
    #    typeId: repository.maven.remove-snapshots
    #    task_alert_email: [email protected]  # optional
    #    taskProperties:
    #      repositoryName: "*"  # * for all repos. Change to a repository name if you only want a specific one
    #      minimumRetained: "2"
    #      snapshotRetentionDays: "2"
    #      gracePeriodInDays: "2"
    #    booleanTaskProperties:
    #      removeIfReleased: true
    #  #  Example task to purge unused docker manifest and images
    #  - name: Purge unused docker manifests and images
    #    cron: '0 55 23 * * ?'
    #    typeId: "repository.docker.gc"
    #    task_alert_email: [email protected]  # optional
    #    taskProperties:
    #      repositoryName: "*"  # * for all repos. Change to a repository name if you only want a specific one
    #  #  Example task to purge incomplete docker uploads
    #  - name: Purge incomplete docker uploads
    #    cron: '0 0 0 * * ?'
    #    typeId: "repository.docker.upload-purge"
    #    task_alert_email: [email protected]  # optional
    #    taskProperties:
    #      age: "24"

Geplangte Aufgaben fir Astellungen. typeId an Aufgab spezifeschtaskProperties/booleanTaskProperties Dir kënnt entweder roden:

  • vun der Java Typ Hierarchie org.sonatype.nexus.scheduling.TaskDescriptorSupport
  • kontrolléiert d'HTML-Task-Creatioun Form an Ärem Browser
  • AJAX Ufroen am Browser ze gesinn wann Dir eng Aufgab manuell opstellt.

Aufgab Eegeschafte mussen am richtege Yaml Block deklaréiert ginn ofhängeg vun hirem Typ:

  • taskProperties fir all String Eegeschafte (dh Repository Nimm, Repository Nimm, Zäitperioden ...).
  • booleanTaskProperties fir all logesch Eegeschaften (dh haaptsächlech Checkboxen am GUI vun der Nexus Kreatioun Aufgab).

Backupsatellit

      nexus_backup_configure: false
      nexus_backup_cron: '0 0 21 * * ?'  # See cron expressions definition in nexus create task gui
      nexus_backup_dir: '/var/nexus-backup'
      nexus_restore_log: '{{ nexus_backup_dir }}/nexus-restore.log'
      nexus_backup_rotate: false
      nexus_backup_rotate_first: false
      nexus_backup_keep_rotations: 4  # Keep 4 backup rotation by default (current + last 3)

De Backup gëtt net konfiguréiert bis Dir wiesselt nexus_backup_configure в true.
An dësem Fall gëtt déi geplangte Skripttask konfiguréiert fir op Nexus ze lafen
am Intervall uginn an nexus_backup_cron (Standard 21:00 all Dag).
Gesinn [groovy Schabloun fir dës Aufgab] (Templates/backup.groovy.j2) fir Detailer.
Dës geplangten Aufgab ass onofhängeg vun aneren nexus_scheduled_tasksdéi Dir
an Ärem Spillbuch annoncéieren.

Wann Dir wëllt Backups rotéieren / läschen, installéieren nexus_backup_rotate: true a konfiguréieren d'Zuel vun de Backups déi Dir wëllt späichere benotzen nexus_backup_keep_rotations (Standard 4).

Wann Dir Rotatioun benotzt, wann Dir zousätzlech Disk Space wärend dem Backupprozess späichere wëllt,
Dir kënnt installéieren nexus_backup_rotate_first: true. Dëst wäert Pre-Rotatioun / Läschen virum Backup konfiguréieren. Par défaut geschitt Rotatioun nodeems e Backup erstallt gëtt. Maacht weg datt an dësem Fall déi al Backups
gëtt geläscht ier den aktuelle Backup gemaach gëtt.

Erhuelung Prozedur

Run Spillbuch mat Parameter -e nexus_restore_point=<YYYY-MM-dd-HH-mm-ss>
(zum Beispill 2017-12-17-21-00-00 fir den 17. Dezember 2017 um 21:00 Auer

Ewechzehuelen Nexus

Opgepasst: Dëst wäert Är aktuell Donnéeën komplett läschen. Gitt sécher e Backup ze maachen, wann néideg

Benotzt eng Variabel nexus_purgewann Dir musst vun Null nei starten an d'Nexus Instanz nei installéieren mat all Daten ewechgeholl.

ansible-playbook -i your/inventory.ini your_nexus_playbook.yml -e nexus_purge=true

Änneren Administrator Passwuert no der éischter Installatioun

    nexus_default_admin_password: 'admin123'

Dëst sollt net an Ärem Spillbuch geännert ginn. Dës Variabel ass mat dem Standard Nexus Admin Passwuert populéiert wann se fir d'éischt installéiert sinn a garantéiert datt mir d'Admin Passwuert änneren kënnen nexus_admin_password.

Wann Dir de Administrator Passwuert no der éischter Installatioun wëllt änneren, kënnt Dir et temporär op dat alt Passwuert vun der Kommandozeil änneren. No Ännerung nexus_admin_password an Ärem Spillbuch kënnt Dir lafen:

ansible-playbook -i your/inventory.ini your_playbook.yml -e nexus_default_admin_password=oldPassword

Telegram Kanal op Nexus Sonatype: https://t.me/ru_nexus_sonatype

Nëmme registréiert Benotzer kënnen un der Ëmfro deelhuelen. Umellen, wann ech glift.

Wéi eng Artefakt Repositories benotzt Dir?

  • Sonatype Nexus ass gratis

  • Sonatype Nexus bezuelt

  • Artifactory ass gratis

  • Artifactory bezuelt

  • Harbour

  • Pulp

9 Benotzer hunn gestëmmt. 3 Benotzer hu sech enthalen.

Source: will.com

Setzt e Commentaire