Uppsetning og stilling Nexus Sonatype með því að nota innviðina sem kóðaaðferð

Sonatype Nexus er samþættur vettvangur þar sem forritarar geta umboð, geymt og stjórnað Java (Maven) ósjálfstæði, Docker, Python, Ruby, NPM, Bower myndir, RPM pakka, gitlfs, Apt, Go, Nuget og dreift hugbúnaðaröryggi sínu.

Af hverju þarftu Sonatype Nexus?

  • Til að geyma einkamuni;
  • Fyrir skyndiminni gripi sem er hlaðið niður af internetinu;

Artifacts studdir í grunn Sonatype Nexus pakkanum:

  • Java, Maven (krukka)
  • Docker
  • Python (pip)
  • Ruby (gimsteinn)
  • NPM
  • Bower
  • Namm (rpm)
  • gitlfs
  • Raw
  • Apt (deb)
  • Go
  • Núget

Samfélagsstuddir gripir:

  • Semja
  • Conan
  • CPAN
  • ELPA
  • Helm
  • P2
  • R

Uppsetning Sonatype Nexus með því að nota https://github.com/ansible-ThoTeam/nexus3-oss

Kröfur

  • Lestu um notkun ansible á netinu.
  • Settu upp ansible pip install ansible á vinnustöðinni þar sem leikbókin keyrir.
  • Setja geerlingguy.java á vinnustöðinni þar sem leikbókin keyrir.
  • Setja geerlingguy.apache á vinnustöðinni þar sem leikbókin keyrir.
  • Þetta hlutverk hefur verið prófað á CentOS 7, Ubuntu Xenial (16.04) og Bionic (18.04), Debian Jessie og Stretch
  • jmespath Bókasafnið verður að vera uppsett á vinnustöðinni þar sem leikbókin er í gangi. Til að setja upp: sudo pip install -r requirements.txt
  • Vistaðu leikbókarskrána (dæmi hér að neðan) í nexus.yml skránni
  • Keyra Nexus uppsetningu ansible-playbook -i host nexus.yml

Dæmi um ansible-leikbók til að setja upp nexus án LDAP með Maven (java), Docker, Python, Ruby, NPM, Bower, RPM og gitlfs geymslum.

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

Skjámyndir:

Uppsetning og stilling Nexus Sonatype með því að nota innviðina sem kóðaaðferð

Uppsetning og stilling Nexus Sonatype með því að nota innviðina sem kóðaaðferð

Breytileg hlutverk

Hlutverksbreytur

Breytur með sjálfgefnum gildum (sjá default/main.yml):

Almennar breytur

    nexus_version: ''
    nexus_timezone: 'UTC'

Sjálfgefið er að hlutverkið setur upp nýjustu útgáfuna af Nexus. Þú getur lagað útgáfuna með því að breyta breytunni nexus_version. Sjá tiltækar útgáfur á https://www.sonatype.com/download-oss-sonatype.

Ef þú skiptir yfir í nýrri útgáfu mun hlutverkið reyna að uppfæra Nexus uppsetninguna þína.

Ef þú ert að nota eldri útgáfu af Nexus en nýjustu, ættirðu að tryggja að þú sért ekki að nota eiginleika sem eru ekki tiltækir í uppsettu útgáfunni (td hýsing yum geymslur er fáanleg fyrir nexus stærri en 3.8.0, git lfs repo fyrir tengsl stærra en 3.3.0 osfrv.)

nexus timezone er heiti Java tímabeltis, sem getur verið gagnlegt ásamt eftirfarandi cron tjáningum fyrir nexus_scheduled verkefni.

Nexus tengi og samhengisleið

    nexus_default_port: 8081
    nexus_default_context_path: '/'

Gátt og samhengisleið Java tengingarferlisins. nexus_default_context_path verður að innihalda skástrik þegar það er stillt, td: nexus_default_context_path: '/nexus/'.

Nexus OS notandi og hópur

    nexus_os_group: 'nexus'
    nexus_os_user: 'nexus'

Notandinn og hópurinn sem notaður er til að eiga Nexus skrár og keyra þjónustuna verða til af hlutverkinu ef slíkt vantar.

    nexus_os_user_home_dir: '/home/nexus'

Leyfa að breyta sjálfgefna heimaskrá fyrir nexus notandann

Nexus tilviksskrár

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

Nexus vörulistar.

  • nexus_installation_dir inniheldur uppsettar keyrsluskrár
  • nexus_data_dir inniheldur allar stillingar, geymslur og niðurhalaða gripi. Sérsniðnar blobstore slóðir nexus_data_dir hægt að aðlaga, sjá hér að neðan nexus_blobstores.
  • nexus_tmp_dir inniheldur allar tímabundnar skrár. Sjálfgefin slóð fyrir redhat hefur verið færð frá /tmp til að sigrast á hugsanlegum vandamálum með sjálfvirkum hreinsunaraðferðum. Sjá #168.

Stilla Nexus JVM minnisnotkun

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

Þetta eru sjálfgefnar stillingar fyrir Nexus. Vinsamlegast ekki breyta þessum gildum Ef þú hefur ekki lesið Minni kafla um kröfur um Nexus kerfi og skil ekki hvað þeir eru að gera.

Sem önnur viðvörun, hér er útdráttur úr ofangreindu skjali:

Ekki er mælt með því að auka JVM hrúgaminni umfram ráðlögð gildi til að reyna að bæta árangur. Þetta getur í raun haft þveröfug áhrif, sem leiðir til óþarfa vinnu fyrir stýrikerfið.

Lykilorð stjórnanda

    nexus_admin_password: 'changeme'

Lykilorð „admin“ reikningsins fyrir uppsetningu. Þetta virkar aðeins við fyrstu sjálfgefna uppsetningu. Vinsamlegast sjáðu [Breyta stjórnanda lykilorði eftir fyrstu uppsetningu](# change-admin-password-after-first-install) ef þú vilt breyta því síðar með hlutverki.

Það er eindregið mælt með því að geyma ekki lykilorðið þitt í skýrum texta í leikbókinni, heldur að nota [ansible-vault dulkóðun] (https://docs.ansible.com/ansible/latest/user_guide/vault.html) (annaðhvort inline eða í sérstakri skrá sem er hlaðin t.d. include_vars)

Sjálfgefið er nafnlaus aðgangur

    nexus_anonymous_access: false

Nafnlaus aðgangur er sjálfgefið óvirkur. Lestu meira um nafnlausan aðgang.

Opinbert hýsingarheiti

    nexus_public_hostname: 'nexus.vm'
    nexus_public_scheme: https

Fullkomið lén og kerfi (https eða http) þar sem Nexus tilvikið verður aðgengilegt viðskiptavinum sínum.

API aðgangur fyrir þetta hlutverk

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

Þessar breytur stjórna því hvernig hlutverkið tengist Nexus API fyrir úthlutun.
Aðeins fyrir lengra komna notendur. Þú vilt líklega ekki breyta þessum sjálfgefna stillingum

Setja upp öfugt umboð

    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

Setja SSL öfugt umboð.
Til að gera þetta þarftu að setja upp httpd. Athugið: hvenær fyrir httpd_setup_enable sett gilditrue, tengiliðir 127.0.0.1:8081, þannig ekki að vera beint aðgengileg í gegnum HTTP tengi 8081 frá ytri IP tölu.

Sjálfgefið hýsilnafn sem notað er er nexus_public_hostname. Ef þú þarft önnur nöfn af einhverjum ástæðum geturðu stillt httpd_server_name með annarri merkingu.

С httpd_copy_ssl_files: true (sjálfgefið) ofangreind vottorð ættu að vera til í leikbókasafninu þínu og verða afrituð á netþjóninn og stillt í apache.

Ef þú vilt nota núverandi vottorð á þjóninum skaltu setja upp httpd_copy_ssl_files: false og gefðu upp eftirfarandi breytur:

    # 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 er valfrjálst og ætti að vera óstillt ef þú vilt ekki aðlaga keðjuskrána

    httpd_default_admin_email: "[email protected]"

Stilltu sjálfgefið netfang stjórnanda

LDAP stillingar

LDAP tengingar og öryggissvið eru sjálfgefið óvirk

    nexus_ldap_realm: false
    ldap_connections: []

LDAP tengingar, hver þáttur lítur svona út:

    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

Dæmi um LDAP stillingar fyrir nafnlausa auðkenningu (nafnlaus binding), þetta er líka "lágmarks" stillingar:

    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'

Dæmi LDAP stillingar fyrir einfalda auðkenningu (með DSA reikningi):

    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

Dæmi LDAP stillingar fyrir einfalda auðkenningu (með DSA reikningi) + hópar kortlagðir sem hlutverk:

    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

Dæmi um LDAP stillingar fyrir einfalda auðkenningu (með því að nota DSA reikning) + hópar varpaðir á kraftmikið hátt sem hlutverk:

    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'

Forréttindi

    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

Listi forréttindi fyrir stillingar. Skoðaðu skjölin og GUI til að athuga hvaða breytur þarf að stilla eftir forréttindategundinni.

Þessir þættir eru sameinaðir eftirfarandi sjálfgefnum gildum:

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

Hlutverk (inni í Nexus þýðir þetta)

    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

Listi hlutverkum fyrir stillingar.

Notendur

    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

Staðbundnir (ekki LDAP) notendur/reikningalisti til að búa til í nexus.

Listi yfir staðbundna (ekki LDAP) notendur/reikninga til að búa til í Nexus.

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

Ldap kortlagning notenda/hlutverka. Ríki absent mun fjarlægja hlutverk frá núverandi notanda ef hann er þegar til.
Ldap notendum er ekki eytt. Reynt er að stilla hlutverk fyrir notanda sem ekki er til mun leiða til villu.

Efnisvalarar

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

Fyrir frekari upplýsingar um efnisvalið, sjá Skjöl.

Til að nota efnisvalið skaltu bæta við nýjum réttindum með type: repository-content-selector og viðeigandicontentSelector

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

Blobstores og geymslur

    nexus_delete_default_repos: false

Eyddu geymslunum úr upphaflegri sjálfgefna stillingu Nexus uppsetningar. Þetta skref er aðeins framkvæmt við fyrstu uppsetningu (hvenær nexus_data_dir hefur fundist tómt).

Fjarlægir geymslur úr sjálfgefnum sjálfgefnum stillingum fyrir Nexus. Þetta skref er aðeins framkvæmt við fyrstu uppsetningu (þegar nexus_data_dir tómt).

    nexus_delete_default_blobstore: false

Eyddu sjálfgefna blobstore úr upphaflegu sjálfgefna stillingu Nexus uppsetningar. Þetta er aðeins hægt að gera ef nexus_delete_default_repos: true og allar stilltar geymslur (sjá hér að neðan) hafa skýrt blob_store: custom. Þetta skref er aðeins framkvæmt við fyrstu uppsetningu (hvenær nexus_data_dir hefur fundist tómt).

Slökkt er sjálfkrafa á því að fjarlægja blob-geymslu (tvíundir artifacts) frá upphaflegri uppsetningu. Slökktu á til að fjarlægja blobgeymslu (tvíundir gripir). nexus_delete_default_repos: true. Þetta skref er aðeins framkvæmt við fyrstu uppsetningu (þegar nexus_data_dir tómt).

    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 til að búa til. Ekki er hægt að uppfæra blobstore slóð og geymslu blobstore eftir fyrstu stofnun (allar uppfærslur hér verða hunsaðar við endurúthlutun).

Stilling blobstore á S3 er veitt til þæginda og er ekki hluti af sjálfvirku prófunum sem við keyrum á travis. Vinsamlegast athugaðu að aðeins er mælt með því að geyma á S3 fyrir tilvik sem eru notuð á AWS.

Sköpun Blobstores. Ekki er hægt að uppfæra geymsluslóðina og geymslugeymsluna eftir upphaflega stofnun (allar uppfærslur hér verða hunsaðar þegar þær eru settar upp aftur).

Til þæginda er boðið upp á að setja upp geymslupláss á S3. Vinsamlegast athugaðu að aðeins er mælt með S3 geymslu fyrir tilvik sem eru sett á 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

Hér að ofan er dæmi um uppsetningu proxy-þjónn Maven.

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

Maven hýst geymslur uppsetningu. Neikvæð skyndiminni stilling er valfrjáls og mun sjálfgefið hafa ofangreind gildi ef þeim er sleppt.

Stillingar hýst geymslur Maven. Neikvæða skyndiminni stillingin (-1) er valfrjáls og mun sjálfgefin hafa ofangreind gildi ef ekki er tilgreint.

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

Stillingar hópar Maven.

Allar þrjár geymslugerðirnar eru sameinaðar með eftirfarandi sjálfgefna gildum:

    _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 og yum geymsla:
sjá defaults/main.yml fyrir þessa valkosti:

Docker, Pypi, Raw, Rubygems, Bower, NPM, Git-LFS og yum geymslur eru sjálfgefnar óvirkar:
Horfa á defaults/main.yml fyrir þessa valkosti:

      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

Vinsamlegast athugaðu að þú gætir þurft að virkja ákveðin öryggissvið ef þú vilt nota aðrar gerðir af geymslum en maven. Þetta er sjálfgefið rangt

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

Einnig er hægt að virkja Remote User Realm með því að nota

nexus_rut_auth_realm: true

og titilinn er hægt að aðlaga með því að skilgreina

nexus_rut_auth_header: "CUSTOM_HEADER"

Skipulögð verkefni

    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"

Skipulögð verkefni fyrir stillingar. typeId og sérstök verkefnitaskProperties/booleanTaskProperties þú getur giskað á annað hvort:

  • úr Java tegundastigveldinu org.sonatype.nexus.scheduling.TaskDescriptorSupport
  • athugaðu HTML verkefnaformið í vafranum þínum
  • frá því að skoða AJAX beiðnir í vafranum þegar verkefni er sett upp handvirkt.

Eiginleikar verkefnisins verða að vera lýst yfir í réttum yaml blokk eftir gerð þeirra:

  • taskProperties fyrir alla strengareiginleika (þ.e. geymsluheiti, geymsluheiti, tímabil...).
  • booleanTaskProperties fyrir alla rökfræðilega eiginleika (þ.e.a.s. aðallega gátreitir í GUI tengingarverksins).

Öryggisafrit

      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)

Afritun verður ekki stillt fyrr en þú skiptir nexus_backup_configure в true.
Í þessu tilviki verður áætlað skriftuverkefni stillt til að keyra á Nexus
með því millibili sem tilgreint er í nexus_backup_cron (sjálfgefið 21:00 alla daga).
Sjá [groovy sniðmát fyrir þetta verkefni](templates/backup.groovy.j2) fyrir frekari upplýsingar.
Þetta áætlaða verkefni er óháð öðrum nexus_scheduled_taskssem þú
tilkynntu í leikbókinni þinni.

Ef þú vilt snúa/eyða afritum skaltu setja upp nexus_backup_rotate: true og stilltu fjölda afrita sem þú vilt vista með því að nota nexus_backup_keep_rotations (sjálfgefið 4).

Þegar þú notar snúning, ef þú vilt spara meira pláss á plássi meðan á öryggisafritinu stendur,
Þú getur sett upp nexus_backup_rotate_first: true. Þetta mun stilla forsnúning/eyðingu fyrir öryggisafrit. Sjálfgefið er að snúningur á sér stað eftir að öryggisafrit er búið til. Vinsamlegast athugaðu að í þessu tilviki gömlu öryggisafritin
verður eytt áður en núverandi öryggisafrit er gert.

Endurheimtaraðferð

Keyra leikbók með breytu -e nexus_restore_point=<YYYY-MM-dd-HH-mm-ss>
(til dæmis 2017-12-17-21-00-00 fyrir 17. desember 2017 kl. 21:00

Fjarlægir tengsl

Viðvörun: Þetta mun algjörlega eyða núverandi gögnum þínum. Vertu viss um að taka öryggisafrit fyrr ef þörf krefur

Notaðu breytu nexus_purgeef þú þarft að endurræsa frá grunni og setja upp nexus tilvikið aftur með öll gögn fjarlægð.

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

Breyttu lykilorði stjórnanda eftir fyrstu uppsetningu

    nexus_default_admin_password: 'admin123'

Þessu ætti ekki að breyta í leikbókinni þinni. Þessi breyta er fyllt út með sjálfgefnu Nexus stjórnanda lykilorði þegar það er fyrst sett upp og tryggir að við getum breytt stjórnanda lykilorðinu í nexus_admin_password.

Ef þú vilt breyta lykilorði stjórnanda eftir fyrstu uppsetningu geturðu breytt því tímabundið í gamla lykilorðið frá skipanalínunni. Eftir breytingu nexus_admin_password í leikbókinni þinni geturðu keyrt:

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

Telegram rás á Nexus Sonatype: https://t.me/ru_nexus_sonatype

Aðeins skráðir notendur geta tekið þátt í könnuninni. Skráðu þig inn, takk.

Hvaða gripageymslur notar þú?

  • Sonatype Nexus er ókeypis

  • Sonatype Nexus greitt

  • Artifactory er ókeypis

  • Artifactory greitt

  • Harbor

  • Pulp

9 notendur greiddu atkvæði. 3 notendur sátu hjá.

Heimild: www.habr.com

Bæta við athugasemd