Skip to content

Commit

Permalink
Merge pull request #20 from CloudKrafter/import-privileges-tasks
Browse files Browse the repository at this point in the history
Manage privileges using the API
  • Loading branch information
brianveltman authored Feb 13, 2025
2 parents 154c113 + eb5aa02 commit f737de6
Show file tree
Hide file tree
Showing 33 changed files with 73 additions and 139 deletions.
1 change: 1 addition & 0 deletions roles/config_api/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ nexus_admin_password: changeme
nexus_enable_pro_version: false

nexus_config_dry_run: false
nexus_enforce_desired_state: false

nexus_ssl_truststore: []

Expand Down
2 changes: 1 addition & 1 deletion roles/config_api/tasks/blobstore-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@
method: DELETE
with_items:
- "{{ nxs_delete_blobstores | default([]) }}"
when: nxs_delete_blobstores | length > 0
when: nxs_delete_blobstores | length > 0 and nexus_enforce_desired_state | bool
tags: blobstores
2 changes: 1 addition & 1 deletion roles/config_api/tasks/cleanup-policies-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_cleanuppolicies | default([]) }}"
when: nxs_delete_cleanuppolicies | length > 0
when: nxs_delete_cleanuppolicies | length > 0 and nexus_enforce_desired_state | bool
tags: cleanup-policies
when: not nexus_config_dry_run
tags: cleanup-policies
2 changes: 1 addition & 1 deletion roles/config_api/tasks/content-selectors-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_content_selectors | default([]) }}"
when: nxs_delete_content_selectors | length > 0
when: nxs_delete_content_selectors | length > 0 and nexus_enforce_desired_state | bool
tags: content-selectors
when: not nexus_config_dry_run
tags: content-selectors
2 changes: 1 addition & 1 deletion roles/config_api/tasks/ldap-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_ldap_connetions | default([]) }}"
when: nxs_delete_ldap_connetions | length > 0
when: nxs_delete_ldap_connetions | length > 0 and nexus_enforce_desired_state | bool
tags: ldap
when: not nexus_config_dry_run
tags: ldap
Expand Down
2 changes: 1 addition & 1 deletion roles/config_api/tasks/license-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
force_basic_auth: true
timeout: "{{ nexus_api_timeout }}"
status_code: 204
when: not nexus_enable_pro_version
when: not nexus_enable_pro_version and nexus_enforce_desired_state | bool
changed_when: true
tags: license

Expand Down
13 changes: 7 additions & 6 deletions roles/config_api/tasks/privileges-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_app_privileges | default([]) }}"
when: nxs_delete_app_privileges | length > 0
when: nxs_delete_app_privileges | length > 0 and nexus_enforce_desired_state | bool
tags: privileges
- name: Delete Script Privileges using Nexus API
ansible.builtin.include_tasks: privileges-api.yml
Expand All @@ -324,7 +324,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_script_privileges | default([]) }}"
when: nxs_delete_script_privileges | length > 0
when: nxs_delete_script_privileges | length > 0 and nexus_enforce_desired_state | bool
tags: privileges
- name: Delete Wildcard Privileges using Nexus API
ansible.builtin.include_tasks: privileges-api.yml
Expand All @@ -334,8 +334,9 @@
method: DELETE
with_items:
- "{{ nxs_delete_wildcard_privileges | default([]) }}"
when: nxs_delete_wildcard_privileges | length > 0
when: nxs_delete_wildcard_privileges | length > 0 and nexus_enforce_desired_state | bool
tags: privileges

- name: Delete Repository Content Selector Privileges using Nexus API
ansible.builtin.include_tasks: privileges-api.yml
vars:
Expand All @@ -344,7 +345,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_repository_content_selector_privileges | default([]) }}"
when: nxs_delete_repository_content_selector_privileges | length > 0
when: nxs_delete_repository_content_selector_privileges | length > 0 and nexus_enforce_desired_state | bool
tags: privileges
- name: Delete Repository Admin Privileges using Nexus API
ansible.builtin.include_tasks: privileges-api.yml
Expand All @@ -354,7 +355,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_repository_admin_privileges | default([]) }}"
when: nxs_delete_repository_admin_privileges | length > 0
when: nxs_delete_repository_admin_privileges | length > 0 and nexus_enforce_desired_state | bool
tags: privileges
- name: Delete Repository View Privileges using Nexus API
ansible.builtin.include_tasks: privileges-api.yml
Expand All @@ -364,7 +365,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_repository_view_privileges | default([]) }}"
when: nxs_delete_repository_view_privileges | length > 0
when: nxs_delete_repository_view_privileges | length > 0 and nexus_enforce_desired_state | bool
tags: privileges
when: not nexus_config_dry_run
tags: privileges
2 changes: 1 addition & 1 deletion roles/config_api/tasks/process_blobstores.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,6 @@
loop: "{{ nxs_delete_blobstores }}"
loop_control:
loop_var: blobstore
when: nxs_delete_blobstores | length > 0
when: nxs_delete_blobstores | length > 0 and nexus_enforce_desired_state | bool
changed_when: true
tags: blobstores
4 changes: 2 additions & 2 deletions roles/config_api/tasks/repositories-apt-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_apt_hosted_repos | default([]) }}"
when: nxs_delete_apt_hosted_repos | length > 0
when: nxs_delete_apt_hosted_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- apt
- apt-hosted
Expand All @@ -252,7 +252,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_apt_proxy_repos | default([]) }}"
when: nxs_delete_apt_proxy_repos | length > 0
when: nxs_delete_apt_proxy_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- apt
- apt-proxy
Expand Down
6 changes: 3 additions & 3 deletions roles/config_api/tasks/repositories-cargo-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_cargo_hosted_repos | default([]) }}"
when: nxs_delete_cargo_hosted_repos | length > 0
when: nxs_delete_cargo_hosted_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- cargo
- cargo-hosted
Expand All @@ -326,7 +326,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_cargo_proxy_repos | default([]) }}"
when: nxs_delete_cargo_proxy_repos | length > 0
when: nxs_delete_cargo_proxy_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- cargo
- cargo-proxy
Expand All @@ -340,7 +340,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_cargo_group_repos | default([]) }}"
when: nxs_delete_cargo_group_repos | length > 0
when: nxs_delete_cargo_group_repos | length > 0 and nexus_enforce_desired_state | bool
tags: cargo
when: not nexus_config_dry_run
tags:
Expand Down
2 changes: 1 addition & 1 deletion roles/config_api/tasks/repositories-cocoapods-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_cocoapods_proxy_repos | default([]) }}"
when: nxs_delete_cocoapods_proxy_repos | length > 0
when: nxs_delete_cocoapods_proxy_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- cocoapods
- cocoapods-proxy
Expand Down
2 changes: 1 addition & 1 deletion roles/config_api/tasks/repositories-composer-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_composer_proxy_repos | default([]) }}"
when: nxs_delete_composer_proxy_repos | length > 0
when: nxs_delete_composer_proxy_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- composer
- composer-proxy
Expand Down
4 changes: 2 additions & 2 deletions roles/config_api/tasks/repositories-conan-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_conan_hosted_repos | default([]) }}"
when: nxs_delete_conan_hosted_repos | length > 0
when: nxs_delete_conan_hosted_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- conan
- conan-hosted
Expand All @@ -249,7 +249,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_conan_proxy_repos | default([]) }}"
when: nxs_delete_conan_proxy_repos | length > 0
when: nxs_delete_conan_proxy_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- conan
- conan-proxy
Expand Down
2 changes: 1 addition & 1 deletion roles/config_api/tasks/repositories-conda-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_conda_proxy_repos | default([]) }}"
when: nxs_delete_conda_proxy_repos | length > 0
when: nxs_delete_conda_proxy_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- conda
- conda-proxy
Expand Down
6 changes: 3 additions & 3 deletions roles/config_api/tasks/repositories-docker-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_docker_hosted_repos | default([]) }}"
when: nxs_delete_docker_hosted_repos | length > 0
when: nxs_delete_docker_hosted_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- docker
- docker-hosted
Expand All @@ -347,7 +347,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_docker_proxy_repos | default([]) }}"
when: nxs_delete_docker_proxy_repos | length > 0
when: nxs_delete_docker_proxy_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- docker
- docker-proxy
Expand All @@ -361,7 +361,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_docker_group_repos | default([]) }}"
when: nxs_delete_docker_group_repos | length > 0
when: nxs_delete_docker_group_repos | length > 0 and nexus_enforce_desired_state | bool
tags: docker
when: not nexus_config_dry_run | bool
tags:
Expand Down
2 changes: 1 addition & 1 deletion roles/config_api/tasks/repositories-gitlfs-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_gitlfs_hosted_repos | default([]) }}"
when: nxs_delete_gitlfs_hosted_repos | length > 0
when: nxs_delete_gitlfs_hosted_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- gitlfs
- gitlfs-hosted
Expand Down
4 changes: 2 additions & 2 deletions roles/config_api/tasks/repositories-go-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_go_proxy_repos | default([]) }}"
when: nxs_delete_go_proxy_repos | length > 0
when: nxs_delete_go_proxy_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- go
- go-proxy
Expand All @@ -235,7 +235,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_go_group_repos | default([]) }}"
when: nxs_delete_go_group_repos | length > 0
when: nxs_delete_go_group_repos | length > 0 and nexus_enforce_desired_state | bool
tags: go
when: not nexus_config_dry_run
tags:
Expand Down
4 changes: 2 additions & 2 deletions roles/config_api/tasks/repositories-helm-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_helm_hosted_repos | default([]) }}"
when: nxs_delete_helm_hosted_repos | length > 0
when: nxs_delete_helm_hosted_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- helm
- helm-hosted
Expand All @@ -249,7 +249,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_helm_proxy_repos | default([]) }}"
when: nxs_delete_helm_proxy_repos | length > 0
when: nxs_delete_helm_proxy_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- helm
- helm-proxy
Expand Down
6 changes: 3 additions & 3 deletions roles/config_api/tasks/repositories-maven-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_mvn_hosted_repos | default([]) }}"
when: nxs_delete_mvn_hosted_repos | length > 0
when: nxs_delete_mvn_hosted_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- maven
- maven-hosted
Expand All @@ -331,7 +331,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_mvn_proxy_repos | default([]) }}"
when: nxs_delete_mvn_proxy_repos | length > 0
when: nxs_delete_mvn_proxy_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- maven
- maven-proxy
Expand All @@ -345,7 +345,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_mvn_group_repos | default([]) }}"
when: nxs_delete_mvn_group_repos | length > 0
when: nxs_delete_mvn_group_repos | length > 0 and nexus_enforce_desired_state | bool
tags: maven
when: not nexus_config_dry_run | bool
tags:
Expand Down
6 changes: 3 additions & 3 deletions roles/config_api/tasks/repositories-npm-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_npm_hosted_repos | default([]) }}"
when: nxs_delete_npm_hosted_repos | length > 0
when: nxs_delete_npm_hosted_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- npm
- npm-hosted
Expand All @@ -326,7 +326,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_npm_proxy_repos | default([]) }}"
when: nxs_delete_npm_proxy_repos | length > 0
when: nxs_delete_npm_proxy_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- npm
- npm-proxy
Expand All @@ -340,7 +340,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_npm_group_repos | default([]) }}"
when: nxs_delete_npm_group_repos | length > 0
when: nxs_delete_npm_group_repos | length > 0 and nexus_enforce_desired_state | bool
tags: npm
when: not nexus_config_dry_run
tags:
Expand Down
6 changes: 3 additions & 3 deletions roles/config_api/tasks/repositories-nuget-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_nuget_hosted_repos | default([]) }}"
when: nxs_delete_nuget_hosted_repos | length > 0
when: nxs_delete_nuget_hosted_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- nuget
- nuget-hosted
Expand All @@ -328,7 +328,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_nuget_proxy_repos | default([]) }}"
when: nxs_delete_nuget_proxy_repos | length > 0
when: nxs_delete_nuget_proxy_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- nuget
- nuget-proxy
Expand All @@ -342,7 +342,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_nuget_group_repos | default([]) }}"
when: nxs_delete_nuget_group_repos | length > 0
when: nxs_delete_nuget_group_repos | length > 0 and nexus_enforce_desired_state | bool
tags: nuget
when: not nexus_config_dry_run
tags:
Expand Down
2 changes: 1 addition & 1 deletion roles/config_api/tasks/repositories-p2-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_p2_proxy_repos | default([]) }}"
when: nxs_delete_p2_proxy_repos | length > 0
when: nxs_delete_p2_proxy_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- p2
- p2-proxy
Expand Down
6 changes: 3 additions & 3 deletions roles/config_api/tasks/repositories-pypi-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_pypi_hosted_repos | default([]) }}"
when: nxs_delete_pypi_hosted_repos | length > 0
when: nxs_delete_pypi_hosted_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- pypi
- pypi-hosted
Expand All @@ -325,7 +325,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_pypi_proxy_repos | default([]) }}"
when: nxs_delete_pypi_proxy_repos | length > 0
when: nxs_delete_pypi_proxy_repos | length > 0 and nexus_enforce_desired_state | bool
tags:
- pypi
- pypi-proxy
Expand All @@ -339,7 +339,7 @@
method: DELETE
with_items:
- "{{ nxs_delete_pypi_group_repos | default([]) }}"
when: nxs_delete_pypi_group_repos | length > 0
when: nxs_delete_pypi_group_repos | length > 0 and nexus_enforce_desired_state | bool
tags: pypi
when: not nexus_config_dry_run
tags:
Expand Down
Loading

0 comments on commit f737de6

Please sign in to comment.