Instali kaj agordi Nexus Sonatype uzante la infrastrukturon kiel kodan aliron

Sonatype Nexus estas integra platformo per kiu programistoj povas prokuri, stoki kaj administri Java (Maven) dependecojn, Docker, Python, Ruby, NPM, Bower-bildojn, RPM-pakaĵojn, gitlfs, Apt, Go, Nuget, kaj distribui sian programaran sekurecon.

Kial vi bezonas Sonatype Nexus?

  • Por stokado de privataj artefaktoj;
  • Por konservado de artefaktoj kiuj estas elŝutitaj de la Interreto;

Artefaktoj subtenataj en la baza Sonatype Nexus-pakaĵo:

  • Java, Maven (kruĉo)
  • Docker
  • Python (pip)
  • Rubeno (gemo)
  • NPM
  • Bowers
  • Yum (rpm)
  • gitlfs
  • kruda
  • Apt (deb)
  • Go
  • Nuget

Komunumo Subtenataj Artefaktoj:

  • komponisto
  • conan
  • CPAN
  • ELPA
  • Kasko
  • P2
  • R

Instalante Sonatype Nexus uzante https://github.com/ansible-ThoTeam/nexus3-oss

postuloj

  • Legu pri uzado de ansible en la Interreto.
  • Instalu ansible pip install ansible sur la laborstacio kie la ludlibro funkcias.
  • Instali geerlingguy.java sur la laborstacio kie la ludlibro funkcias.
  • Instali geerlingguy.apache sur la laborstacio kie la ludlibro funkcias.
  • Ĉi tiu rolo estis testita sur CentOS 7, Ubuntu Xenial (16.04) kaj Bionic (18.04), Debian Jessie kaj Stretch
  • jmespath La biblioteko devas esti instalita sur la laborstacio kie la ludlibro funkcias. Por instali: sudo pip install -r requirements.txt
  • Konservu la ludlibrodosieron (ekzemplo sube) al nexus.yml-dosiero
  • Rulu nexus-instaladon ansible-playbook -i host nexus.yml

Ekzemplo ansible-playbook por instali nexus sen LDAP kun Maven (java), Docker, Python, Ruby, NPM, Bower, RPM kaj gitlfs-deponejoj.

---
- 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'] }

Ekrankopioj:

Instali kaj agordi Nexus Sonatype uzante la infrastrukturon kiel kodan aliron

Instali kaj agordi Nexus Sonatype uzante la infrastrukturon kiel kodan aliron

Variaj roloj

Rolvariabloj

Variabloj kun defaŭltaj valoroj (vidu default/main.yml):

Ĝeneralaj variabloj

    nexus_version: ''
    nexus_timezone: 'UTC'

Defaŭlte, la rolo instalos la plej novan disponeblan version de Nexus. Vi povas ripari la version ŝanĝante la variablon nexus_version. Vidu disponeblajn versiojn ĉe https://www.sonatype.com/download-oss-sonatype.

Se vi ŝanĝas al pli nova versio, la rolo provos ĝisdatigi vian instaladon de Nexus.

Se vi uzas pli malnovan version de Nexus ol la plej nova, vi devas certigi, ke vi ne uzas funkciojn, kiuj ne estas disponeblaj en la instalita eldono (ekzemple, gastigado de yum-deponejoj disponeblas por nexus pli granda ol 3.8.0, git lfs repo). por ligilo pli granda ol 3.3.0 ktp.)

nexus timezone estas la nomo de la Java horzono, kiu povas esti utila kombine kun la sekvaj cron-esprimoj por nexus_scheduled taskoj.

Nexus haveno kaj kunteksta vojo

    nexus_default_port: 8081
    nexus_default_context_path: '/'

La haveno kaj kunteksta vojo de la Java-konektprocezo. nexus_default_context_path devas enhavi antaŭan oblikvon kiam ĝi estas agordita, ekz.: nexus_default_context_path: '/nexus/'.

Nexus OS Uzanto kaj Grupo

    nexus_os_group: 'nexus'
    nexus_os_user: 'nexus'

La uzanto kaj grupo kutimis posedi Nexus-dosierojn kaj ruli la servon estos kreitaj de la rolo, se iu mankas.

    nexus_os_user_home_dir: '/home/nexus'

Permesu ŝanĝi la defaŭltan hejman dosierujon por la nexus-uzanto

Nexus-instancaj dosierujoj

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

Nexus-Katalogoj.

  • nexus_installation_dir enhavas instalitajn ruleblajn dosierojn
  • nexus_data_dir enhavas ĉiujn agordojn, deponejojn kaj elŝutitajn artefaktojn. Propraj blobstore vojoj nexus_data_dir povas esti personecigita, vidu sube nexus_blobstores.
  • nexus_tmp_dir enhavas ĉiujn provizorajn dosierojn. La defaŭlta vojo por redhat estis movita de /tmp por venki eblajn problemojn kun aŭtomataj purigaj proceduroj. Vidu #168.

Agordi Nexus JVM-Uzadon de Memoro

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

Ĉi tiuj estas la defaŭltaj agordoj por Nexus. Bonvolu ne ŝanĝi ĉi tiujn valorojn Se vi ne legis nexus sistema postuloj memorsekcio kaj ne komprenas, kion ili faras.

Kiel dua averto, jen eltiraĵo de la supra dokumento:

Ne rekomendas pliigi la amasmemoron de JVM preter la rekomenditaj valoroj en provo plibonigi rendimenton. Ĉi tio efektive povas havi la kontraŭan efikon, rezultigante nenecesan laboron por la operaciumo.

Pasvorto de administranto

    nexus_admin_password: 'changeme'

La pasvorto de la konto "administranto" por agordo. Ĉi tio funkcias nur ĉe la unua defaŭlta instalado. Bonvolu vidi [Ŝanĝi administran pasvorton post unua instalado](# change-admin-password-after-first-install) se vi volas ŝanĝi ĝin poste uzante rolon.

Estas forte rekomendite ne konservi vian pasvorton kiel klaran tekston en la ludlibro, sed uzi [ansible-vault-ĉifradon] (https://docs.ansible.com/ansible/latest/user_guide/vault.html) (aŭ enlinia aŭ en aparta dosiero ŝarĝita kun ekz. include_vars)

Anonima aliro defaŭlte

    nexus_anonymous_access: false

Anonima aliro estas malebligita defaŭlte. Legu pli pri anonima aliro.

Publika gastiga nomo

    nexus_public_hostname: 'nexus.vm'
    nexus_public_scheme: https

La plene kvalifikita domajna nomo kaj skemo (https aŭ http) laŭ kiuj la Nexus-instanco estos havebla al siaj klientoj.

API-aliro por ĉi tiu rolo

    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 }}"

Ĉi tiuj variabloj kontrolas kiel la rolo konektas al la Nexus API por provizado.
Nur por progresintaj uzantoj. Vi verŝajne ne volas ŝanĝi ĉi tiujn defaŭltajn agordojn

Agordi inversan prokurilon

    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

Instali SSL Inversa Prokurilo.
Por fari tion vi devas instali httpd. Noto: kiam por httpd_setup_enable fiksita valorotrue, nexus kontaktas 127.0.0.1:8081, tiel ne estante rekte alirebla per HTTP-haveno 8081 de la ekstera IP-adreso.

La defaŭlta gastiga nomo uzata estas nexus_public_hostname. Se vi bezonas malsamajn nomojn ial, vi povas agordi httpd_server_name kun malsama signifo.

С httpd_copy_ssl_files: true (defaŭlte) ĉi-supraj atestiloj devus ekzisti en via ludlibro-dosierujo kaj estos kopiitaj al la servilo kaj agordita en apache.

Se vi volas uzi ekzistantajn atestojn en la servilo, instalu httpd_copy_ssl_files: false kaj provizi la sekvajn variablojn:

    # 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 estas laŭvola kaj devus esti lasita neagordita se vi ne volas personecigi la ĉendosieron

    httpd_default_admin_email: "[email protected]"

Agordu defaŭltan administran retadreson

LDAP-agordo

LDAP-konektoj kaj sekurecsfero estas malŝaltitaj defaŭlte

    nexus_ldap_realm: false
    ldap_connections: []

LDAP-konektoj, ĉiu elemento aspektas jene:

    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

Ekzemplo LDAP-agordo por anonima aŭtentikigo (anonima ligado), ĉi tio ankaŭ estas "minimuma" agordo:

    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'

Ekzemplo LDAP-agordo por simpla aŭtentigo (uzante DSA-konton):

    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

Ekzemplo LDAP-agordo por simpla aŭtentigo (uzante DSA-konton) + grupoj mapitaj kiel roloj:

    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

Ekzemplo LDAP-agordo por simpla aŭtentigo (uzante DSA-konton) + grupoj dinamike mapitaj kiel roloj:

    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'

Privilegio

    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

Listo de privilegioj por agordoj. Rigardu la dokumentadon kaj GUI por kontroli kiuj variabloj devas esti agorditaj depende de la privilegia tipo.

Ĉi tiuj elementoj estas kombinitaj kun la sekvaj defaŭltaj valoroj:

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

Roloj (en Nexus tio signifas)

    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

Listo de roloj por agordoj.

Uzantoj

    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

Listo de lokaj (ne-LDAP) uzantoj/kontoj por krei en nexus.

Listo de lokaj (ne-LDAP) uzantoj/kontoj por krei en Nexus.

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

Ldap-mapado de uzantoj/roloj. Ŝtato absent forigos rolojn de ekzistanta uzanto se unu jam ekzistas.
Uzantoj de Ldap ne estas forigitaj. Provi agordi rolon por neekzistanta uzanto rezultigos eraron.

Enhavaj elektiloj

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

Por pliaj informoj pri la enhavelektilo, vidu Dokumentado.

Por uzi la enhavan elektilon, aldonu novan privilegion kun type: repository-content-selector kaj trafacontentSelector

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

Blobstores kaj deponejoj

    nexus_delete_default_repos: false

Forigu la deponejojn de la nexus instali komencan defaŭltan agordon. Ĉi tiu paŝo estas efektivigita nur ĉe unuafoja instalado (kiam nexus_data_dir estis detektita malplena).

Forigante deponejojn de la defaŭlta agordo por Nexus. Ĉi tiu paŝo estas farita nur dum la unua instalado (kiam nexus_data_dir malplena).

    nexus_delete_default_blobstore: false

Forigu la defaŭltan blobvendejon de la komenca defaŭlta agordo de nexus instali. Ĉi tio povas esti farita nur se nexus_delete_default_repos: true kaj ĉiuj agorditaj deponejoj (vidu malsupre) havas eksplicitan blob_store: custom. Ĉi tiu paŝo estas efektivigita nur ĉe unuafoja instalado (kiam nexus_data_dir estis detektita malplena).

Forigo de blobstokado (binaraj artefaktoj) estas malebligita defaŭlte de la komenca agordo. Por forigi blob-stokadon (binaraj artefaktoj), malŝaltu nexus_delete_default_repos: true. Ĉi tiu paŝo estas farita nur dum la unua instalado (kiam nexus_data_dir malplena).

    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 }}"

Blobvendejoj Krei. Blobvendeja vojo kaj deponejo blobvendejo ne povas esti ĝisdatigitaj post komenca kreado (ĉiu ajn ĝisdatigo ĉi tie estos ignorita dum reprovizado).

Agordi blobstore sur S3 estas provizita kiel oportuno kaj ne estas parto de la aŭtomatigitaj testoj, kiujn ni faras sur travis. Bonvolu noti, ke stokado sur S3 estas rekomendita nur por okazoj deplojitaj sur AWS.

Kreado Blobvendejoj. La stoka vojo kaj stokado deponejo ne povas esti ĝisdatigitaj post la komenca kreado (ĉiu ajn ĝisdatigo ĉi tie estos ignorita kiam instalita denove).

Agordo de blobstokado sur S3 estas disponigita kiel oportuno. Bonvolu noti, ke S3-stokado estas rekomendita nur por okazoj deplojitaj sur AWS.

    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

Supre estas ekzempla agordo prokura servilo Maven.

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

Maven gastigitaj deponejoj agordo. Negativa kaŝmemora agordo estas laŭvola kaj defaŭlte al la supraj valoroj se ellasita.

Agordo gastigitaj deponejoj Maven. La negativa kaŝmemora agordo (-1) estas laŭvola kaj defaŭlte al la supraj valoroj se ne specifita.

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

Agordo grupoj Maven.

Ĉiuj tri deponejoj estas kombinitaj kun la sekvaj defaŭltaj valoroj:

    _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 kaj yum-deponejoj:
vidu defaults/main.yml por ĉi tiuj opcioj:

Docker, Pypi, Raw, Rubygems, Bower, NPM, Git-LFS kaj yum-deponejoj estas malŝaltitaj defaŭlte:
Vidu defaults/main.yml por ĉi tiuj opcioj:

      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

Bonvolu noti, ke vi eble bezonos ebligi certajn sekureckampojn se vi volas uzi aliajn specojn de deponejoj krom Maven. Ĉi tio estas malvera defaŭlte

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 ankaŭ povas esti ebligita uzante

nexus_rut_auth_realm: true

kaj la titolo povas esti personecigita per difinado

nexus_rut_auth_header: "CUSTOM_HEADER"

Planitaj taskoj

    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"

Planitaj taskoj por agordoj. typeId kaj specifa taskotaskProperties/booleanTaskProperties vi povas diveni aŭ:

  • el la Ĝava tiphierarkio org.sonatype.nexus.scheduling.TaskDescriptorSupport
  • kontrolante la HTML-taskan kreadformularon en via retumilo
  • de vidi AJAX-petojn en la retumilo dum mane agordante taskon.

Taskaj propraĵoj devas esti deklaritaj en la ĝusta yaml-bloko depende de sia tipo:

  • taskProperties por ĉiuj ĉenpropraĵoj (t.e. nomoj de deponejoj, nomoj de deponejoj, tempoperiodoj...).
  • booleanTaskProperties por ĉiuj logikaj propraĵoj (t.e. ĉefe markobutonoj en la GUI de la nexus-kreadtasko).

Sekurkopioj

      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)

Rezervo ne estos agordita ĝis vi ŝanĝas nexus_backup_configure в true.
En ĉi tiu kazo, la planita skriptotasko estos agordita por funkcii sur Nexus
je la intervalo specifita en nexus_backup_cron (defaŭlte 21:00 ĉiutage).
Vidu [groovy ŝablono por ĉi tiu tasko](templates/backup.groovy.j2) por detaloj.
Ĉi tiu planita tasko estas sendependa de aliaj nexus_scheduled_taskskiun vi
anoncu en via ludlibro.

Se vi volas turni/forigi sekurkopiojn, instalu nexus_backup_rotate: true kaj agordu la nombron da sekurkopioj, kiujn vi ŝatus konservi uzante nexus_backup_keep_rotations (defaŭlte 4).

Kiam vi uzas rotacion, se vi volas ŝpari plian diskospacon dum la rezerva procezo,
Vi povas instali nexus_backup_rotate_first: true. Ĉi tio agordos antaŭrotacion/forigon antaŭ sekurkopio. Defaŭlte, rotacio okazas post kiam sekurkopio estas kreita. Bonvolu noti, ke en ĉi tiu kazo la malnovaj sekurkopioj
estos forigita antaŭ ol la nuna sekurkopio estas farita.

Reakira proceduro

Rulu ludlibron kun parametro -e nexus_restore_point=<YYYY-MM-dd-HH-mm-ss>
(ekzemple, 2017-12-17-21-00-00 por la 17-a de decembro 2017 je 21:00

Forigante ligilon

Averto: Ĉi tio tute forigos viajn nunajn datumojn. Nepre faru sekurkopion pli frue se necese

Uzu variablon nexus_purgese vi bezonas rekomenci de nulo kaj reinstali la nexus-instancon kun ĉiuj datumoj forigitaj.

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

Ŝanĝu pasvorton de administranto post la unua instalado

    nexus_default_admin_password: 'admin123'

Ĉi tio ne estu ŝanĝita en via ludlibro. Ĉi tiu variablo estas plenigita per la defaŭlta administra pasvorto de Nexus kiam unue instalita kaj certigas, ke ni povas ŝanĝi la administran pasvorton al nexus_admin_password.

Se vi volas ŝanĝi la pasvorton de administranto post la unua instalado, vi povas provizore ŝanĝi ĝin al la malnova pasvorto de la komandlinio. Post ŝanĝo nexus_admin_password en via ludlibro vi povas ruli:

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

Telegram-kanalo sur Nexus Sonatype: https://t.me/ru_nexus_sonatype

Nur registritaj uzantoj povas partopreni la enketon. Ensaluti, bonvolu.

Kiajn artefaktajn deponejojn vi uzas?

  • Sonatype Nexus estas senpaga

  • Sonatype Nexus pagis

  • Artefaro estas senpaga

  • Artefaro pagita

  • Haveno

  • Pulpo

Voĉdonis 9 uzantoj. 3 uzantoj sindetenis.

fonto: www.habr.com

Aldoni komenton