From b28738b31ec3625aa472bb9b12a6de1de7336e5e Mon Sep 17 00:00:00 2001 From: Cedric Levasseur Date: Thu, 19 Oct 2017 17:38:38 +0200 Subject: [PATCH 01/12] Setting up mail via rest api --- tasks/main.yml | 12 ++++++++++++ tasks/setup_mail.yml | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tasks/setup_mail.yml diff --git a/tasks/main.yml b/tasks/main.yml index 2943b6e..37e8929 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -180,3 +180,15 @@ - include: create_task_each.yml with_items: "{{ nexus_scheduled_tasks }}" + +- name: Configure mail server + include: setup_mail.yml + #when nexus_mail_host is defined + +- include: call_script.yml + vars: + script_name: add_ldapuser_role + args: + ldap_id: "{{ nexus_ldap_id }}" + role: "{{ nexus_role }}" + usernames: "{{ nexus_ldapadmin_username }}" diff --git a/tasks/setup_mail.yml b/tasks/setup_mail.yml new file mode 100644 index 0000000..06da2d4 --- /dev/null +++ b/tasks/setup_mail.yml @@ -0,0 +1,12 @@ +--- +- name: Calling Groovy script {{ script_name }} + uri: + url: "http://localhost:{{ nexus_default_port }}{{ nexus_default_context_path }}service/extdirect" + user: 'admin' + password: "{{ current_nexus_admin_password }}" + headers: + Content-Type: "application/json" + method: POST + status_code: 200,204 + force_basic_auth: yes + body: '{"action":"coreui_Email","method":"update","data":[{"enabled":true,"host":"localhost","port":25,"username":"","password":"","fromAddress":"nexus-no-reply@fr.imshealth.com","subjectPrefix":"[NEXUS] ","startTlsEnabled":false,"startTlsRequired":false,"sslOnConnectEnabled":false,"sslCheckServerIdentityEnabled":false,"nexusTrustStoreEnabled":false}],"type":"rpc","tid":13}' From 1210976dc98e6cdfdf874a01fbb2be19c2a0532c Mon Sep 17 00:00:00 2001 From: Cedric Levasseur Date: Thu, 19 Oct 2017 18:00:51 +0200 Subject: [PATCH 02/12] setting up mail : variables ! --- defaults/main.yml | 6 ++++++ tasks/main.yml | 2 +- tasks/setup_mail.yml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 861a60e..e50e3f9 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -350,3 +350,9 @@ _nexus_repos_gitlfs_defaults: nexus_repos_gitlfs_hosted: - name: gitlfs-internal blob_store: "{{ nexus_blob_names.gitlfs.blob }}" + +nexus_mail_host: "localhost" +nexus_mail_port: 25 +nexus_mail_from: "nexus-no-reply@localhost" +nexus_mail_subject_prefix: "[NEXUS]" + diff --git a/tasks/main.yml b/tasks/main.yml index 37e8929..2efea18 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -183,7 +183,7 @@ - name: Configure mail server include: setup_mail.yml - #when nexus_mail_host is defined + when nexus_mail_host is defined - include: call_script.yml vars: diff --git a/tasks/setup_mail.yml b/tasks/setup_mail.yml index 06da2d4..ff90b2d 100644 --- a/tasks/setup_mail.yml +++ b/tasks/setup_mail.yml @@ -9,4 +9,4 @@ method: POST status_code: 200,204 force_basic_auth: yes - body: '{"action":"coreui_Email","method":"update","data":[{"enabled":true,"host":"localhost","port":25,"username":"","password":"","fromAddress":"nexus-no-reply@fr.imshealth.com","subjectPrefix":"[NEXUS] ","startTlsEnabled":false,"startTlsRequired":false,"sslOnConnectEnabled":false,"sslCheckServerIdentityEnabled":false,"nexusTrustStoreEnabled":false}],"type":"rpc","tid":13}' + body: '{"action":"coreui_Email","method":"update","data":[{"enabled":true,"host":"{{ nexus_mail_host}}","port":{{ nexus_mail_port }},"username":"","password":"","fromAddress":"{{ nexus_mail_from }}","subjectPrefix":"{{ nexus_mail_subject_prefix }}","startTlsEnabled":false,"startTlsRequired":false,"sslOnConnectEnabled":false,"sslCheckServerIdentityEnabled":false,"nexusTrustStoreEnabled":false}],"type":"rpc","tid":13}' From 1740bf9764d7d794271ea0d8f52770c2515a87e6 Mon Sep 17 00:00:00 2001 From: Cedric Levasseur Date: Thu, 19 Oct 2017 18:20:36 +0200 Subject: [PATCH 03/12] adding " around variable --- tasks/setup_mail.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/setup_mail.yml b/tasks/setup_mail.yml index ff90b2d..b19f1b2 100644 --- a/tasks/setup_mail.yml +++ b/tasks/setup_mail.yml @@ -9,4 +9,4 @@ method: POST status_code: 200,204 force_basic_auth: yes - body: '{"action":"coreui_Email","method":"update","data":[{"enabled":true,"host":"{{ nexus_mail_host}}","port":{{ nexus_mail_port }},"username":"","password":"","fromAddress":"{{ nexus_mail_from }}","subjectPrefix":"{{ nexus_mail_subject_prefix }}","startTlsEnabled":false,"startTlsRequired":false,"sslOnConnectEnabled":false,"sslCheckServerIdentityEnabled":false,"nexusTrustStoreEnabled":false}],"type":"rpc","tid":13}' + body: '{"action":"coreui_Email","method":"update","data":[{"enabled":true,"host":"{{ nexus_mail_host}}","port":"{{ nexus_mail_port }}","username":"","password":"","fromAddress":"{{ nexus_mail_from }}","subjectPrefix":"{{ nexus_mail_subject_prefix }}","startTlsEnabled":false,"startTlsRequired":false,"sslOnConnectEnabled":false,"sslCheckServerIdentityEnabled":false,"nexusTrustStoreEnabled":false}],"type":"rpc","tid":13}' From 996dc39c245287aebcf9e4fde86fe64de11729da Mon Sep 17 00:00:00 2001 From: Cedric Levasseur Date: Thu, 19 Oct 2017 18:27:06 +0200 Subject: [PATCH 04/12] missing semicolon --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 2efea18..59f278d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -183,7 +183,7 @@ - name: Configure mail server include: setup_mail.yml - when nexus_mail_host is defined + when: nexus_mail_host is defined - include: call_script.yml vars: From 64125cd683fb9eee8e4700ccb58cb06243ae4806 Mon Sep 17 00:00:00 2001 From: Cedric Levasseur Date: Fri, 20 Oct 2017 08:59:09 +0200 Subject: [PATCH 05/12] changing tast name --- tasks/setup_mail.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/setup_mail.yml b/tasks/setup_mail.yml index b19f1b2..148c90e 100644 --- a/tasks/setup_mail.yml +++ b/tasks/setup_mail.yml @@ -1,5 +1,5 @@ --- -- name: Calling Groovy script {{ script_name }} +- name: Running setup_mail.yml uri: url: "http://localhost:{{ nexus_default_port }}{{ nexus_default_context_path }}service/extdirect" user: 'admin' From 07e62f1e9abace6c8bd805c2f8f1865770134132 Mon Sep 17 00:00:00 2001 From: Cedric Levasseur Date: Fri, 20 Oct 2017 17:29:34 +0200 Subject: [PATCH 06/12] modifying json encapsulation --- tasks/setup_mail.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tasks/setup_mail.yml b/tasks/setup_mail.yml index 148c90e..b6be149 100644 --- a/tasks/setup_mail.yml +++ b/tasks/setup_mail.yml @@ -4,9 +4,27 @@ url: "http://localhost:{{ nexus_default_port }}{{ nexus_default_context_path }}service/extdirect" user: 'admin' password: "{{ current_nexus_admin_password }}" + body_format: json headers: Content-Type: "application/json" method: POST status_code: 200,204 force_basic_auth: yes - body: '{"action":"coreui_Email","method":"update","data":[{"enabled":true,"host":"{{ nexus_mail_host}}","port":"{{ nexus_mail_port }}","username":"","password":"","fromAddress":"{{ nexus_mail_from }}","subjectPrefix":"{{ nexus_mail_subject_prefix }}","startTlsEnabled":false,"startTlsRequired":false,"sslOnConnectEnabled":false,"sslCheckServerIdentityEnabled":false,"nexusTrustStoreEnabled":false}],"type":"rpc","tid":13}' + body: + action: "coreui_Email" + method: "update" + data : + enabled: true + host: "{{ nexus_mail_host}}" + port: "{{ nexus_mail_port }}" + username: "" + password: "" + fromAddress: "{{ nexus_mail_from }}" + subjectPrefix: "{{ nexus_mail_subject_prefix }}" + startTlsEnabled: false + startTlsRequired: false + sslOnConnectEnabled: false + sslCheckServerIdentityEnabled :false + nexusTrustStoreEnabled :false + type :"rpc" + tid: 13' From fecd693108aae28cb8eda982d49d54198dcadab0 Mon Sep 17 00:00:00 2001 From: Cedric Levasseur Date: Fri, 20 Oct 2017 18:07:33 +0200 Subject: [PATCH 07/12] grr correction : spaces and semicolon were inverted --- tasks/setup_mail.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/setup_mail.yml b/tasks/setup_mail.yml index b6be149..a534115 100644 --- a/tasks/setup_mail.yml +++ b/tasks/setup_mail.yml @@ -24,7 +24,7 @@ startTlsEnabled: false startTlsRequired: false sslOnConnectEnabled: false - sslCheckServerIdentityEnabled :false - nexusTrustStoreEnabled :false - type :"rpc" + sslCheckServerIdentityEnabled: false + nexusTrustStoreEnabled: false + type: "rpc" tid: 13' From c3e56f3a7fea57a94f6d732b92e780a5c0d09f62 Mon Sep 17 00:00:00 2001 From: Cedric Levasseur Date: Fri, 20 Oct 2017 18:11:43 +0200 Subject: [PATCH 08/12] removing annoying apos --- tasks/setup_mail.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/setup_mail.yml b/tasks/setup_mail.yml index a534115..d85671c 100644 --- a/tasks/setup_mail.yml +++ b/tasks/setup_mail.yml @@ -27,4 +27,4 @@ sslCheckServerIdentityEnabled: false nexusTrustStoreEnabled: false type: "rpc" - tid: 13' + tid: 13 From 8b68429b03762eff9bd635fa6501e1846be13544 Mon Sep 17 00:00:00 2001 From: Cedric Levasseur Date: Mon, 23 Oct 2017 13:47:09 +0200 Subject: [PATCH 09/12] correctiopn yml, space before colon --- tasks/setup_mail.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/setup_mail.yml b/tasks/setup_mail.yml index d85671c..9eeb59e 100644 --- a/tasks/setup_mail.yml +++ b/tasks/setup_mail.yml @@ -13,7 +13,7 @@ body: action: "coreui_Email" method: "update" - data : + data: enabled: true host: "{{ nexus_mail_host}}" port: "{{ nexus_mail_port }}" From 2680deae85a3c2c4af071116a29c8f59ab41d75b Mon Sep 17 00:00:00 2001 From: Cedric Levasseur Date: Mon, 23 Oct 2017 14:36:48 +0200 Subject: [PATCH 10/12] adding a lot of defautl value for mail server --- defaults/main.yml | 7 +++++++ tasks/setup_mail.yml | 19 +------------------ 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index e50e3f9..036b884 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -355,4 +355,11 @@ nexus_mail_host: "localhost" nexus_mail_port: 25 nexus_mail_from: "nexus-no-reply@localhost" nexus_mail_subject_prefix: "[NEXUS]" +nexus_mail_username: "" +nexus_mail_password: "" +nexus_mail_start_tls_enabled: false +nexus_mail_start_tls_required: false +nexus_mail_ssl_on_connect_enabled: false +nexus_mail_ssl_check_server_identity_enabled: false +nexus_mail_trust_store_enabled: false diff --git a/tasks/setup_mail.yml b/tasks/setup_mail.yml index 9eeb59e..bc2e97d 100644 --- a/tasks/setup_mail.yml +++ b/tasks/setup_mail.yml @@ -10,21 +10,4 @@ method: POST status_code: 200,204 force_basic_auth: yes - body: - action: "coreui_Email" - method: "update" - data: - enabled: true - host: "{{ nexus_mail_host}}" - port: "{{ nexus_mail_port }}" - username: "" - password: "" - fromAddress: "{{ nexus_mail_from }}" - subjectPrefix: "{{ nexus_mail_subject_prefix }}" - startTlsEnabled: false - startTlsRequired: false - sslOnConnectEnabled: false - sslCheckServerIdentityEnabled: false - nexusTrustStoreEnabled: false - type: "rpc" - tid: 13 + body: {"action":"coreui_Email","method":"update","data":[{"enabled":true,"host":"{{ nexus_mail_host }}","port": "{{ nexus_mail_port }}","username":"{{ nexus_mail_username }}","password":"{{ nexus_mail_password }}","fromAddress":"{{ nexus_mail_from }}","subjectPrefix":"{{ nexus_mail_subject_prefix}}" ,"startTlsEnabled":"{{ nexus_mail_start_tls_enabled }},"startTlsRequired":"{{ nexus_mail_start_tls_required }}","sslOnConnectEnabled":"{{ nexus_mail_ssl_on_connect_enabled }}","sslCheckServerIdentityEnabled":"{{ nexus_mail_ssl_check_server_identity_enabled }}","nexusTrustStoreEnabled":"{{ nexus_mail_trust_store_enabled }}"],"type":"rpc","tid":12} From 7da5359eb99f66e2eb7050a6ba4c7c1f63d336c2 Mon Sep 17 00:00:00 2001 From: Cedric Levasseur Date: Mon, 23 Oct 2017 14:57:19 +0200 Subject: [PATCH 11/12] correction json --- tasks/setup_mail.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/setup_mail.yml b/tasks/setup_mail.yml index bc2e97d..e3112ec 100644 --- a/tasks/setup_mail.yml +++ b/tasks/setup_mail.yml @@ -10,4 +10,4 @@ method: POST status_code: 200,204 force_basic_auth: yes - body: {"action":"coreui_Email","method":"update","data":[{"enabled":true,"host":"{{ nexus_mail_host }}","port": "{{ nexus_mail_port }}","username":"{{ nexus_mail_username }}","password":"{{ nexus_mail_password }}","fromAddress":"{{ nexus_mail_from }}","subjectPrefix":"{{ nexus_mail_subject_prefix}}" ,"startTlsEnabled":"{{ nexus_mail_start_tls_enabled }},"startTlsRequired":"{{ nexus_mail_start_tls_required }}","sslOnConnectEnabled":"{{ nexus_mail_ssl_on_connect_enabled }}","sslCheckServerIdentityEnabled":"{{ nexus_mail_ssl_check_server_identity_enabled }}","nexusTrustStoreEnabled":"{{ nexus_mail_trust_store_enabled }}"],"type":"rpc","tid":12} + body: {"action":"coreui_Email","method":"update","data":[{"enabled":true,"host":"{{ nexus_mail_host }}","port": "{{ nexus_mail_port }}","username":"{{ nexus_mail_username }}","password":"{{ nexus_mail_password }}","fromAddress":"{{ nexus_mail_from }}","subjectPrefix":"{{ nexus_mail_subject_prefix}}" ,"startTlsEnabled":"{{ nexus_mail_start_tls_enabled }}","startTlsRequired":"{{ nexus_mail_start_tls_required }}","sslOnConnectEnabled":"{{ nexus_mail_ssl_on_connect_enabled }}","sslCheckServerIdentityEnabled":"{{ nexus_mail_ssl_check_server_identity_enabled }}","nexusTrustStoreEnabled":"{{ nexus_mail_trust_store_enabled }}"}],"type":"rpc","tid":12} From 2514c745f69eb5f384a12b7c138419148b2d0736 Mon Sep 17 00:00:00 2001 From: Cedric Levasseur Date: Mon, 23 Oct 2017 17:26:09 +0200 Subject: [PATCH 12/12] Adding some doc about variables nexus_mail_... --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 15b2cca..188276c 100644 --- a/README.md +++ b/README.md @@ -277,6 +277,12 @@ see `defaults/main.yml` for these options: These are all false unless you override them from playbook / group_var / cli, these all utilize the same mechanism as maven. +the variable ```nexus_mail_host``` is used to configure the mail server. If empty, the mail server is left disabled. +Others variables are : +``` nexus_mail_port, nexus_mail_from, nexus_mail_subject_prefix, nexus_mail_username, nexus_mail_password, nexus_mail_start_tls_enabled, nexus_mail_start_tls_required, nexus_mail_ssl_on_connect_enabled, nexus_mail_ssl_check_server_identity_enabled, nexus_mail_trust_store_enabled ``` + + + ## Dependencies This role requires Ansible 2.1 or higher.