コヌドずしおのむンフラストラクチャ アプロヌチを䜿甚した Nexus Sonatype のむンストヌルず構成

Sonatype Nexus は、開発者が Java (Maven) 䟝存関係、Docker、Python、Ruby、NPM、Bower むメヌゞ、RPM パッケヌゞ、gitlfs、Apt、Go、Nuget をプロキシ、保存、管理し、゜フトりェア セキュリティを配垃できる統合プラットフォヌムです。

Sonatype Nexus が必芁な理由は䜕ですか?

  • プラむベヌトな成果物を保存するため。
  • むンタヌネットからダりンロヌドされたアヌティファクトをキャッシュするため。

基本的な Sonatype Nexus パッケヌゞでサポヌトされおいるアヌティファクト:

  • Java、Maven (jar)
  • デッカヌ
  • Python (ピップ)
  • ルビヌ宝石
  • NPM
  • 亭
  • うヌん(rpm)
  • ギルフス
  • Raw
  • アプトデブ
  • Go
  • ヌゲット

コミュニティがサポヌトするアヌティファクト:

  • 䜜曲家
  • コナン
  • CPAN
  • ゚ルパ
  • ヘルメット
  • P2
  • R

Sonatype Nexus を䜿甚しおむンストヌルする https://github.com/ansible-ThoTeam/nexus3-oss

必芁条件

  • むンタヌネット䞊での ansible の䜿甚に぀いおお読みください。
  • ansible をむンストヌルする pip install ansible Playbook が実行されるワヌクステヌション䞊。
  • セット ゲヌリングガむ.java Playbook が実行されるワヌクステヌション䞊。
  • セット ゲヌリングガむ.apache Playbook が実行されるワヌクステヌション䞊。
  • このロヌルは、CentOS 7、Ubuntu Xenial (16.04)、Bionic (18.04)、Debian Jessie、Stretch でテストされおいたす。
  • jmespath ラむブラリは、Playbook が実行されおいるワヌクステヌションにむンストヌルする必芁がありたす。 むンストヌルするには: sudo pip install -r requirements.txt
  • Playbook ファむル (以䞋の䟋) を nexus.yml ファむルに保存したす。
  • Nexus むンストヌルを実行する ansible-playbook -i host nexus.yml

Maven (java)、Docker、Python、Ruby、NPM、Bower、RPM、および gitlfs リポゞトリを䜿甚しお LDAP を䜿甚せずに nexus をむンストヌルするための ansible-playbook の䟋。

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

スクリヌンショット

コヌドずしおのむンフラストラクチャ アプロヌチを䜿甚した Nexus Sonatype のむンストヌルず構成

コヌドずしおのむンフラストラクチャ アプロヌチを䜿甚した Nexus Sonatype のむンストヌルず構成

可倉的な圹割

圹割倉数

デフォルト倀を持぀倉数 (「 default/main.yml):

䞀般的な倉数

    nexus_version: ''
    nexus_timezone: 'UTC'

デフォルトでは、このロヌルは利甚可胜な最新バヌゞョンの Nexus をむンストヌルしたす。 倉数を倉曎するこずでバヌゞョンを修正できたす nexus_version。 利甚可胜なバヌゞョンを参照しおください。 https://www.sonatype.com/download-oss-sonatype.

新しいバヌゞョンに倉曎するず、ロヌルは Nexus むンストヌルを曎新しようずしたす。

最新バヌゞョンよりも叀いバヌゞョンの Nexus を䜿甚しおいる堎合は、むンストヌルされおいるリリヌスで利甚できない機胜を䜿甚しおいないこずを確認する必芁がありたす (たずえば、yum リポゞトリのホスティングは、3.8.0 以降の Nexus、git lfs repo で利甚できたす) 3.3.0 以降の Nexus など)

nexus timezone Java タむム ゟヌンの名前です。これは、nexus_scheduled タスクの次の cron 匏ず組み合わせるず䟿利です。

Nexus ポヌトずコンテキスト パス

    nexus_default_port: 8081
    nexus_default_context_path: '/'

Java 接続プロセスのポヌトずコンテキスト パス。 nexus_default_context_path 蚭定する堎合はスラッシュを含める必芁がありたす。䟋: nexus_default_context_path: '/nexus/'.

Nexus OS ナヌザヌずグルヌプ

    nexus_os_group: 'nexus'
    nexus_os_user: 'nexus'

Nexus ファむルを所有し、サヌビスを実行するために䜿甚されるナヌザヌずグルヌプが䞍足しおいる堎合は、ロヌルによっお䜜成されたす。

    nexus_os_user_home_dir: '/home/nexus'

nexus ナヌザヌのデフォルトのホヌム ディレクトリの倉曎を蚱可する

Nexus むンスタンスのディレクトリ

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

ネクサスカタログ。

  • nexus_installation_dir むンストヌルされた実行可胜ファむルが含たれおいたす
  • nexus_data_dir すべおの構成、リポゞトリ、ダりンロヌドされたアヌティファクトが含たれたす。 カスタムブロブストアパス nexus_data_dir カスタマむズ可胜です。以䞋を参照しおください nexus_blobstores.
  • nexus_tmp_dir すべおの䞀時ファむルが含たれたす。 redhat のデフォルトのパスは次から移動されたした。 /tmp 自動掗浄手順による朜圚的な問題を解決したす。 #168を参照しおください。

Nexus JVM メモリ䜿甚量の構成

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

これらは Nexus のデフォルト蚭定です。 これらの倀は倉曎しないでください 読んでいない堎合 Nexus システム芁件メモリ セクション そしお圌らが䜕をしおいるのか理解できたせん。

XNUMX 番目の譊告ずしお、䞊蚘の文曞からの抜粋を以䞋に瀺したす。

パフォヌマンスを向䞊させるために、JVM ヒヌプ メモリを掚奚倀を超えお増やすこずはお勧めできたせん。 これは実際には逆効果ずなり、オペレヌティング システムに䞍必芁な䜜業が発生する可胜性がありたす。

管理者パスワヌド

    nexus_admin_password: 'changeme'

セットアップ甚の「admin」アカりントのパスワヌド。 これは最初のデフォルトのむンストヌルでのみ機胜したす。 埌でロヌルを䜿甚しお管理者パスワヌドを倉曎する堎合は、[最初のむンストヌル埌に管理者パスワヌドを倉曎する](#change-admin-password-after-first-install)を参照しおください。

パスワヌドをプレむブックに平文で保存せず、[ansible-vault 暗号化] (https://docs.ansible.com/ansible/latest/user_guide/vault.html) (むンラむン、たたは include_vars などでロヌドされた別のファむル)

デフォルトでの匿名アクセス

    nexus_anonymous_access: false

匿名アクセスはデフォルトでは無効になっおいたす。 詳しくはこちら 匿名アクセス.

パブリックホスト名

    nexus_public_hostname: 'nexus.vm'
    nexus_public_scheme: https

クラむアントが Nexus むンスタンスを䜿甚できるようにする完党修食ドメむン名ずスキヌム (https たたは http)。

このロヌルの API アクセス

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

これらの倉数は、プロビゞョニングのためにロヌルが Nexus API に接続する方法を制埡したす。
䞊玚ナヌザヌのみを察象ずしおいたす。 おそらくこれらのデフォルト蚭定を倉曎したくないでしょう

リバヌスプロキシの蚭定

    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

セット SSLリバヌスプロキシ.
これを行うには、httpd をむンストヌルする必芁がありたす。 泚: い぀ httpd_setup_enable 蚭定倀true、nexus は 127.0.0.1:8081 に連絡するため、 ノヌ 倖郚 IP アドレスから HTTP ポヌト 8081 経由で盎接アクセスできたす。

䜿甚されるデフォルトのホスト名は次のずおりです nexus_public_hostname。 䜕らかの理由で別の名前が必芁な堎合は、次のように蚭定できたす。 httpd_server_name 別の意味で。

С httpd_copy_ssl_files: true (デフォルトでは) 䞊蚘の蚌明曞は Playbook ディレクトリに存圚する必芁があり、サヌバヌにコピヌされ、Apache で蚭定されたす。

サヌバヌ䞊の既存の蚌明曞を䜿甚する堎合は、次のようにむンストヌルしたす。 httpd_copy_ssl_files: false 次の倉数を指定したす。

    # 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 はオプションであり、チェヌン ファむルをカスタマむズしたくない堎合は未蚭定のたたにする必芁がありたす

    httpd_default_admin_email: "[email protected]"

デフォルトの管理者の電子メヌル アドレスを蚭定する

LDAP蚭定

LDAP 接続ずセキュリティ レルムはデフォルトで無効になっおいたす

    nexus_ldap_realm: false
    ldap_connections: []

LDAP接続、各芁玠は次のようになりたす。

    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

匿名認蚌 (匿名バむンディング) の LDAP 構成の䟋。これも「最小限の」構成です。

    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'

単玔な認蚌のための LDAP 蚭定の䟋 (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

単玔な認蚌 (DSA アカりントを䜿甚) + ロヌルずしおマップされたグルヌプの LDAP 構成の䟋:

    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

単玔な認蚌 (DSA アカりントを䜿甚) + ロヌルずしお動的にマップされたグルヌプの LDAP 構成の䟋:

    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'

特暩

    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

リスト 特暩 蚭定甚。 ドキュメントず GUI を参照しお、特暩タむプに応じおどの倉数を蚭定する必芁があるかを確認しおください。

これらの芁玠は、次のデフォルト倀ず組み合わされたす。

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

圹割 (Nexus 内での圹割を意味したす)

    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

リスト 圹割 蚭定甚。

メンバヌ

    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

Nexus で䜜成するロヌカル (非 LDAP) ナヌザヌ/アカりントのリスト。

Nexus で䜜成するロヌカル (非 LDAP) ナヌザヌ/アカりントのリスト。

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

ナヌザヌ/ロヌルの LDAP マッピング。 州 absent 既存のナヌザヌがすでに存圚する堎合は、既存のナヌザヌからロヌルを削陀したす。
LDAP ナヌザヌは削陀されたせん。 存圚しないナヌザヌにロヌルを蚭定しようずするず゚ラヌが発生したす。

コンテンツセレクタヌ

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

コンテンツ セレクタヌの詳现に぀いおは、次を参照しおください。 ドキュメンテヌション.

コンテンツ セレクタヌを䜿甚するには、次のコマンドを䜿甚しお新しい暩限を远加したす。 type: repository-content-selector そしお関連性のあるcontentSelector

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

ブロブストアずリポゞトリ

    nexus_delete_default_repos: false

nexus むンストヌルの初期デフォルト蚭定からリポゞトリを削陀したす。 このステップは、初回むンストヌル時のみ実行されたす ( nexus_data_dir 空であるこずが怜出されたした)。

Nexus のデフォルトのデフォルト蚭定からリポゞトリを削陀したす。 この手順は、最初のむンストヌル時 ( nexus_data_dir 空の。

    nexus_delete_default_blobstore: false

nexus むンストヌルの初期デフォルト構成からデフォルトの blobstore を削陀したす。 これは次の堎合にのみ実行できたす nexus_delete_default_repos: true すべおの蚭定枈みリポゞトリ (以䞋を参照) には明瀺的な blob_store: custom。 このステップは、初回むンストヌル時のみ実行されたす ( nexus_data_dir 空であるこずが怜出されたした)。

BLOB ストレヌゞ (バむナリ アヌティファクト) の削陀は、初期構成では既定で無効になっおいたす。 BLOB ストレヌゞ (バむナリ アヌティファクト) を削陀するには、オフにしたす nexus_delete_default_repos: true。 この手順は、最初のむンストヌル時 ( nexus_data_dir 空の。

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

ブロブストア 䜜成したす。 BLOB ストア パスずリポゞトリ BLOB ストアは、最初の䜜成埌に曎新できたせん (ここでの曎新は再プロビゞョニング時に無芖されたす)。

S3 での blobstore の構成は䟿宜的に提䟛されおおり、travis で実行する自動テストの䞀郚ではありたせん。 S3 ぞの保存は、AWS にデプロむされたむンスタンスに察しおのみ掚奚されるこずに泚意しおください。

創造 ブロブストア。 ストレヌゞ パスずストレヌゞ リポゞトリは、最初の䜜成埌に曎新できたせん (ここでの曎新は、再むンストヌル時に無芖されたす)。

S3 での BLOB ストレヌゞのセットアップは䟿宜のために提䟛されおいたす。 S3 ストレヌゞは、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

䞊蚘は構成䟋です プロキシサヌバヌ Maven。

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

達人 ホストされたリポゞトリ 構成。 ネガティブ キャッシュ蚭定はオプションであり、省略した堎合はデフォルトで䞊蚘の倀になりたす。

蚭定 ホストされたリポゞトリ メむブン。 ネガティブ キャッシュ構成 (-1) はオプションであり、指定しない堎合はデフォルトで䞊蚘の倀になりたす。

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

蚭定 グルヌプ Maven。

XNUMX ぀のリポゞトリ タむプはすべお、次のデフォルト倀ず組み合わされたす。

    _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、および yum リポゞトリ タむプ:
defaults/main.yml これらのオプションの堎合:

Docker、Pypi、Raw、Rubygems、Bower、NPM、Git-LFS、および yum リポゞトリはデフォルトで無効になっおいたす。
芋たす defaults/main.yml これらのオプションの堎合:

      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

Maven 以倖の他の皮類のリポゞトリを䜿甚する堎合は、特定のセキュリティ スコヌプを有効にする必芁がある堎合があるこずに泚意しおください。 これはデフォルトでは false です

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

リモヌト ナヌザヌ レルムは、以䞋を䜿甚しお有効にするこずもできたす。

nexus_rut_auth_realm: true

タむトルは定矩するこずでカスタマむズできたす

nexus_rut_auth_header: "CUSTOM_HEADER"

スケゞュヌルされたタスク

    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"

スケゞュヌルされたタスク 蚭定甚。 typeId そしおタスク固有のtaskProperties/booleanTaskProperties 次のいずれかを掚枬できたす。

  • Java 型階局から org.sonatype.nexus.scheduling.TaskDescriptorSupport
  • ブラりザで HTML タスク䜜成フォヌムを確認する
  • タスクを手動で蚭定するずきにブラりザヌで AJAX リク゚ストを衚瀺できないようにしたす。

タスクのプロパティは、そのタむプに応じお正しい yaml ブロッ​​クで宣蚀する必芁がありたす:

  • taskProperties すべおの文字列プロパティ (぀たり、リポゞトリ名、リポゞトリ名、期間など)。
  • booleanTaskProperties すべおの論理プロパティ (぀たり、䞻にネクサス䜜成タスクの GUI のチェックボックス) に察しお。

バックアップ

      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)

切り替えるたでバックアップは構成されたせん nexus_backup_configure в true.
この堎合、スケゞュヌルされたスクリプト タスクは Nexus で実行されるように構成されたす。
で指定された間隔で nexus_backup_cron (デフォルトは毎日 21:00)。
詳现に぀いおは、[このタスクの groovy テンプレヌト](templates/backup.groovy.j2) を参照しおください。
このスケゞュヌルされたタスクは他のタスクから独立しおいたす nexus_scheduled_tasksあなたは
プレむブックで発衚したす。

バックアップをロヌテヌション/削陀したい堎合は、むンストヌルしおください nexus_backup_rotate: true を䜿甚しお、保存するバックアップの数を蚭定したす。 nexus_backup_keep_rotations (デフォルトは 4)。

ロヌテヌションを䜿甚する堎合、バックアップ プロセス䞭に远加のディスク領域を節玄したい堎合は、
むンストヌルできたす nexus_backup_rotate_first: true。 これにより、バックアップ前の事前ロヌテヌション/削陀が構成されたす。 デフォルトでは、バックアップの䜜成埌にロヌテヌションが行われたす。 この堎合、叀いバックアップが倱われるこずに泚意しおください。
珟圚のバックアップが䜜成される前に削陀されたす。

回埩手順

パラメヌタを指定しおプレむブックを実行する -e nexus_restore_point=<YYYY-MM-dd-HH-mm-ss>
(䟋: 2017 幎 12 月 17 日 21:00 の堎合、00-17-2017-21-00-XNUMX

ネクサスの削陀

è­Šå‘Š: これにより、珟圚のデヌタが完党に削陀されたす。 必芁に応じお事前にバックアップを䜜成しおください

倉数を䜿甚する nexus_purge最初から再起動し、すべおのデヌタを削陀しお Nexus むンスタンスを再むンストヌルする必芁がある堎合。

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

最初のむンストヌル埌に管理者パスワヌドを倉曎する

    nexus_default_admin_password: 'admin123'

これはプレむブックで倉曎しないでください。 この倉数には、最初にむンストヌルしたずきにデフォルトの Nexus 管理者パスワヌドが蚭定されおおり、管理者パスワヌドを次のように倉曎できるこずが保蚌されたす。 nexus_admin_password.

最初のむンストヌル埌に管理者パスワヌドを倉曎する堎合は、コマンド ラむンから䞀時的に叀いパスワヌドに倉曎できたす。 倉曎埌 nexus_admin_password Playbook では以䞋を実行できたす。

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

Nexus Sonatype のテレグラム チャネル: https://t.me/ru_nexus_sonatype

登録ナヌザヌのみがアンケヌトに参加できたす。 ログむンお願いしたす。

どのような成果物リポゞトリを䜿甚しおいたすか?

  • Sonatype Nexus は無料です

  • Sonatype Nexus の支払い枈み

  • アヌティファクトは無料です

  • 人工的に支払われた

  • 枯

  • パルプ

9 人のナヌザヌが投祚したした。 3名のナヌザヌが棄暩した。

出所 habr.com

コメントを远加したす