Sonatype Nexus เป็นแพลตฟอร์มบูรณาการที่นักพัฒนาสามารถใช้พร็อกซี จัดเก็บและจัดการการพึ่งพา Java (Maven), Docker, Python, Ruby, NPM, อิมเมจ Bower, แพ็คเกจ RPM, gitlfs, Apt, Go, Nuget และกระจายความปลอดภัยของซอฟต์แวร์
ทำไมคุณถึงต้องการ Sonatype Nexus?
- สำหรับจัดเก็บสิ่งประดิษฐ์ส่วนตัว
- สำหรับแคชสิ่งประดิษฐ์ที่ดาวน์โหลดจากอินเทอร์เน็ต
อาร์ติแฟกต์ที่รองรับในแพ็คเกจ Sonatype Nexus พื้นฐาน:
- ชวา, มาเวน (ขวด)
- นักเทียบท่า
- หลาม (pip)
- ทับทิม (อัญมณี)
- NPM
- ซุ้มไม้ในสวน
- ยำ (รอบต่อนาที)
- gitlfs
- ดิบ
- อพาร์ทเมนท์ (deb)
- Go
- Nuget
สิ่งประดิษฐ์ที่สนับสนุนโดยชุมชน:
- แต่ง
- โคนัน
- ซีแพน
- เอลป้า
- หางเสือ
- P2
- R
การติดตั้ง Sonatype Nexus โดยใช้ https://github.com/ansible-ThoTeam/nexus3-oss
ความต้องการ
- อ่านเกี่ยวกับการใช้ ansible บนอินเทอร์เน็ต
- ติดตั้งได้
pip install ansible
บนเวิร์กสเตชันที่ Playbook ทำงาน - ติดตั้ง
geerlingguy.java บนเวิร์กสเตชันที่ Playbook ทำงาน - ติดตั้ง
geerlingguy.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
ตัวอย่างคู่มือการเล่นสำหรับการติดตั้ง Nexus ที่ไม่มี LDAP พร้อมที่เก็บ Maven (java), Docker, Python, Ruby, NPM, Bower, RPM และ 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'] }
ภาพหน้าจอ:
บทบาทที่เปลี่ยนแปลงได้
ตัวแปรบทบาท
ตัวแปรที่มีค่าเริ่มต้น (ดู default/main.yml
):
ตัวแปรทั่วไป
nexus_version: ''
nexus_timezone: 'UTC'
ตามค่าเริ่มต้น บทบาทจะติดตั้ง Nexus เวอร์ชันล่าสุดที่มีอยู่ คุณสามารถแก้ไขเวอร์ชันได้โดยการเปลี่ยนตัวแปร nexus_version
. ดูรุ่นที่มีจำหน่ายได้ที่
หากคุณเปลี่ยนเป็นเวอร์ชันใหม่ บทบาทจะพยายามอัปเดตการติดตั้ง Nexus ของคุณ
หากคุณใช้ Nexus เวอร์ชันเก่ากว่ารุ่นล่าสุด คุณควรตรวจสอบให้แน่ใจว่าคุณไม่ได้ใช้คุณสมบัติที่ไม่มีในรุ่นที่ติดตั้ง (เช่น การโฮสต์พื้นที่เก็บข้อมูล yum นั้นพร้อมใช้งานสำหรับ Nexus ที่มากกว่า 3.8.0, git lfs repo สำหรับ Nexus มากกว่า 3.3.0 เป็นต้น)
nexus timezone
คือชื่อของเขตเวลา Java ซึ่งสามารถมีประโยชน์เมื่อใช้ร่วมกับนิพจน์ cron ต่อไปนี้สำหรับงาน nexus_scheduled
พอร์ต 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
nexus_installation_dir
มีไฟล์ปฏิบัติการที่ติดตั้งไว้nexus_data_dir
มีการกำหนดค่า ที่เก็บ และสิ่งประดิษฐ์ที่ดาวน์โหลดทั้งหมด เส้นทาง Blobstore แบบกำหนดเอง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 กรุณาอย่าเปลี่ยนค่าเหล่านี้ หากคุณยังไม่ได้อ่าน
เพื่อเป็นการเตือนครั้งที่สอง นี่เป็นข้อความที่ตัดตอนมาจากเอกสารข้างต้น:
ไม่แนะนำให้เพิ่มหน่วยความจำฮีป JVM เกินค่าที่แนะนำเพื่อพยายามปรับปรุงประสิทธิภาพ ซึ่งจริงๆ แล้วอาจมีผลตรงกันข้าม ส่งผลให้ระบบปฏิบัติการต้องทำงานโดยไม่จำเป็น
รหัสผ่านผู้ดูแลระบบ
nexus_admin_password: 'changeme'
รหัสผ่านบัญชี “ผู้ดูแลระบบ” สำหรับการตั้งค่า ใช้งานได้กับการติดตั้งเริ่มต้นครั้งแรกเท่านั้น. โปรดดู [เปลี่ยนรหัสผ่านผู้ดูแลระบบหลังการติดตั้งครั้งแรก](# change-admin-password-after-first-install) หากคุณต้องการเปลี่ยนในภายหลังโดยใช้บทบาท
ขอแนะนำอย่างยิ่งว่าอย่าเก็บรหัสผ่านของคุณเป็นข้อความที่ชัดเจนใน Playbook แต่ควรใช้ [การเข้ารหัสแบบ ansible-vault] (
การเข้าถึงแบบไม่ระบุชื่อตามค่าเริ่มต้น
nexus_anonymous_access: false
การเข้าถึงแบบไม่ระบุชื่อจะถูกปิดใช้งานตามค่าเริ่มต้น อ่านเพิ่มเติมเกี่ยวกับ
ชื่อโฮสต์สาธารณะ
nexus_public_hostname: 'nexus.vm'
nexus_public_scheme: https
ชื่อโดเมนและรูปแบบแบบเต็ม (https หรือ http) ที่อินสแตนซ์ Nexus จะพร้อมใช้งานสำหรับลูกค้า
การเข้าถึง 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
ติดตั้ง
ในการดำเนินการนี้ คุณจะต้องติดตั้ง httpd หมายเหตุ: เมื่อใด httpd_setup_enable
ตั้งค่าtrue
, ผู้ติดต่อ Nexus 127.0.0.1:8081 ดังนั้น ไม่ สามารถเข้าถึงได้โดยตรงผ่านพอร์ต HTTP 8081 จากที่อยู่ IP ภายนอก
ชื่อโฮสต์เริ่มต้นที่ใช้คือ 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: []
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
ตัวอย่างการกำหนดค่า 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_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
ตัวอย่างการกำหนดค่า 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_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
รายการ
องค์ประกอบเหล่านี้จะรวมกับค่าเริ่มต้นต่อไปนี้:
_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
รายชื่อผู้ใช้/บัญชีภายใน (ไม่ใช่ LDAP) ที่จะสร้างใน Nexus
รายชื่อผู้ใช้/บัญชีภายใน (ที่ไม่ใช่ LDAP) ที่จะสร้างใน Nexus
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
Blobstores และที่เก็บ
nexus_delete_default_repos: false
ลบที่เก็บออกจาก Nexus ติดตั้งการกำหนดค่าเริ่มต้นเริ่มต้น ขั้นตอนนี้จะดำเนินการเฉพาะกับการติดตั้งครั้งแรกเท่านั้น (เมื่อ nexus_data_dir
ตรวจพบว่าว่างเปล่า)
การลบที่เก็บข้อมูลออกจากการกำหนดค่าเริ่มต้นเริ่มต้นสำหรับ Nexus ขั้นตอนนี้จะดำเนินการระหว่างการติดตั้งครั้งแรกเท่านั้น (เมื่อ nexus_data_dir
ว่างเปล่า).
nexus_delete_default_blobstore: false
ลบ blobstore เริ่มต้นออกจากการกำหนดค่าเริ่มต้นเริ่มต้นของ Nexus ติดตั้ง ซึ่งสามารถทำได้ก็ต่อเมื่อ nexus_delete_default_repos: true
และที่เก็บที่กำหนดค่าทั้งหมด (ดูด้านล่าง) มีความชัดเจน blob_store: custom
. ขั้นตอนนี้จะดำเนินการเฉพาะกับการติดตั้งครั้งแรกเท่านั้น (เมื่อ nexus_data_dir
ตรวจพบว่าว่างเปล่า)
การลบที่เก็บข้อมูล 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 }}"
การกำหนดค่า blobstore บน S3 มีให้เพื่อความสะดวกและไม่ได้เป็นส่วนหนึ่งของการทดสอบอัตโนมัติที่เราดำเนินการบน Travis โปรดทราบว่าแนะนำให้จัดเก็บบน S3 สำหรับอินสแตนซ์ที่ใช้งานบน AWS เท่านั้น
การสร้าง
การตั้งค่าที่เก็บข้อมูล Blob บน S3 มีให้เพื่อความสะดวก โปรดทราบว่าแนะนำให้ใช้พื้นที่จัดเก็บ 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
ด้านบนเป็นตัวอย่างการกำหนดค่า
nexus_repos_maven_hosted:
- name: private-release
version_policy: release
write_policy: allow_once # one of "allow", "allow_once" or "deny"
Maven
องค์ประกอบ
nexus_repos_maven_group:
- name: public
member_repos:
- central
- jboss
องค์ประกอบ
พื้นที่เก็บข้อมูลทั้งสามประเภทจะรวมกับค่าเริ่มต้นต่อไปนี้:
_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 นี่เป็นเท็จโดยค่าเริ่มต้น
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)
สำรองข้อมูล
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
ที่คุณ
ประกาศใน Playbook ของคุณ
หากคุณต้องการหมุน/ลบข้อมูลสำรอง ให้ติดตั้ง nexus_backup_rotate: true
และกำหนดจำนวนข้อมูลสำรองที่คุณต้องการบันทึก nexus_backup_keep_rotations
(ค่าเริ่มต้น 4)
เมื่อใช้การหมุน หากคุณต้องการประหยัดพื้นที่ดิสก์เพิ่มเติมในระหว่างกระบวนการสำรองข้อมูล
คุณสามารถติดตั้ง nexus_backup_rotate_first: true
. วิธีนี้จะกำหนดค่าการหมุนเวียนล่วงหน้า/การลบก่อนการสำรองข้อมูล ตามค่าเริ่มต้น การหมุนจะเกิดขึ้นหลังจากสร้างข้อมูลสำรองแล้ว โปรดทราบว่าในกรณีนี้การสำรองข้อมูลเก่า
จะถูกลบก่อนที่จะทำการสำรองข้อมูลปัจจุบัน
ขั้นตอนการกู้คืน
เรียกใช้ Playbook ด้วยพารามิเตอร์ -e nexus_restore_point=<YYYY-MM-dd-HH-mm-ss>
(เช่น 2017-12-17-21-00-00 สำหรับวันที่ 17 ธันวาคม 2017 เวลา 21:00 น.
กำลังนำ Nexus ออก
คำเตือน: การดำเนินการนี้จะลบข้อมูลปัจจุบันของคุณโดยสิ้นเชิง อย่าลืมสำรองข้อมูลไว้ก่อนหน้านี้หากจำเป็น
ใช้ตัวแปร nexus_purge
หากคุณต้องการรีสตาร์ทตั้งแต่ต้นและติดตั้งอินสแตนซ์ Nexus ใหม่โดยลบข้อมูลทั้งหมดออก
ansible-playbook -i your/inventory.ini your_nexus_playbook.yml -e nexus_purge=true
เปลี่ยนรหัสผ่านผู้ดูแลระบบหลังจากการติดตั้งครั้งแรก
nexus_default_admin_password: 'admin123'
ไม่ควรเปลี่ยนแปลงสิ่งนี้ใน Playbook ของคุณ. ตัวแปรนี้จะถูกเติมด้วยรหัสผ่านผู้ดูแลระบบ 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:
เฉพาะผู้ใช้ที่ลงทะเบียนเท่านั้นที่สามารถเข้าร่วมในการสำรวจได้
คุณใช้ที่เก็บสิ่งประดิษฐ์ใด
-
Sonatype Nexus ให้บริการฟรี
-
Sonatype Nexus จ่ายแล้ว
-
Artifactory ฟรี
-
ชำระค่าโรงงานแล้ว
-
ท่าเรือ
-
จาว
ผู้ใช้ 9 คนโหวต ผู้ใช้ 3 รายงดออกเสียง
ที่มา: will.com