Suiteáil agus cumraíocht Nexus Sonatype ag baint úsáide as an mbonneagar mar chur chuige cód

Is ardán comhtháite é Sonatype Nexus trínar féidir le forbróirí seachfhreastalaí, stóráil agus bainistiú a dhéanamh ar spleáchais Java (Maven), Docker, Python, Ruby, NPM, íomhánna Bower, pacáistí RPM, gitlfs, Apt, Go, Nuget, agus a slándáil bogearraí a dháileadh.

Cén fáth a bhfuil Sonatype Nexus ag teastáil uait?

  • Chun artifacts príobháideacha a stóráil;
  • Le haghaidh caching déantáin a íoslódáil ón Idirlíon;

Déantáin a dtacaítear leo sa phacáiste bunúsach Sonatype Nexus:

  • Java, Maven (próca)
  • dhugaire
  • Python (pip)
  • Ruby (Gem)
  • NPM
  • Bowers
  • Yum (rpm)
  • gitlfs
  • Raw
  • Apt (deb)
  • Go
  • Nuget

Déantáin Tacaithe Pobail:

  • Cumadóir
  • Conan
  • CPAN
  • ELPA
  • Helm
  • P2
  • R

Suiteáil Sonatype Nexus ag baint úsáide as https://github.com/ansible-ThoTeam/nexus3-oss

Riachtanais

  • Léigh faoi úsáid ansible ar an Idirlíon.
  • Suiteáil ciallmhar pip install ansible ar an stáisiún oibre ina ritheann an playbook.
  • Socraigh geerlingguy.java ar an stáisiún oibre ina ritheann an playbook.
  • Socraigh geerlingguy.apache ar an stáisiún oibre ina ritheann an playbook.
  • Táthar tar éis an ról seo a thástáil ar CentOS 7, Ubuntu Xenial (16.04) agus Bionic (18.04), Debian Jessie agus Stretch
  • jmespath Ní mór an leabharlann a shuiteáil ar an stáisiún oibre ina bhfuil an leabhar súgartha ar siúl. Chun a shuiteáil: sudo pip install -r requirements.txt
  • Sábháil an comhad playbook (mar shampla thíos) go comhad nexus.yml
  • Rith suiteáil nexus ansible-playbook -i host nexus.yml

Sampla ansible-playbook chun nexus a shuiteáil gan LDAP le stórtha Maven (java), Docker, Python, Ruby, NPM, Bower, RPM agus gitlfs.

---
- name: Nexus
  hosts: nexus
  become: yes

  vars:
    nexus_timezone: 'Asia/Omsk'
    nexus_admin_password: "admin123"
    nexus_public_hostname: 'apatsev-nexus-playbook'
    httpd_setup_enable: false
    nexus_privileges:
      - name: all-repos-read
        description: 'Read & Browse access to all repos'
        repository: '*'
        actions:
          - read
          - browse
      - name: company-project-deploy
        description: 'Deployments to company-project'
        repository: company-project
        actions:
          - add
          - edit
    nexus_roles:
      - id: Developpers # maps to the LDAP group
        name: developers
        description: All developers
        privileges:
          - nx-search-read
          - all-repos-read
          - company-project-deploy
        roles: []
    nexus_local_users:
      - username: jenkins # used as key to update
        first_name: Jenkins
        last_name: CI
        email: [email protected]
        password: "s3cr3t"
        roles:
          - Developpers # role ID here
    nexus_blobstores:
      - name: company-artifacts
        path: /var/nexus/blobs/company-artifacts
    nexus_scheduled_tasks:
      - name: compact-blobstore
        cron: '0 0 22 * * ?'
        typeId: blobstore.compact
        taskProperties:
          blobstoreName: 'company-artifacts'

    nexus_repos_maven_proxy:
      - name: central
        remote_url: 'https://repo1.maven.org/maven2/'
        layout_policy: permissive
      - name: jboss
        remote_url: 'https://repository.jboss.org/nexus/content/groups/public-jboss/'
      - name: vaadin-addons
        remote_url: 'https://maven.vaadin.com/vaadin-addons/'
      - name: jaspersoft
        remote_url: 'https://jaspersoft.artifactoryonline.com/jaspersoft/jaspersoft-repo/'
        version_policy: mixed
    nexus_repos_maven_hosted:
      - name: company-project
        version_policy: mixed
        write_policy: allow
        blob_store: company-artifacts
    nexus_repos_maven_group:
      - name: public
        member_repos:
          - central
          - jboss
          - vaadin-addons
          - jaspersoft

    # Yum. Change nexus_config_yum to true for create yum repository
    nexus_config_yum: true
    nexus_repos_yum_hosted:
      - name: private_yum_centos_7
        repodata_depth: 1
    nexus_repos_yum_proxy:
      - name: epel_centos_7_x86_64
        remote_url: http://download.fedoraproject.org/pub/epel/7/x86_64
        maximum_component_age: -1
        maximum_metadata_age: -1
        negative_cache_ttl: 60
      - name: centos-7-os-x86_64
        remote_url: http://mirror.centos.org/centos/7/os/x86_64/
        maximum_component_age: -1
        maximum_metadata_age: -1
        negative_cache_ttl: 60
    nexus_repos_yum_group:
      - name: yum_all
        member_repos:
          - private_yum_centos_7
          - epel_centos_7_x86_64

    # NPM. Change nexus_config_npm to true for create npm repository
    nexus_config_npm: true
    nexus_repos_npm_hosted: []
    nexus_repos_npm_group:
      - name: npm-public
        member_repos:
          - npm-registry
    nexus_repos_npm_proxy:
      - name: npm-registry
        remote_url: https://registry.npmjs.org/
        negative_cache_enabled: false

    # Docker. Change nexus_config_docker to true for create docker repository
    nexus_config_docker: true
    nexus_repos_docker_hosted:
      - name: docker-hosted
        http_port: "{{ nexus_docker_hosted_port }}"
        v1_enabled: True
    nexus_repos_docker_proxy:
      - name: docker-proxy
        http_port: "{{ nexus_docker_proxy_port }}"
        v1_enabled: True
        index_type: "HUB"
        remote_url: "https://registry-1.docker.io"
        use_nexus_certificates_to_access_index: false
        maximum_component_age: 1440
        maximum_metadata_age: 1440
        negative_cache_enabled: true
        negative_cache_ttl: 1440
    nexus_repos_docker_group:
      - name: docker-group
        http_port: "{{ nexus_docker_group_port }}"
        v1_enabled: True
        member_repos:
          - docker-hosted
          - docker-proxy

    # Bower. Change nexus_config_bower to true for create bower repository
    nexus_config_bower: true
    nexus_repos_bower_hosted:
      - name: bower-hosted
    nexus_repos_bower_proxy:
      - name: bower-proxy
        index_type: "proxy"
        remote_url: "https://registry.bower.io"
        use_nexus_certificates_to_access_index: false
        maximum_component_age: 1440
        maximum_metadata_age: 1440
        negative_cache_enabled: true
        negative_cache_ttl: 1440
    nexus_repos_bower_group:
      - name: bower-group
        member_repos:
          - bower-hosted
          - bower-proxy

    # Pypi. Change nexus_config_pypi to true for create pypi repository
    nexus_config_pypi: true
    nexus_repos_pypi_hosted:
      - name: pypi-hosted
    nexus_repos_pypi_proxy:
      - name: pypi-proxy
        index_type: "proxy"
        remote_url: "https://pypi.org/"
        use_nexus_certificates_to_access_index: false
        maximum_component_age: 1440
        maximum_metadata_age: 1440
        negative_cache_enabled: true
        negative_cache_ttl: 1440
    nexus_repos_pypi_group:
      - name: pypi-group
        member_repos:
          - pypi-hosted
          - pypi-proxy

    # rubygems. Change nexus_config_rubygems to true for create rubygems repository
    nexus_config_rubygems: true
    nexus_repos_rubygems_hosted:
      - name: rubygems-hosted
    nexus_repos_rubygems_proxy:
      - name: rubygems-proxy
        index_type: "proxy"
        remote_url: "https://rubygems.org"
        use_nexus_certificates_to_access_index: false
        maximum_component_age: 1440
        maximum_metadata_age: 1440
        negative_cache_enabled: true
        negative_cache_ttl: 1440
    nexus_repos_rubygems_group:
      - name: rubygems-group
        member_repos:
          - rubygems-hosted
          - rubygems-proxy

    # gitlfs. Change nexus_config_gitlfs to true for create gitlfs repository
    nexus_config_gitlfs: true
    nexus_repos_gitlfs_hosted:
      - name: gitlfs-hosted

  roles:
    - { role: geerlingguy.java }
    # Debian/Ubuntu only
    # - { role: geerlingguy.apache, apache_create_vhosts: no, apache_mods_enabled: ["proxy_http.load", "headers.load"], apache_remove_default_vhost: true, tags: ["geerlingguy.apache"] }
    # RedHat/CentOS only
    - { role: geerlingguy.apache, apache_create_vhosts: no, apache_remove_default_vhost: true, tags: ["geerlingguy.apache"] }
    - { role: ansible-thoteam.nexus3-oss, tags: ['ansible-thoteam.nexus3-oss'] }

Scáileáin scáileáin:

Suiteáil agus cumraíocht Nexus Sonatype ag baint úsáide as an mbonneagar mar chur chuige cód

Suiteáil agus cumraíocht Nexus Sonatype ag baint úsáide as an mbonneagar mar chur chuige cód

Róil athraitheacha

Athróga Róil

Athróga le luachanna réamhshocraithe (féach default/main.yml):

Athróga ginearálta

    nexus_version: ''
    nexus_timezone: 'UTC'

De réir réamhshocraithe, déanfaidh an ról an leagan is déanaí de Nexus a shuiteáil. Is féidir leat an leagan a shocrú tríd an athróg a athrú nexus_version. Féach ar na leaganacha atá ar fáil ag https://www.sonatype.com/download-oss-sonatype.

Má athraíonn tú go leagan níos nuaí, déanfaidh an ról iarracht do shuiteáil Nexus a nuashonrú.

Má tá tú ag baint úsáide as leagan níos sine de Nexus ná an ceann is déanaí, ba cheart duit a chinntiú nach bhfuil tú ag baint úsáide as gnéithe nach bhfuil ar fáil sa scaoileadh suiteáilte (mar shampla, tá stórtha yum óstáil ar fáil le haghaidh nexus níos mó ná 3.8.0, git lfs repo le haghaidh nexus níos mó ná 3.3.0 etc.)

nexus timezone is ainm don chrios ama Java, is féidir a bheith úsáideach i gcomhcheangal leis na habairtí cron seo a leanas le haghaidh tascanna nexus_scheduled.

Port nexus agus cosán comhthéacs

    nexus_default_port: 8081
    nexus_default_context_path: '/'

An port agus cosán comhthéacs an phróisis naisc Java. nexus_default_context_path caithfidh réamhslais a bheith ann nuair a shocraítear é, m.sh. nexus_default_context_path: '/nexus/'.

Úsáideoir agus Grúpa Nexus OS

    nexus_os_group: 'nexus'
    nexus_os_user: 'nexus'

Cruthóidh an ról an t-úsáideoir agus an grúpa a úsáidtear chun comhaid Nexus a bheith acu agus an tseirbhís a rith má tá ceann ar iarraidh.

    nexus_os_user_home_dir: '/home/nexus'

Ceadaigh an t-eolaire baile réamhshocraithe a athrú don úsáideoir nexus

Eolairí shampla Nexus

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

Catalóga Nexus.

  • nexus_installation_dir tá comhaid inrite suiteáilte ann
  • nexus_data_dir ina bhfuil gach cumraíocht, stórtha agus déantáin íoslódáilte. Cosáin blobstore saincheaptha nexus_data_dir is féidir a shaincheapadh, féach thíos nexus_blobstores.
  • nexus_tmp_dir ina bhfuil gach comhad sealadach. Bogadh an cosán réamhshocraithe le haghaidh redhat ó /tmp chun fadhbanna féideartha le nósanna imeachta glantacháin uathoibríoch a shárú. Féach #168.

Úsáid Cuimhne Nexus JVM a chumrú

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

Is iad seo na socruithe réamhshocraithe do Nexus. Ná hathraigh na luachanna seo le do thoil Mura bhfuil tú léite Alt cuimhne riachtanais an chórais nexus agus ní thuigeann siad cad atá ar siúl acu.

Mar dhara rabhadh, seo sliocht as an doiciméad thuas:

Ní mholtar cuimhne carn JVM a mhéadú thar na luachanna molta in iarracht feidhmíocht a fheabhsú. D'fhéadfadh a mhalairt éifeacht a bheith aige seo, rud a fhágann go n-oibreodh an córas oibriúcháin gan ghá.

Pasfhocal riarthóir

    nexus_admin_password: 'changeme'

Pasfhocal an chuntais “admin” le haghaidh cumraíochta. Ní oibríonn sé seo ach ar an gcéad suiteáil réamhshocraithe. Féach le do thoil [Athraigh pasfhocal riarthóra tar éis an chéad suiteála](# change-admin-password-after-first-install) más mian leat é a athrú níos déanaí ag baint úsáide as ról.

Moltar go láidir gan do phasfhocal a stóráil i dtéacs soiléir sa leabhar súgartha, ach úsáid a bhaint as [criptiúchán ansible- cruinneachán] (https://docs.ansible.com/ansible/latest/user_guide/vault.html) (ceachtar inlíne nó i gcomhad ar leith luchtaithe le e.g. include_vars)

Rochtain gan ainm de réir réamhshocraithe

    nexus_anonymous_access: false

Tá rochtain gan ainm díchumasaithe de réir réamhshocraithe. Léigh tuilleadh faoi rochtain gan ainm.

Óstainm poiblí

    nexus_public_hostname: 'nexus.vm'
    nexus_public_scheme: https

An t-ainm fearainn láncháilithe agus an scéim (https nó http) faoina mbeidh an sampla Nexus ar fáil dá chliaint.

Rochtain API don ról seo

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

Rialaíonn na hathróga seo conas a nascann an ról leis an Nexus API le haghaidh soláthair.
D'úsáideoirí chun cinn amháin. Is dócha nach dteastaíonn uait na socruithe réamhshocraithe seo a athrú

Seachfhreastalaí droim ar ais a shocrú

    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

Socraigh Seachfhreastalaí Droim ar Ais SSL.
Chun seo a dhéanamh ní mór duit httpd a shuiteáil. Nóta: cathain le haghaidh httpd_setup_enable luach socraithetrue, nexus teagmhálacha 127.0.0.1:8081, mar sin aon a bheith inrochtana go díreach trí phort HTTP 8081 ón seoladh IP seachtrach.

Is é an t-óstainm réamhshocraithe a úsáidtear nexus_public_hostname. Más gá duit ainmneacha éagsúla ar chúis éigin, is féidir leat a shocrú httpd_server_name le brí eile.

С httpd_copy_ssl_files: true (de réir réamhshocraithe) ba cheart go mbeadh na deimhnithe thuas i do eolaire leabhar súgartha agus déanfar iad a chóipeáil chuig an bhfreastalaí agus a chumrú in apache.

Más mian leat teastais atá ann cheana a úsáid ar an bhfreastalaí, suiteáil httpd_copy_ssl_files: false agus cuir na hathróga seo a leanas ar fáil:

    # 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 Tá sé roghnach agus ba cheart é a fhágáil gan socrú mura bhfuil tú ag iarraidh an slabhrachomhad a shaincheapadh

    httpd_default_admin_email: "[email protected]"

Socraigh seoladh ríomhphoist réamhshocraithe admin

Cumraíocht LDAP

Díchumasaítear naisc LDAP agus an réimse slándála de réir réamhshocraithe

    nexus_ldap_realm: false
    ldap_connections: []

naisc LDAP, tá cuma mar seo ar gach eilimint:

    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

Sampla de chumraíocht LDAP le haghaidh fíordheimhnithe gan ainm (ceangail gan ainm), is cumraíocht "íosta" é seo freisin:

    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'

Sampla de chumraíocht LDAP le haghaidh fíordheimhnithe simplí (ag úsáid cuntas 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

Sampla de chumraíocht LDAP le haghaidh fíordheimhnithe simplí (ag úsáid cuntas DSA) + grúpaí arna mapáil mar róil:

    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

Sampla de chumraíocht LDAP le haghaidh fíordheimhnithe simplí (ag úsáid cuntas DSA) + grúpaí atá mapáilte go dinimiciúil mar róil:

    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'

Pribhléid

    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

Liosta pribhléid le haghaidh socruithe. Breathnaigh ar an gcáipéisíocht agus ar an GUI le seiceáil cé na hathróga is gá a shocrú ag brath ar an gcineál pribhléide.

Comhcheanglaítear na heilimintí seo leis na luachanna réamhshocraithe seo a leanas:

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

Róil (taobh istigh de Nexus ciallaíonn sé seo)

    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

Liosta róil le haghaidh socruithe.

Baill

    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

Liosta úsáideoirí/cuntais áitiúla (neamh-LDAP) le cruthú i nexus.

Liosta úsáideoirí/cuntais áitiúla (neamh-LDAP) le cruthú i Nexus.

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

Ldap mapáil úsáideoirí/róil. Stáit absent bainfidh sé róil ó úsáideoir reatha má tá ceann ann cheana.
Ní scriostar úsáideoirí ldap. Má dhéantar iarracht ról a shocrú d'úsáideoir nach bhfuil ann, beidh earráid ann.

Roghnóirí ábhar

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

Chun tuilleadh eolais a fháil faoin roghnóir ábhair, féach Doiciméadúchán.

Chun an roghnóir ábhair a úsáid, cuir pribhléid nua leis type: repository-content-selector agus ábharthacontentSelector

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

Blobstores agus stórtha

    nexus_delete_default_repos: false

Scrios na stórtha ón nexus suiteáil cumraíocht réamhshocraithe tosaigh. Ní dhéantar an chéim seo ach amháin ar shuiteáil den chéad uair (nuair nexus_data_dir aimsithe folamh).

Taisclanna a bhaint as an gcumraíocht réamhshocraithe réamhshocraithe do Nexus. Ní dhéantar an chéim seo ach amháin le linn na chéad suiteála (nuair nexus_data_dir folamh).

    nexus_delete_default_blobstore: false

Scrios an blobstore réamhshocraithe ón nexus shuiteáil cumraíocht réamhshocraithe tosaigh. Is féidir é seo a dhéanamh ach amháin má nexus_delete_default_repos: true agus tá sainráite ag gach stór cumraithe (féach thíos). blob_store: custom. Ní dhéantar an chéim seo ach amháin ar shuiteáil den chéad uair (nuair nexus_data_dir aimsithe folamh).

Tá baint stórála blobaí (déantúsáin dhénártha) díchumasaithe de réir réamhshocraithe ón gcumraíocht tosaigh. Chun stóráil blob a bhaint (déantúsáin dhénártha), cas as nexus_delete_default_repos: true. Ní dhéantar an chéim seo ach amháin le linn na chéad suiteála (nuair nexus_data_dir folamh).

    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 Cruthaigh. Ní féidir cosán blobstore agus blobstore stór a nuashonrú tar éis cruthú tosaigh (déanfar neamhaird ar aon nuashonrú anseo nuair a athsholáthrófar é).

Soláthraítear é mar áis chun blobstore a chumrú ar S3 agus ní cuid de na tástálacha uathoibrithe a reáchtáilimid ar travis é. Tabhair faoi deara le do thoil nach moltar stóráil ar S3 ach amháin i gcásanna a imlonnaítear ar AWS.

Cruthú Blobstores. Ní féidir an cosán stórála agus an stór stórála a nuashonrú tar éis an cruthú tosaigh (déanfar neamhaird ar aon nuashonrú anseo nuair a bheidh sé suiteáilte arís).

Soláthraítear stór blobaí ar S3 mar áis. Tabhair faoi deara le do thoil nach moltar stóráil S3 ach amháin i gcásanna a imlonnaítear ar 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

Tá cumraíocht shamplach thuas seachfhreastalaí Maigheann.

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

Maven stórtha óstáilte cumraíocht. Tá cumraíocht taisce diúltach roghnach agus beidh sé réamhshocraithe chuig na luachanna thuas má fhágtar ar lár é.

Cumraíocht stórtha óstáilte Maigheann. Tá an chumraíocht taisce diúltach (-1) roghnach agus beidh sé réamhshocraithe chuig na luachanna thuas mura bhfuil sé sonraithe.

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

Cumraíocht grúpaí Maigheann.

Comhcheanglaítear na trí chineál stórtha leis na luachanna réamhshocraithe seo a leanas:

    _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

Cineálacha stórtha Docker, Pypi, Raw, Rubygems, Bower, NPM, Git-LFS agus yum:
féach defaults/main.yml do na roghanna seo:

Tá stórtha Docker, Pypi, Raw, Rubygems, Bower, NPM, Git-LFS agus yum díchumasaithe de réir réamhshocraithe:
Féach defaults/main.yml do na roghanna seo:

      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

Tabhair faoi deara go mb'fhéidir go mbeidh ort scóip slándála áirithe a chumasú más mian leat úsáid a bhaint as cineálacha eile stórtha seachas maven. Tá sé seo bréagach de réir réamhshocraithe

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

Is féidir Réimse Úsáideora Cianda a chumasú freisin trí úsáid a bhaint as

nexus_rut_auth_realm: true

agus is féidir an teideal a shaincheapadh trí shainiú

nexus_rut_auth_header: "CUSTOM_HEADER"

Tascanna sceidealta

    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"

Tascanna sceidealta le haghaidh socruithe. typeId agus tasc sonrachtaskProperties/booleanTaskProperties is féidir leat buille faoi thuairim ceachtar:

  • ón ordlathas cineál Java org.sonatype.nexus.scheduling.TaskDescriptorSupport
  • ag seiceáil an fhoirm cruthú tascanna HTML i do bhrabhsálaí
  • ó féachaint ar iarratais AJAX sa bhrabhsálaí agus tasc á shocrú de láimh.

Ní mór airíonna tascanna a dhearbhú sa bhloc yaml ceart ag brath ar a gcineál:

  • taskProperties do gach maoin teaghrán (.i. ainmneacha stórtha, ainmneacha stórtha, tréimhsí ama...).
  • booleanTaskProperties do gach airí loighciúil (i.e. ticbhoscaí go príomha i GUI an taisc um chruthú nexus).

Cúltacaí

      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)

Ní bheidh cúltaca cumraithe go dtí go n-aistríonn tú nexus_backup_configure в true.
Sa chás seo, beidh an tasc script sceidealta a chumrú a reáchtáil ar Nexus
ag an eatramh sonraithe i nexus_backup_cron (réamhshocraithe 21:00 gach lá).
Féach [teimpléad groovy don tasc seo] (templates/backup.groovy.j2) le haghaidh sonraí.
Tá an tasc sceidealta seo neamhspleách ar dhaoine eile nexus_scheduled_tasksatá agat
fhógairt i do leabhar súgartha.

Más mian leat cúltacaí a rothlú/scriosadh, suiteáil nexus_backup_rotate: true agus cumraigh líon na gcúltacaí ar mhaith leat a shábháil ag baint úsáide as nexus_backup_keep_rotations (réamhshocraithe 4).

Agus rothlú á úsáid agat, más mian leat spás diosca breise a shábháil le linn an phróisis chúltaca,
Is féidir leat a shuiteáil nexus_backup_rotate_first: true. Cumróidh sé seo réamhuainíocht/scriosadh roimh chúltaca. De réir réamhshocraithe, tarlaíonn rothlú tar éis cúltaca a chruthú. Tabhair faoi deara go bhfuil sa chás seo na cúltacaí d'aois
scriosfar é sula ndéanfar an cúltaca reatha.

Nós imeachta aisghabhála

Rith leabhar súgartha le paraiméadar -e nexus_restore_point=<YYYY-MM-dd-HH-mm-ss>
(mar shampla, 2017-12-17-21-00-00 don 17 Nollaig, 2017 ag 21:00

nexus a bhaint

Rabhadh: Scriosfaidh sé seo do shonraí reatha go hiomlán. Bí cinnte cúltaca a dhéanamh níos luaithe más gá

Bain úsáid as athróg nexus_purgemás gá duit atosú ón tús agus an nasc a athshuiteáil agus na sonraí go léir a bhaint.

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

Athraigh pasfhocal an riarthóra tar éis an chéad suiteáil

    nexus_default_admin_password: 'admin123'

Níor cheart é seo a athrú i do leabhar súgartha. Tá an pasfhocal réamhshocraithe admin Nexus ag an athróg seo nuair a suiteáladh é ar dtús agus cinntíonn sé gur féidir linn an pasfhocal riaracháin a athrú go nexus_admin_password.

Más mian leat an focal faire riarthóra a athrú tar éis an chéad suiteáil, is féidir leat é a athrú go sealadach chuig an seanfhocal faire ón líne ordaithe. Tar éis athrú nexus_admin_password i do leabhar súgartha is féidir leat a rith:

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

Cainéal teileagram ar Sonatype Nexus: https://t.me/ru_nexus_sonatype

Ní féidir ach le húsáideoirí cláraithe páirt a ghlacadh sa suirbhé. Sínigh isteach, le do thoil.

Cad iad na stórtha déantán a úsáideann tú?

  • Sonatype nexus saor in aisce,

  • Sonatype Nexus íoctha

  • Saor in aisce an t-amhrán artifactory

  • Artifactory íoctha

  • Harbor

  • Laíon

Vótáil 9 úsáideoir. Staon 3 úsáideoir.

Foinse: will.com

Add a comment