Sonatype Nexus是一个集成平台,开发人员可以使用它来代理,存储和管理Java(Maven)依赖项,Docker,Python,Ruby,NPM,Bower图像,RPM软件包,gitlfs,Apt,Go,Nuget,以及分发其软件规定。
为什么需要Sonatype Nexus?
- 存储私人物品;
- 用于缓存从Internet下载的工件;
Sonatype Nexus基本套件中支持的工件:
- Java,Maven(罐子)
- 码头工人
- Python(点子)
- 红宝石(宝石)
- NPM
- 凉亭
- 百胜(rpm)
- gitlfs
- 生的
- 公寓(Deb)
- 去吧
- 努吉特
社区支持的工件:
要求条件
- 了解有关在互联网上使用ansible的信息。
- 在剧本开始的工作站上安装ansible
pip install ansible
。 - 在剧本开始的工作站上安装geerlingguy.java 。
- 在剧本开始的工作站上安装geerlingguy.apache 。
- 此角色已在CentOS 7,Ubuntu Xenial(16.04)和Bionic(18.04),Debian Jessie和Stretch上进行了测试
jmespath
库必须安装在剧本开始的工作站上。 要安装,请运行sudo pip install -r requirements.txt
- 将剧本文件(下面的示例)保存到nexus.yml文件中
- 运行nexus
ansible-playbook -i host nexus.yml
的安装ansible-playbook -i host nexus.yml
Ansible-playbook示例,该示例使用Maven(java),Docker,Python,Ruby,NPM,Bower,RPM和gitlfs在没有LDAP的情况下安装nexus。
--- - 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: support@company.com 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
变量来修复版本。 请参阅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 timezone
名称,可与下面的cron表达式结合使用,用于nexus_scheduled任务。
连结端口和上下文路径
nexus_default_port: 8081 nexus_default_context_path: '/'
Java连接过程的端口和上下文路径。 nexus_default_context_path
设置时必须包含斜杠,例如。: nexus_default_context_path: '/nexus/'
。
Nexus用户和组
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
包含所有配置,存储库和已加载的工件。 可以配置自定义Blobstores 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的默认设置。 如果您尚未阅读联系系统要求的内存部分,并且不了解它们在做什么, 请不要更改这些值 。
作为第二个警告,以下是上述文档的摘录:
不建议将JVM堆内存增加到建议值之外,以提高性能。 实际上,这可能会产生相反的效果,导致操作系统不必要的操作。
管理员密码
nexus_admin_password: 'changeme'
“ admin”帐户的密码是要配置的。 这仅适用于第一个默认安装 。 如果要稍后使用角色进行更改,请参阅[首次安装后更改管理员密码](#change-admin-password-首次安装后)。
强烈建议您将密码以明文形式存储在剧本中,但要使用[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: "admin@example.com" 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
(默认)时,以上证书必须存在于您的剧本目录中,并将被复制到服务器并在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: "admin@example.com"
设置默认管理员电子邮件
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
用于简单身份验证的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
要配置的特权列表。 请参阅文档和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: support@company.com # password: "s3cr3t" # roles: # - developers # role ID
在本地创建的本地(非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
Blobstore和存储库
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 }}"
要创建的Blobstore 。 初始创建后无法更新blobstore路径和存储库blobstore(此处的任何更新在重新配置时都将被忽略)。
为方便起见,在S3上配置blobstore并不是我们在travis上运行的自动化测试的一部分。 请注意,仅建议将AWS上部署的实例存储在S3上。
创建Blobstore 初始创建后无法更新存储路径和存储库(重新安装时将忽略此处的任何更新)。
为方便起见,提供了在S3上配置Blob存储的功能。 请注意,建议仅对在AWS上部署的实例使用S3存储。
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"
Maven 托管存储库配置。 负缓存配置是可选的,如果省略,则默认为上述值。
托管 Maven 存储库的配置。 负缓存配置(-1)是可选的,如果未指定,则默认为上述值。
nexus_repos_maven_group: - name: public member_repos: - central - jboss
Maven 组配置。
所有三种类型的存储库都与以下默认值结合使用:
_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: alerts@example.org # 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: alerts@example.org # 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: alerts@example.org # 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: alerts@example.org # optional # taskProperties: # age: "24"
计划任务进行配置。 可以猜测typeId
和特定taskProperties
任务的taskProperties
/ booleanTaskProperties
:
- 从Java类型层次结构
org.sonatype.nexus.scheduling.TaskDescriptorSupport
- 检查HTML表单以在浏览器中创建任务
- 从手动设置任务时在浏览器中查看AJAX请求。
必须根据其类型在正确的yaml块中声明任务的属性 :
- 所有字符串属性(即存储库名称,存储库名称,时间段...)的
taskProperties
。 - 所有逻辑属性的
booleanTaskProperties
(即,基本关系创建任务的图形界面中的复选框)。
后备
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模板](模板/ backup.groovy.j2)。
此计划任务独立于您的其他nexus_scheduled_tasks
在您的剧本中宣布。
如果要循环/删除备份,请设置nexus_backup_rotate: true
并使用nexus_backup_rotate: true
配置要保存的备份数量(默认为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
:
ansible-playbook -i your/inventory.ini your_playbook.yml -e nexus_default_admin_password=oldPassword
Nexus Sonatype: https://t.me/ru_nexus_sonatype