From 3848391b11287b43167138d8ffd381c5b84cc9eb Mon Sep 17 00:00:00 2001 From: Olivier Clavel Date: Thu, 14 Feb 2019 10:56:53 +0100 Subject: [PATCH] Allow to skip provisionning tasks --- README.md | 30 +++++++- tasks/main.yml | 189 +++++++++++++++++++++++++------------------------ 2 files changed, 126 insertions(+), 93 deletions(-) diff --git a/README.md b/README.md index 035a6c9d..0c7c1133 100644 --- a/README.md +++ b/README.md @@ -724,15 +724,41 @@ ansible-playbook -i your/inventory.ini your_playbook.yml -e nexus_default_admin_ ``` **This variable has no effect if nexus_version is fixed in your vars** -Unless you set this variable, the role will keep the current installed nexus version when running against an already provisionned host. Passing this extra var will trigger automatic latest nexus version detection and upgrade if a newer version is available. +Unless you set this variable, the role will keep the current installed nexus version when running against +an already provisionned host. Passing this extra var will trigger automatic latest nexus version detection and upgrade +if a newer version is available. -**Setting this var as part of your playbook breaks idempotence** (i.e. your playbook will make changes to your system if a new version is available although no parameters have changed) +**Setting this var as part of your playbook breaks idempotence** (i.e. your playbook will make changes to your system +if a new version is available although no parameters have changed) We strongly suggest to use this variable only as an extra var to ansible-playbook call ```bash ansible-playbook -i your/inventory.ini your_playbook.yml -e nexus_upgrade=true ``` +#### Skip provisionning tasks +```yaml + nexus_run_provisionning: false +``` +This var is unset by default and will default to `true`. Setting it to `false` will cause the role to skip all of the +provisionning tasks and will therefore *not create/update*: +* ldap configurations +* content selectors +* privileges +* roles +* users (except checking/updating admin password) +* blobstores +* repositories +* tasks (backup will still be configured if enabled) + +This can save time if you have lots of configured repositories/users/roles... and you want to play the role +to simply check nexus is correctly installed, or restore a backup, or upgrade nexus version. + +We strongly suggest to use this variable only as an extra var to ansible-playbook call +```bash +ansible-playbook -i your/inventory.ini your_playbook.yml -e nexus_run_provisionning=false +``` + ## Dependencies The java and httpd requirements /can/ be fulfilled with the following galaxy roles : diff --git a/tasks/main.yml b/tasks/main.yml index f19692b1..e91b93aa 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -50,133 +50,139 @@ - name: "{{ nexus_blob_names.yum.blob }}" when: (nexus_data_dir_contents.stdout | length == 0) and nexus_delete_default_blobstore -- include_tasks: setup_ldap_each.yml - with_items: "{{ ldap_connections }}" +- block: + - include_tasks: setup_ldap_each.yml + with_items: "{{ ldap_connections }}" + + - include_tasks: create_content_selector_each.yml + with_items: "{{ nexus_content_selectors }}" -- include_tasks: create_content_selector_each.yml - with_items: "{{ nexus_content_selectors }}" + - include_tasks: setup_privilege_each.yml + with_items: "{{ nexus_privileges }}" -- include_tasks: setup_privilege_each.yml - with_items: "{{ nexus_privileges }}" + - include_tasks: setup_role_each.yml + with_items: "{{ nexus_roles }}" -- include_tasks: setup_role_each.yml - with_items: "{{ nexus_roles }}" + - include_tasks: setup_user_each.yml + with_items: "{{ nexus_local_users }}" -- include_tasks: setup_user_each.yml - with_items: "{{ nexus_local_users }}" + - include_tasks: setup_ldap_user_each.yml + with_items: "{{ nexus_ldap_users }}" -- include_tasks: setup_ldap_user_each.yml - with_items: "{{ nexus_ldap_users }}" + - name: "Digest splited blob list var" + include_vars: blob_vars.yml + when: nexus_blob_split -- name: "Digest splited blob list var" - include_vars: blob_vars.yml - when: nexus_blob_split + - include_tasks: create_blobstore_each.yml + with_items: "{{ nexus_blobstores }}" + when: nexus_restore_point is undefined -- include_tasks: create_blobstore_each.yml - with_items: "{{ nexus_blobstores }}" - when: nexus_restore_point is undefined + when: nexus_run_provisionning | default(true) | bool - name: "Restore nexus backup" include_tasks: nexus-restore.yml when: nexus_restore_point is defined -- include_tasks: create_repo_maven_proxy_each.yml - with_items: "{{ nexus_repos_maven_proxy }}" +- block: + - include_tasks: create_repo_maven_proxy_each.yml + with_items: "{{ nexus_repos_maven_proxy }}" -- include_tasks: create_repo_maven_hosted_each.yml - with_items: "{{ nexus_repos_maven_hosted }}" + - include_tasks: create_repo_maven_hosted_each.yml + with_items: "{{ nexus_repos_maven_hosted }}" -- include_tasks: create_repo_maven_group_each.yml - with_items: "{{ nexus_repos_maven_group }}" + - include_tasks: create_repo_maven_group_each.yml + with_items: "{{ nexus_repos_maven_group }}" -- block: - - include_tasks: create_repo_docker_hosted_each.yml - with_items: "{{ nexus_repos_docker_hosted }}" + - block: + - include_tasks: create_repo_docker_hosted_each.yml + with_items: "{{ nexus_repos_docker_hosted }}" - - include_tasks: create_repo_docker_proxy_each.yml - with_items: "{{ nexus_repos_docker_proxy }}" + - include_tasks: create_repo_docker_proxy_each.yml + with_items: "{{ nexus_repos_docker_proxy }}" - - include_tasks: create_repo_docker_group_each.yml - with_items: "{{ nexus_repos_docker_group }}" - when: nexus_config_docker + - include_tasks: create_repo_docker_group_each.yml + with_items: "{{ nexus_repos_docker_group }}" + when: nexus_config_docker -- block: - - include_tasks: create_repo_pypi_proxy_each.yml - with_items: "{{ nexus_repos_pypi_proxy }}" + - block: + - include_tasks: create_repo_pypi_proxy_each.yml + with_items: "{{ nexus_repos_pypi_proxy }}" - - include_tasks: create_repo_pypi_hosted_each.yml - with_items: "{{ nexus_repos_pypi_hosted }}" + - include_tasks: create_repo_pypi_hosted_each.yml + with_items: "{{ nexus_repos_pypi_hosted }}" - - include_tasks: create_repo_pypi_group_each.yml - with_items: "{{ nexus_repos_pypi_group }}" - when: nexus_config_pypi + - include_tasks: create_repo_pypi_group_each.yml + with_items: "{{ nexus_repos_pypi_group }}" + when: nexus_config_pypi -- block: - - include_tasks: create_repo_raw_proxy_each.yml - with_items: "{{ nexus_repos_raw_proxy }}" + - block: + - include_tasks: create_repo_raw_proxy_each.yml + with_items: "{{ nexus_repos_raw_proxy }}" - - include_tasks: create_repo_raw_hosted_each.yml - with_items: "{{ nexus_repos_raw_hosted }}" + - include_tasks: create_repo_raw_hosted_each.yml + with_items: "{{ nexus_repos_raw_hosted }}" - - include_tasks: create_repo_raw_group_each.yml - with_items: "{{ nexus_repos_raw_group }}" - when: nexus_config_raw + - include_tasks: create_repo_raw_group_each.yml + with_items: "{{ nexus_repos_raw_group }}" + when: nexus_config_raw -- block: - - include_tasks: create_repo_rubygems_proxy_each.yml - with_items: "{{ nexus_repos_rubygems_proxy }}" + - block: + - include_tasks: create_repo_rubygems_proxy_each.yml + with_items: "{{ nexus_repos_rubygems_proxy }}" - - include_tasks: create_repo_rubygems_hosted_each.yml - with_items: "{{ nexus_repos_rubygems_hosted }}" + - include_tasks: create_repo_rubygems_hosted_each.yml + with_items: "{{ nexus_repos_rubygems_hosted }}" - - include_tasks: create_repo_rubygems_group_each.yml - with_items: "{{ nexus_repos_rubygems_group }}" - when: nexus_config_rubygems + - include_tasks: create_repo_rubygems_group_each.yml + with_items: "{{ nexus_repos_rubygems_group }}" + when: nexus_config_rubygems -- block: - - include_tasks: create_repo_bower_proxy_each.yml - with_items: "{{ nexus_repos_bower_proxy }}" + - block: + - include_tasks: create_repo_bower_proxy_each.yml + with_items: "{{ nexus_repos_bower_proxy }}" - - include_tasks: create_repo_bower_hosted_each.yml - with_items: "{{ nexus_repos_bower_hosted }}" + - include_tasks: create_repo_bower_hosted_each.yml + with_items: "{{ nexus_repos_bower_hosted }}" - - include_tasks: create_repo_bower_group_each.yml - with_items: "{{ nexus_repos_bower_group }}" - when: nexus_config_bower + - include_tasks: create_repo_bower_group_each.yml + with_items: "{{ nexus_repos_bower_group }}" + when: nexus_config_bower -- block: - - include_tasks: create_repo_npm_proxy_each.yml - with_items: "{{ nexus_repos_npm_proxy }}" + - block: + - include_tasks: create_repo_npm_proxy_each.yml + with_items: "{{ nexus_repos_npm_proxy }}" - - include_tasks: create_repo_npm_hosted_each.yml - with_items: "{{ nexus_repos_npm_hosted }}" + - include_tasks: create_repo_npm_hosted_each.yml + with_items: "{{ nexus_repos_npm_hosted }}" - - include_tasks: create_repo_npm_group_each.yml - with_items: "{{ nexus_repos_npm_group }}" - when: nexus_config_npm + - include_tasks: create_repo_npm_group_each.yml + with_items: "{{ nexus_repos_npm_group }}" + when: nexus_config_npm -- block: - - include_tasks: create_repo_nuget_proxy_each.yml - with_items: "{{ nexus_repos_nuget_proxy }}" - - include_tasks: create_repo_nuget_hosted_each.yml - with_items: "{{ nexus_repos_nuget_hosted }}" - - include_tasks: create_repo_nuget_group_each.yml - with_items: "{{ nexus_repos_nuget_group }}" - when: nexus_config_nuget + - block: + - include_tasks: create_repo_nuget_proxy_each.yml + with_items: "{{ nexus_repos_nuget_proxy }}" + - include_tasks: create_repo_nuget_hosted_each.yml + with_items: "{{ nexus_repos_nuget_hosted }}" + - include_tasks: create_repo_nuget_group_each.yml + with_items: "{{ nexus_repos_nuget_group }}" + when: nexus_config_nuget -- include_tasks: create_repo_gitlfs_hosted_each.yml - with_items: "{{ nexus_repos_gitlfs_hosted }}" - when: nexus_config_gitlfs + - include_tasks: create_repo_gitlfs_hosted_each.yml + with_items: "{{ nexus_repos_gitlfs_hosted }}" + when: nexus_config_gitlfs -- block: - - include_tasks: create_repo_yum_hosted_each.yml - with_items: "{{ nexus_repos_yum_hosted }}" - - include_tasks: create_repo_yum_proxy_each.yml - with_items: "{{ nexus_repos_yum_proxy }}" - - include_tasks: create_repo_yum_group_each.yml - with_items: "{{ nexus_repos_yum_group }}" - when: nexus_config_yum + - block: + - include_tasks: create_repo_yum_hosted_each.yml + with_items: "{{ nexus_repos_yum_hosted }}" + - include_tasks: create_repo_yum_proxy_each.yml + with_items: "{{ nexus_repos_yum_proxy }}" + - include_tasks: create_repo_yum_group_each.yml + with_items: "{{ nexus_repos_yum_group }}" + when: nexus_config_yum + + when: nexus_run_provisionning | default(true) | bool - include_tasks: call_script.yml vars: @@ -268,6 +274,7 @@ - include_tasks: create_task_each.yml with_items: "{{ nexus_scheduled_tasks }}" + when: nexus_run_provisionning | default(true) | bool - name: Configure nexus backup task include_tasks: call_script.yml