Fametrahana sy fanamboarana ny Nexus Sonatype amin'ny fampiasana ny fotodrafitrasa ho fomba fiasa

Sonatype Nexus dia sehatra mitambatra ahafahan'ny mpamorona misolo toerana, mitahiry ary mitantana ny fiankinan'ny Java (Maven), Docker, Python, Ruby, NPM, sary Bower, fonosana RPM, gitlfs, Apt, Go, Nuget, ary mizara ny fiarovana ny rindrambaiko.

Nahoana ianao no mila Sonatype Nexus?

  • Ho fitehirizana artifacts manokana;
  • Ho an'ny caching artifacts izay alaina avy amin'ny Internet;

Zavakanto tohana ao amin'ny fonosana Sonatype Nexus fototra:

  • Java, Maven (jar)
  • Docker
  • Python (pip)
  • Ruby (vatosoa)
  • NPM
  • Bowers
  • Yum (rpm)
  • gitlfs
  • Raw
  • Apt (deb)
  • Go
  • Nuget

Zavakanto tohanan'ny fiaraha-monina:

  • Composer
  • Conan
  • CPAN
  • ELPA
  • fiarovan-doha
  • P2
  • R

Fametrahana ny Sonatype Nexus mampiasa https://github.com/ansible-ThoTeam/nexus3-oss

fepetra takiana

  • Vakio ny momba ny fampiasana ansible amin'ny Internet.
  • Install ansible pip install ansible eo amin'ny toeram-piasana izay misy ny playbook.
  • hametraka geerlingguy.java eo amin'ny toeram-piasana izay misy ny playbook.
  • hametraka geerlingguy.apache eo amin'ny toeram-piasana izay misy ny playbook.
  • Ity andraikitra ity dia nosedraina tamin'ny CentOS 7, Ubuntu Xenial (16.04) ary Bionic (18.04), Debian Jessie ary Stretch
  • jmespath Ny tranomboky dia tsy maintsy apetraka eo amin'ny toeram-piasana misy ny playbook. Hametraka: sudo pip install -r requirements.txt
  • Tehirizo amin'ny rakitra nexus.yml ny rakitra playbook (ohatra etsy ambany).
  • Alefaso ny fametrahana Nexus ansible-playbook -i host nexus.yml

Ohatra ansible-playbook amin'ny fametrahana nexus tsy misy LDAP miaraka amin'ny tahiry Maven (java), Docker, Python, Ruby, NPM, Bower, RPM ary gitlfs.

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

sary:

Fametrahana sy fanamboarana ny Nexus Sonatype amin'ny fampiasana ny fotodrafitrasa ho fomba fiasa

Fametrahana sy fanamboarana ny Nexus Sonatype amin'ny fampiasana ny fotodrafitrasa ho fomba fiasa

Anjara miovaova

Variables anjara

Variable misy sanda default (jereo default/main.yml):

Variable ankapobe

    nexus_version: ''
    nexus_timezone: 'UTC'

Amin'ny alàlan'ny default, ny andraikitra dia hametraka ny kinova farany misy an'ny Nexus. Azonao atao ny manamboatra ny dikan-teny amin'ny fanovana ny fari-piainana nexus_version. Jereo ny dikan-teny misy ao amin'ny https://www.sonatype.com/download-oss-sonatype.

Raha miova amin'ny kinova vaovao ianao dia hanandrana hanavao ny fametrahana Nexus anao ny anjara.

Raha mampiasa dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-dikan-teny ao amin'ny Nexus ianao, dia tokony ho azo antoka fa tsy mampiasa endri-javatra tsy hita ao amin'ny famoahana napetraka ianao (ohatra, ny fampiantranoana trano fitehirizam-bokatra yum dia misy ho an'ny nexus lehibe kokoa noho ny 3.8.0, git lfs repo. ho an'ny nexus mihoatra ny 3.3.0 sns.)

nexus timezone dia ny anaran'ny faritra Java, izay mety ilaina miaraka amin'ireto teny cron manaraka ireto ho an'ny asa nexus_scheduled.

Seranana Nexus sy lalan'ny contexte

    nexus_default_port: 8081
    nexus_default_context_path: '/'

Ny seranan-tsambo sy ny lalan'ny contexte amin'ny fizotran'ny fifandraisana Java. nexus_default_context_path tsy maintsy misy slash mandroso rehefa apetraka, ohatra: nexus_default_context_path: '/nexus/'.

Mpampiasa sy Vondrona Nexus OS

    nexus_os_group: 'nexus'
    nexus_os_user: 'nexus'

Ny mpampiasa sy ny vondrona zatra manana rakitra Nexus sy mitantana ny serivisy dia hoforonin'ny andraikitra raha misy tsy hita.

    nexus_os_user_home_dir: '/home/nexus'

Avelao ny fanovana ny lahatahiry an-trano ho an'ny mpampiasa nexus

Lahatahiry ohatra Nexus

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

Nexus Catalogs.

  • nexus_installation_dir misy rakitra azo tanterahana napetraka
  • nexus_data_dir mirakitra ny configuration rehetra, ny repository ary ny artifact alaina. Lalana blobstore manokana nexus_data_dir azo namboarina, jereo eto ambany nexus_blobstores.
  • nexus_tmp_dir misy rakitra vonjimaika rehetra. Ny lalana default ho an'ny redhat dia nafindra tamin'ny /tmp handresena ny olana mety hitranga amin'ny fomba fanadiovana mandeha ho azy. Jereo ny #168.

Fampiasana fitadidiana Nexus JVM

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

Ireo no firafitry ny Nexus. Aza ovaina azafady ireo soatoavina ireo Raha mbola tsy namaky ianao fizarana fitadidiana rafitra nexus ary tsy azony izay ataony.

Ho fampitandremana faharoa, ity misy sombiny avy amin'ny antontan-taratasy etsy ambony:

Tsy soso-kevitra ny hampitombo ny fahatsiarovan'ny JVM mihoatra ny soatoavina atolotra amin'ny fiezahana hanatsara ny fampisehoana. Mety hisy vokany mifanohitra amin'izany izany, ka miteraka asa tsy ilaina ho an'ny rafitra miasa.

Administrator password

    nexus_admin_password: 'changeme'

Ny tenimiafina kaonty "admin" ho an'ny fananganana. Izany dia miasa amin'ny fametrahana default voalohany ihany. Azafady, jereo ny [Hanova ny tenimiafina admin aorian'ny fametrahana voalohany](# change-admin-password-after-first-install) raha te hanova izany ianao amin'ny fampiasana andraikitra.

Amporisihina mafy ny tsy hitahiry ny tenimiafinao amin'ny lahatsoratra mazava ao amin'ny playbook, fa hampiasa [ansible-vault encryption] (https://docs.ansible.com/ansible/latest/user_guide/vault.html) (na inline na anaty rakitra misaraka feno oh: include_vars)

Fidirana tsy mitonona anarana amin'ny alàlan'ny default

    nexus_anonymous_access: false

Ny fidirana tsy mitonona anarana dia esorina amin'ny alàlan'ny default. Vakio bebe kokoa momba ny fidirana tsy mitonona anarana.

Anarana mpampiantrano

    nexus_public_hostname: 'nexus.vm'
    nexus_public_scheme: https

Ny anaran-tsehatra sy tetik'asa mahafeno fepetra (https na http) izay ahitana ny ohatra Nexus ho an'ny mpanjifany.

Fidirana API ho an'ity andraikitra ity

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

Ireo fari-pahalalana ireo dia mifehy ny fomba ifandraisan'ny anjara amin'ny Nexus API amin'ny famatsiana.
Ho an'ny mpampiasa efa mandroso ihany. Mety tsy tianao ny hanova an'ireo fanovana ireo

Mametraka proxy mivadika

    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

hametraka SSL Reverse Proxy.
Mba hanaovana izany dia mila mametraka httpd. Fanamarihana: rehefa ho httpd_setup_enable mametraka sandatrue, fifandraisana nexus 127.0.0.1:8081, araka izany tsy azo idirana mivantana amin'ny alàlan'ny seranan-tsambo HTTP 8081 avy amin'ny adiresy IP ivelany.

Ny anaran'ny mpampiantrano default ampiasaina dia nexus_public_hostname. Raha mila anarana hafa ianao noho ny antony sasany dia azonao atao ny mametraka httpd_server_name misy dikany hafa.

С httpd_copy_ssl_files: true (amin'ny alàlan'ny default) ireo mari-pankasitrahana etsy ambony dia tokony hisy ao amin'ny lahatahiry playbook ary hadika amin'ny mpizara ary amboarina amin'ny apache.

Raha te hampiasa ny mari-pankasitrahana efa misy amin'ny mpizara ianao dia apetraho httpd_copy_ssl_files: false ary manome ireto variables manaraka ireto:

    # 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 dia azo atao ary tokony havela tsy apetraka raha tsy te-hanamboatra ny rakitra rojo ianao

    httpd_default_admin_email: "[email protected]"

Mametraha adiresy mailaka admin default

LDAP Configuration

Ny fifandraisana LDAP sy ny sehatry ny fiarovana dia tsy mandeha amin'ny alàlan'ny default

    nexus_ldap_realm: false
    ldap_connections: []

Ireo singa mifandraika amin'ny LDAP, ny singa tsirairay dia toy izao:

    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

Ohatra fanefena LDAP ho an'ny fanamarinana tsy mitonona anarana (famatotra tsy mitonona anarana), izany koa dia fanefena "kely indrindra":

    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'

Ohatra fanefena LDAP ho an'ny fanamarinana tsotra (mampiasa kaonty DSA):

    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

Ohatra fanefena LDAP ho an'ny fanamarinana tsotra (mampiasa kaonty DSA) + vondrona voasokajy ho anjara:

    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

Ohatra fanefena LDAP ho an'ny fanamarinana tsotsotra (mampiasa kaonty DSA) + vondrona voasokajy ho anjara mavitrika:

    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'

TOMBONTSOAM

    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

Lisitry ny NAHAZO TOMBONTSOA ho an'ny fanovana. Jereo ny antontan-taratasy sy ny GUI mba hijerena ny fari-piainana tokony hapetraka arakaraka ny karazana tombontsoa.

Ireo singa ireo dia atambatra miaraka amin'ireto sanda mahazatra manaraka ireto:

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

Andraikitra (ao anaty Nexus no dikan'izany)

    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

Lisitry ny ANJARA ASA ho an'ny fanovana.

mpampiasa

    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

Lisitr'ireo mpampiasa/kaonty eo an-toerana (tsy LDAP) hatsangana amin'ny nexus.

Lisitry ny mpampiasa/kaonty eo an-toerana (tsy LDAP) hoforonina ao amin'ny Nexus.

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

Ldap sarintanin'ny mpampiasa/asa. FANJAKANA absent dia hanaisotra andraikitra amin'ny mpampiasa efa misy raha toa ka efa misy izany.
Tsy voafafa ny mpampiasa Ldap. Ny fiezahana hametraka anjara ho an'ny mpampiasa tsy misy dia hiteraka hadisoana.

Mpifidy votoaty

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

Raha mila fanazavana fanampiny momba ny mpifidy votoaty dia jereo tahirin-kevitra.

Raha hampiasa ny mpifidy votoaty dia ampio tombontsoa vaovao amin'ny type: repository-content-selector ary mifandraikacontentSelector

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

Blobstores sy repository

    nexus_delete_default_repos: false

Fafao ny repository ao amin'ny nexus install initial default configuration. Ity dingana ity dia tanterahina amin'ny fametrahana voalohany (rehefa nexus_data_dir hita fa foana).

Esory ny trano fitehirizam-bokatra amin'ny config default ho an'ny Nexus. Ity dingana ity dia atao mandritra ny fametrahana voalohany (rehefa nexus_data_dir foana).

    nexus_delete_default_blobstore: false

Fafao ny blobstore default amin'ny nexus install initial default configuration. Tsy azo atao izany raha tsy nexus_delete_default_repos: true ary ny repository voarindra rehetra (jereo eto ambany) dia manana mazava blob_store: custom. Ity dingana ity dia tanterahina amin'ny fametrahana voalohany (rehefa nexus_data_dir hita fa foana).

Ny fanesorana ny fitehirizana blob (artifacts binary) dia tsy mandeha amin'ny alàlan'ny default amin'ny fanovana voalohany. Mba hanesorana ny fitehirizana blob (artifact binary), vonoy nexus_delete_default_repos: true. Ity dingana ity dia atao mandritra ny fametrahana voalohany (rehefa nexus_data_dir foana).

    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 mamorona. Tsy azo havaozina aorian'ny famoronana voalohany ny lalan'ny blobstore sy ny blobstore fitehirizana (izay tsy hiraharaha ny fanavaozana eto amin'ny famatsiana indray).

Ny fanamafisana ny blobstore amin'ny S3 dia omena ho fanamorana ary tsy ao anatin'ny fitsapana mandeha ho azy izay ataontsika amin'ny travis. Mariho fa ny fitehirizana amin'ny S3 dia atolotra ho an'ny tranga napetraka ao amin'ny AWS ihany.

zavaboary Blobstores. Ny lalan'ny fitahirizana sy ny tahiry fitahirizana dia tsy azo havaozina aorian'ny famoronana voalohany (izay rehetra fanavaozana eto dia tsy horaharahaina rehefa apetraka indray).

Ny fametrahana fitahirizana blob amin'ny S3 dia omena ho fanamorana. Mariho fa ny fitahirizana S3 dia atolotra ho an'ny tranga napetraka ao amin'ny AWS ihany.

    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

Etsy ambony dia misy ohatra config mpizara proxy Maven.

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

Maven fampiantranoana repository configuration. Ny config cache négatif dia tsy azo atao ary tsy maintsy apetraka amin'ireo soatoavina etsy ambony raha esorina.

fanahafana fampiantranoana repository Maven. Ny fanefena cache négatif (-1) dia tsy azo atao ary tsy ho voatondro amin'ireo soatoavina etsy ambony raha tsy voafaritra.

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

fanahafana vondrona Maven.

Ireo karazana tahiry telo rehetra dia atambatra miaraka amin'ireto soatoavina manaraka ireto:

    _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 ary karazana tahiry yum:
jereo defaults/main.yml ho an'ireto safidy ireto:

Docker, Pypi, Raw, Rubygems, Bower, NPM, Git-LFS ary ny fitehirizam-bokatra yum dia tsy mandeha amin'ny alàlan'ny default:
jereo defaults/main.yml ho an'ireto safidy ireto:

      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

Azafady, azafady fa mety ilainao ny mamela ny sehatra fiarovana sasany raha te hampiasa karazana tahiry hafa ankoatra ny maven ianao. Diso izany raha ny default

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 azo ampiasaina ihany koa

nexus_rut_auth_realm: true

ary azo amboarina amin'ny alalan'ny famaritana ny lohateny

nexus_rut_auth_header: "CUSTOM_HEADER"

Asa voalahatra

    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"

Asa voalahatra ho an'ny fanovana. typeId ary asa manokanataskProperties/booleanTaskProperties azonao vinaniana na:

  • avy amin'ny hierarchy karazana Java org.sonatype.nexus.scheduling.TaskDescriptorSupport
  • manamarina ny endrika famoronana asa HTML amin'ny navigateur
  • avy amin'ny fijerena ny fangatahana AJAX ao amin'ny navigateur rehefa manamboatra asa tanana.

Ny fananana asa dia tsy maintsy ambara ao amin'ny bloc yaml marina arakaraka ny karazana azy:

  • taskProperties ho an'ny toetran'ny tady rehetra (izany hoe anaran-drakitra, anaran-drakitra, fe-potoana...).
  • booleanTaskProperties ho an'ny fananana lojika rehetra (izany hoe ny boaty fisavana indrindra ao amin'ny GUI amin'ny asa famoronana nexus).

Backups

      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)

Tsy azo amboarina ny backup raha tsy miova ianao nexus_backup_configure в true.
Amin'ity tranga ity, ny asa soratana voalahatra dia hamboarina amin'ny Nexus
amin'ny elanelam-potoana voalaza ao nexus_backup_cron (default 21:00 isan'andro).
Jereo ny [modely groovy ho an'ity asa ity](templates/backup.groovy.j2) raha mila fanazavana fanampiny.
Tsy miankina amin'ny hafa io asa voalahatra io nexus_scheduled_tasksizay ianao
ambarao ao amin'ny bokinao.

Raha te hanodina/hamafa ny backups ianao dia apetraho nexus_backup_rotate: true ary amboary ny isan'ny backup tianao hotehirizina ampiasaina nexus_backup_keep_rotations (default 4).

Rehefa mampiasa rotation ianao, raha te hitahiry habaka kapila fanampiny ianao mandritra ny fizotran'ny backup,
Azonao atao ny mametraka nexus_backup_rotate_first: true. Izany dia hanendry mialoha fihodinana/famafana alohan'ny backup. Amin'ny alàlan'ny default, ny fihodinana dia mitranga aorian'ny famoronana backup. Mariho fa amin'ity tranga ity dia ny backups taloha
ho voafafa alohan'ny hanaovana ny backup ankehitriny.

Fomba fanarenana

Manaova playbook miaraka amin'ny parameter -e nexus_restore_point=<YYYY-MM-dd-HH-mm-ss>
(ohatra, 2017-12-17-21-00-00 ny 17 Desambra 2017 amin'ny 21:00

Esory ny nexus

Fampitandremana: Izany dia hamafa tanteraka ny angonao ankehitriny. Ataovy azo antoka fa manao backup aloha raha ilaina

Mampiasà miovaova nexus_purgeraha mila manomboka manomboka amin'ny scratch ianao ary mametraka indray ny ohatra nexus miaraka amin'ny angon-drakitra rehetra nesorina.

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

Hanova ny tenimiafina mpitantana aorian'ny fametrahana voalohany

    nexus_default_admin_password: 'admin123'

Tsy tokony hovana ao amin'ny bokinao izany. Ity fari-pahalalana ity dia feno ny tenimiafina admin Nexus default rehefa napetraka voalohany ary manome antoka fa afaka manova ny tenimiafina admin izahay nexus_admin_password.

Raha te hanova ny tenimiafina administratera aorian'ny fametrahana voalohany ianao dia azonao atao ny manova azy vetivety amin'ny tenimiafina taloha avy amin'ny tsipika baiko. Taorian'ny fiovana nexus_admin_password ao amin'ny bokinao dia azonao atao ny mihazakazaka:

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

Fantsona Telegram amin'ny Nexus Sonatype: https://t.me/ru_nexus_sonatype

Ireo mpampiasa voasoratra anarana ihany no afaka mandray anjara amin'ny fanadihadiana. HiditraPlease.

Inona avy ireo tahiry artifact ampiasainao?

  • Maimaim-poana ny Sonatype Nexus

  • Nandoa vola ny Sonatype Nexus

  • Maimaim-poana ny artifactory

  • Nandoa vola ny artifactory

  • Harbor

  • pulp

Mpampiasa 9 no nifidy. Mpampiasa 3 no nifady.

Source: www.habr.com

Add a comment