Kod yondashuvi sifatida infratuzilma yordamida Nexus Sonatype o'rnatish va sozlash

Sonatype Nexus - ishlab chiquvchilar Java (Maven) bog'liqliklari, Docker, Python, Ruby, NPM, Bower tasvirlari, RPM paketlari, gitlfs, Apt, Go, Nuget proksi-serverlari, saqlashlari va boshqarishlari va dasturiy xavfsizligini tarqatishlari mumkin bo'lgan o'rnatilgan platformadir.

Nega sizga Sonatype Nexus kerak?

  • Shaxsiy artefaktlarni saqlash uchun;
  • Internetdan yuklab olingan artefaktlarni keshlash uchun;

Asosiy Sonatype Nexus to'plamida qo'llab-quvvatlanadigan artefaktlar:

  • Java, Maven (jar)
  • Docker
  • Python (pip)
  • Ruby (tovar)
  • NPM
  • Bowers
  • Yum (aylanma daqiqa)
  • gitlfs
  • xom
  • Apt (deb)
  • Go
  • Nuget

Hamjamiyat tomonidan qo'llab-quvvatlanadigan artefaktlar:

  • yaratmoq
  • Conan
  • CPAN
  • ELPA
  • dubulg'a
  • P2
  • R

yordamida Sonatype Nexus o'rnatish https://github.com/ansible-ThoTeam/nexus3-oss

talablar

  • Internetda ansibledan foydalanish haqida o'qing.
  • Ansible o'rnating pip install ansible o'yin kitobi ishlaydigan ish stantsiyasida.
  • O'rnatish geerlingguy.java o'yin kitobi ishlaydigan ish stantsiyasida.
  • O'rnatish geerlingguy.apache o'yin kitobi ishlaydigan ish stantsiyasida.
  • Bu rol CentOS 7, Ubuntu Xenial (16.04) va Bionic (18.04), Debian Jessie va Stretch tizimlarida sinovdan oʻtgan.
  • jmespath Kutubxona o'yin kitobi ishlayotgan ish stantsiyasiga o'rnatilishi kerak. O'rnatish uchun: sudo pip install -r requirements.txt
  • O'yin kitobi faylini (quyidagi misol) nexus.yml fayliga saqlang
  • Nexus o'rnatishni ishga tushiring ansible-playbook -i host nexus.yml

Maven (java), Docker, Python, Ruby, NPM, Bower, RPM va gitlfs omborlari bilan LDAPsiz nexus o'rnatish uchun ansible-playbook misoli.

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

Skrinshotlar:

Kod yondashuvi sifatida infratuzilma yordamida Nexus Sonatype o'rnatish va sozlash

Kod yondashuvi sifatida infratuzilma yordamida Nexus Sonatype o'rnatish va sozlash

O'zgaruvchan rollar

Rol o'zgaruvchilari

Standart qiymatlarga ega o'zgaruvchilar (qarang default/main.yml):

Umumiy o'zgaruvchilar

    nexus_version: ''
    nexus_timezone: 'UTC'

Odatiy bo'lib, rol Nexusning eng so'nggi mavjud versiyasini o'rnatadi. O'zgaruvchini o'zgartirish orqali versiyani tuzatishingiz mumkin nexus_version. Mavjud versiyalarni ko'ring https://www.sonatype.com/download-oss-sonatype.

Agar siz yangiroq versiyaga o'tsangiz, rol Nexus o'rnatishingizni yangilashga harakat qiladi.

Если вы используете более старую версию Nexus, чем последняя, вы должны убедиться, что не используете функции, которые недоступны в установленном выпуске (например, размещенние yum репозиториев доступно для nexus больше чем 3.8.0, git lfs repo для nexus больше чем 3.3.0 va hokazo.)

nexus timezone nexus_scheduled vazifalari uchun quyidagi cron ifodalari bilan birgalikda foydali bo'lishi mumkin bo'lgan Java vaqt mintaqasining nomi.

Nexus porti va kontekst yo'li

    nexus_default_port: 8081
    nexus_default_context_path: '/'

Java ulanish jarayonining port va kontekst yo'li. nexus_default_context_path o'rnatilganda qiyshiq chiziq bo'lishi kerak, masalan: nexus_default_context_path: '/nexus/'.

Nexus OS foydalanuvchisi va guruhi

    nexus_os_group: 'nexus'
    nexus_os_user: 'nexus'

Nexus fayllariga egalik qilish va xizmatni ishga tushirish uchun foydalanilgan foydalanuvchi va guruh, agar ulardan biri yo'q bo'lsa, rol tomonidan yaratiladi.

    nexus_os_user_home_dir: '/home/nexus'

Nexus foydalanuvchisi uchun standart uy katalogini oʻzgartirishga ruxsat bering

Nexus misol kataloglari

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

Nexus kataloglari.

  • nexus_installation_dir o'rnatilgan bajariladigan fayllarni o'z ichiga oladi
  • nexus_data_dir barcha konfiguratsiyalar, omborlar va yuklab olingan artefaktlarni o'z ichiga oladi. Maxsus blobstore yo'llari nexus_data_dir moslashtirilgan bo'lishi mumkin, pastga qarang nexus_blobstores.
  • nexus_tmp_dir barcha vaqtinchalik fayllarni o'z ichiga oladi. Redhat uchun standart yoʻl dan koʻchirildi /tmp avtomatik tozalash tartib-qoidalari bilan yuzaga kelishi mumkin bo'lgan muammolarni bartaraf etish. Qarang: №168.

Nexus JVM xotirasidan foydalanishni sozlash

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

Bular Nexus uchun standart sozlamalardir. Iltimos, ushbu qiymatlarni o'zgartirmang Agar o'qimagan bo'lsangiz nexus tizim talablari xotira bo'limi va ular nima qilayotganlarini tushunmaydilar.

Ikkinchi ogohlantirish sifatida, yuqoridagi hujjatdan parcha:

Ishlashni yaxshilash uchun JVM yig'ma xotirasini tavsiya etilgan qiymatlardan ortiq oshirish tavsiya etilmaydi. Bu aslida teskari ta'sirga ega bo'lishi mumkin, natijada operatsion tizim uchun keraksiz ishlar.

Administrator paroli

    nexus_admin_password: 'changeme'

O'rnatish uchun "administrator" hisobi paroli. Bu faqat birinchi standart o'rnatishda ishlaydi. Rol yordamida uni keyinroq oʻzgartirmoqchi boʻlsangiz, [Birinchi oʻrnatishdan keyin administrator parolini oʻzgartirish](# change-admin-password-after-first-install) ga qarang.

Parolni o'yin kitobida aniq matnda saqlamaslik, balki [ansible-vault encryption] dan foydalanish tavsiya etiladi (https://docs.ansible.com/ansible/latest/user_guide/vault.html) (inline yoki alohida faylda, masalan, include_vars bilan yuklangan)

Odatiy bo'lib anonim kirish

    nexus_anonymous_access: false

Anonim kirish sukut bo'yicha o'chirilgan. haqida ko'proq o'qing anonim kirish.

Umumiy xost nomi

    nexus_public_hostname: 'nexus.vm'
    nexus_public_scheme: https

To'liq malakali domen nomi va sxemasi (https yoki http), uning ostida Nexus namunasi o'z mijozlari uchun mavjud bo'ladi.

Ushbu rol uchun API kirish

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

Bu oʻzgaruvchilar rolni tayyorlash uchun Nexus APIʼga qanday ulanishini boshqaradi.
Faqat ilg'or foydalanuvchilar uchun. Ehtimol, siz ushbu standart sozlamalarni o'zgartirishni xohlamaysiz

Teskari proksi-serverni sozlash

    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

O'rnatish SSL teskari proksi.
Buning uchun httpd-ni o'rnatishingiz kerak. Eslatma: qachon uchun httpd_setup_enable qiymatni belgilangtrue, nexus kontaktlari 127.0.0.1:8081, shunday qilib yo'q tashqi IP manzilidan HTTP port 8081 orqali to'g'ridan-to'g'ri kirish mumkin.

Amaldagi standart xost nomi nexus_public_hostname. Agar biron sababga ko'ra sizga turli nomlar kerak bo'lsa, sozlashingiz mumkin httpd_server_name boshqa ma'no bilan.

С httpd_copy_ssl_files: true (sukut bo'yicha) yuqoridagi sertifikatlar o'yin kitobi katalogida mavjud bo'lishi kerak va ular serverga ko'chiriladi va apache-da sozlanadi.

Agar siz serverda mavjud sertifikatlardan foydalanmoqchi bo'lsangiz, o'rnating httpd_copy_ssl_files: false va quyidagi o'zgaruvchilarni taqdim eting:

    # 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 ixtiyoriy va agar zanjir faylini sozlashni xohlamasangiz, sozlanmagan holda qoldirilishi kerak

    httpd_default_admin_email: "[email protected]"

Standart administrator elektron pochta manzilini o'rnating

LDAP konfiguratsiyasi

LDAP ulanishlari va xavfsizlik sohasi sukut bo'yicha o'chirib qo'yilgan

    nexus_ldap_realm: false
    ldap_connections: []

LDAP ulanishlari, har bir element quyidagicha ko'rinadi:

    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

Anonim autentifikatsiya (anonim ulanish) uchun LDAP konfiguratsiyasiga misol, bu ham "minimal" konfiguratsiya:

    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'

Oddiy autentifikatsiya uchun LDAP konfiguratsiyasiga misol (DSA hisobi yordamida):

    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

Oddiy autentifikatsiya qilish uchun LDAP konfiguratsiyasiga misol (DSA hisob qaydnomasi yordamida) + rollar sifatida ajratilgan guruhlar:

    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

Oddiy autentifikatsiya qilish uchun LDAP konfiguratsiyasiga misol (DSA hisob qaydnomasi yordamida) + rollar sifatida dinamik ravishda xaritalangan guruhlar:

    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'

Imtiyoz

    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

ro'yxat imtiyozlar sozlamalar uchun. Imtiyoz turiga qarab qaysi o'zgaruvchilar o'rnatilishi kerakligini tekshirish uchun hujjatlar va GUI-ga qarang.

Ushbu elementlar quyidagi standart qiymatlar bilan birlashtirilgan:

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

Rollar (Nexus ichida bu degani)

    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

ro'yxat rollar sozlamalar uchun.

foydalanuvchilar

    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

Nexusda yaratish uchun mahalliy (LDAP bo'lmagan) foydalanuvchilar/hisoblar ro'yxati.

Nexus'da yaratish uchun mahalliy (LDAP bo'lmagan) foydalanuvchilar/hisoblar ro'yxati.

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

Foydalanuvchilar/rollarni Ldap xaritalash. Davlat absent Agar mavjud bo'lsa, mavjud foydalanuvchidan rollarni olib tashlaydi.
Ldap foydalanuvchilari o'chirilmaydi. Mavjud bo'lmagan foydalanuvchi uchun rol o'rnatishga urinish xatolikka olib keladi.

Kontent selektorlari

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

Kontent selektori haqida ko'proq ma'lumot olish uchun qarang Hujjatlar.

Kontent selektoridan foydalanish uchun bilan yangi imtiyoz qo'shing type: repository-content-selector va tegishlicontentSelector

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

Blobstores va omborlar

    nexus_delete_default_repos: false

Nexus install boshlang'ich standart konfiguratsiyasidan omborlarni o'chiring. Ushbu qadam faqat birinchi marta o'rnatilganda amalga oshiriladi (qachon nexus_data_dir bo'shligi aniqlandi).

Nexus uchun standart standart konfiguratsiyadan omborlarni olib tashlash. Ushbu qadam faqat birinchi o'rnatish paytida amalga oshiriladi (qachon nexus_data_dir bo'sh).

    nexus_delete_default_blobstore: false

Nexus install boshlang'ich standart konfiguratsiyasidan standart blobstore-ni o'chiring. Bu faqat agar amalga oshirilishi mumkin nexus_delete_default_repos: true va barcha konfiguratsiya qilingan omborlar (pastga qarang) aniq xususiyatga ega blob_store: custom. Ushbu qadam faqat birinchi marta o'rnatilganda amalga oshiriladi (qachon nexus_data_dir bo'shligi aniqlandi).

Blob xotirasini (ikkilik artefaktlarni) olib tashlash dastlabki konfiguratsiyadan sukut bo'yicha o'chirib qo'yilgan. Blob xotirasini (ikkilik artefaktlarni) olib tashlash uchun o'chiring nexus_delete_default_repos: true. Ushbu qadam faqat birinchi o'rnatish paytida amalga oshiriladi (qachon nexus_data_dir bo'sh).

    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 yaratmoq. Blobstore yo'lini va blok do'konini dastlabki yaratilgandan so'ng yangilab bo'lmaydi (qayta ta'minlashda bu yerdagi har qanday yangilanish e'tiborga olinmaydi).

Blobstore-ni S3-da sozlash qulaylik sifatida taqdim etilgan va biz travisda o'tkazadigan avtomatlashtirilgan testlarning bir qismi emas. Esda tutingki, S3-da saqlash faqat AWS-da o'rnatilgan misollar uchun tavsiya etiladi.

Yaratilish Blobstores. Saqlash yo'li va saqlash omborini dastlabki yaratilgandan keyin yangilab bo'lmaydi (qayta o'rnatilganda bu yerdagi har qanday yangilanish e'tiborga olinmaydi).

S3 da blob xotirasini o'rnatish qulaylik sifatida taqdim etiladi. Esda tutingki, S3 xotirasi faqat AWS-da o'rnatilgan misollar uchun tavsiya etiladi.

    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

Yuqorida konfiguratsiyaga misol keltirilgan proksi-server Maven

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

Maven joylashtirilgan omborlar konfiguratsiya. Salbiy kesh konfiguratsiyasi ixtiyoriy va agar o'tkazib yuborilsa, yuqoridagi qiymatlarga sukut bo'yicha o'rnatiladi.

Konfiguratsiya joylashtirilgan omborlar Maven. Salbiy kesh konfiguratsiyasi (-1) ixtiyoriy va agar ko'rsatilmagan bo'lsa, yuqoridagi qiymatlarga sukut bo'yicha bo'ladi.

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

Konfiguratsiya guruhlari Maven

Barcha uchta ombor turlari quyidagi standart qiymatlar bilan birlashtirilgan:

    _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 va yum omborlari turlari:
ko'rish defaults/main.yml ushbu variantlar uchun:

Docker, Pypi, Raw, Rubygems, Bower, NPM, Git-LFS va yum omborlari sukut bo'yicha o'chirib qo'yilgan:
Qarang defaults/main.yml ushbu variantlar uchun:

      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

Shuni esda tutingki, mavendan tashqari boshqa turdagi omborlardan foydalanmoqchi bo'lsangiz, ma'lum xavfsizlik doiralarini yoqishingiz kerak bo'lishi mumkin. Bu sukut bo'yicha noto'g'ri

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

Masofaviy foydalanuvchi hududi yordamida ham yoqish mumkin

nexus_rut_auth_realm: true

va sarlavhani belgilash orqali sozlash mumkin

nexus_rut_auth_header: "CUSTOM_HEADER"

Rejalashtirilgan vazifalar

    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"

Rejalashtirilgan vazifalar sozlamalar uchun. typeId va aniq vazifataskProperties/booleanTaskProperties siz ham taxmin qilishingiz mumkin:

  • Java turi ierarxiyasidan org.sonatype.nexus.scheduling.TaskDescriptorSupport
  • brauzeringizda HTML topshiriq yaratish formasini tekshirish
  • vazifani qo'lda sozlashda brauzerda AJAX so'rovlarini ko'rishdan.

Vazifa xususiyatlari ularning turiga qarab to'g'ri yaml blokida e'lon qilinishi kerak:

  • taskProperties barcha satr xususiyatlari uchun (ya'ni, ombor nomlari, ombor nomlari, vaqt davrlari ...).
  • booleanTaskProperties barcha mantiqiy xususiyatlar uchun (ya'ni, asosan, nexus yaratish vazifasining GUIdagi belgilash katakchalari).

Zaxira nusxalari

      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)

Zaxiralash siz almashtirilguningizcha sozlanmaydi nexus_backup_configure в true.
Bunday holda, rejalashtirilgan skript vazifasi Nexus da ishlash uchun sozlanadi
da belgilangan oraliqda nexus_backup_cron (standart har kuni 21:00).
Tafsilotlar uchun [ushbu vazifa uchun ajoyib shablon](shablonlar/backup.groovy.j2) ga qarang.
Bu rejalashtirilgan vazifa boshqalardan mustaqil nexus_scheduled_tasksqaysi siz
o'yin kitobingizda e'lon qiling.

Agar siz zaxira nusxalarini aylantirish/o'chirishni xohlasangiz, o'rnating nexus_backup_rotate: true va saqlamoqchi bo'lgan zaxiralar sonini sozlang nexus_backup_keep_rotations (standart 4).

Aylanishdan foydalanganda, zaxiralash jarayonida qo'shimcha disk maydonini tejashni istasangiz,
Siz o'rnatishingiz mumkin nexus_backup_rotate_first: true. Bu zaxiralashdan oldin oldingi aylantirish/o‘chirishni sozlaydi. Odatiy bo'lib, aylanish zaxira nusxasi yaratilgandan keyin sodir bo'ladi. Iltimos, bu holda eski zaxira nusxalarini unutmang
joriy zaxira nusxasi amalga oshirilgunga qadar o'chiriladi.

Qayta tiklash jarayoni

Parametr bilan o'yin kitobini ishga tushiring -e nexus_restore_point=<YYYY-MM-dd-HH-mm-ss>
(masalan, 2017-12-17-21-00-00, 17-yil 2017-dekabr, soat 21:00

Nexus olib tashlanmoqda

Ogohlantirish: Bu sizning joriy ma'lumotlaringizni butunlay o'chirib tashlaydi. Agar kerak bo'lsa, avvalroq zaxira nusxasini yaratganingizga ishonch hosil qiling

O'zgaruvchidan foydalaning nexus_purgeagar siz noldan qayta ishga tushirishingiz va barcha ma'lumotlar olib tashlangan holda nexus misolini qayta o'rnatishingiz kerak bo'lsa.

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

Birinchi o'rnatishdan keyin administrator parolini o'zgartiring

    nexus_default_admin_password: 'admin123'

Bu sizning o'yin kitobingizda o'zgartirilmasligi kerak. Bu oʻzgaruvchi birinchi marta oʻrnatilganda standart Nexus administrator paroli bilan toʻldiriladi va administrator parolini quyidagiga oʻzgartirishimiz mumkinligini taʼminlaydi. nexus_admin_password.

Agar siz birinchi o'rnatishdan keyin administrator parolini o'zgartirmoqchi bo'lsangiz, uni buyruq satridan vaqtincha eski parolga o'zgartirishingiz mumkin. O'zgartirishdan keyin nexus_admin_password o'yin kitobida siz quyidagilarni ishlatishingiz mumkin:

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

Nexus Sonatype-dagi Telegram kanali: https://t.me/ru_nexus_sonatype

So'rovda faqat ro'yxatdan o'tgan foydalanuvchilar ishtirok etishlari mumkin. tizimga kirishiltimos.

Qanday artefakt omborlaridan foydalanasiz?

  • Sonatype Nexus bepul

  • Sonatype Nexus to'lanadi

  • Artifactory bepul

  • Artifaktor to'langan

  • Liman

  • Xamiri

9 nafar foydalanuvchi ovoz berdi. 3 nafar foydalanuvchi betaraf qolgan.

Manba: www.habr.com

a Izoh qo'shish