Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't update admin email #50

Open
PaulusTM opened this issue Feb 1, 2018 · 3 comments
Open

Can't update admin email #50

PaulusTM opened this issue Feb 1, 2018 · 3 comments

Comments

@PaulusTM
Copy link

PaulusTM commented Feb 1, 2018

Hi,

I'm trying to update the email adres for the admin user with the nexus3_api resource.
However anything I try does not update the email address.

I'm using this JSON file:

{
  "name": "admin_email",
  "type": "groovy",
  "content": "def user = security.securitySystem.getUser('admin');user.setEmailAddress('[email protected]');'security.securitySystem.updateUser(user);'"
}

And the Chef code:

nexus3_api 'admin_update_email' do
  script_source 'admin_update_email.json'
  script_cookbook 'company_nexus'
  action :run
end

Test Kitchen output:

 * nexus3_api[admin_update_email] action run
           * ruby_block[wait up to 300 seconds for Nexus Rest API endpoint to respond] action run
             - execute the ruby block wait up to 300 seconds for Nexus Rest API endpoint to respond
           * execute[wait for http://localhost:8081/service/siesta/rest/v1/script to respond] action run
             [execute]   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0[ {
                  "name" : "anonymous",
                  "content" : "security.setAnonymousAccess(Boolean.valueOf(args))",
                  "type" : "groovy"
100   119  100   119    0     0   2705      0 --:--:-- --:--:-- --:--:--  2767
             - execute curl --fail -X GET -u admin:admin123 'http://localhost:8081/service/siesta/rest/v1/script'
           * execute[delete script admin_update_email] action run
             [execute]   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* About to connect() to localhost port 8081 (#0)
                *   Trying ::1...
                * Connection refused
                *   Trying 127.0.0.1...
                * Connected to localhost (127.0.0.1) port 8081 (#0)
                * Server auth using Basic with user 'admin'
                > DELETE /service/siesta/rest/v1/script/admin_update_email HTTP/1.1
                > Authorization: Basic YWRtaW46YWRtaW4xMjM=
                > User-Agent: curl/7.29.0
                > Host: localhost:8081
                > Accept: */*
                >
                < HTTP/1.1 404 Not Found
                < Date: Thu, 01 Feb 2018 18:42:44 GMT
                < Server: Nexus/3.7.1-02 (OSS)
                < X-Frame-Options: SAMEORIGIN
                < X-Content-Type-Options: nosniff
                < X-Siesta-FaultId: 6974ab26-9575-423e-8a81-92ba02b874dd
                < Content-Length: 0
                <
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
                * Connection #0 to host localhost left intact
             - execute curl -v -X DELETE -u admin:admin123 'http://localhost:8081/service/siesta/rest/v1/script/admin_update_email'
           * directory[/tmp/kitchen/cache/nexus/scripts] action create (up to date)
           * cookbook_file[/tmp/kitchen/cache/nexus/scripts/admin_update_email.json] action create
             - update content in file /tmp/kitchen/cache/nexus/scripts/admin_update_email.json from 1b790c to f86c34
             --- /tmp/kitchen/cache/nexus/scripts/admin_update_email.json       2018-02-01 18:37:55.371225623 +0000
             +++ /tmp/kitchen/cache/nexus/scripts/.chef-admin_update_email20180201-9247-18evfxp.json    2018-02-01 18:42:44.338347727 +0000
             @@ -1,5 +1,5 @@
       {
             -  "name": "anonymous",
             +  "name": "admin_email",
         "type": "groovy",
         "content": "def user = security.securitySystem.getUser('admin');user.setEmailAddress('[email protected]');'security.securitySystem.updateUser(user);'"
       }
             - restore selinux security context
           * file[/tmp/kitchen/cache/nexus/scripts/admin_update_email.json] action create (skipped due to only_if)
           * execute[upload script admin_update_email] action run
             [execute]   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* About to connect() to localhost port 8081 (#0)
                *   Trying ::1...
                * Connection refused
                *   Trying 127.0.0.1...
                * Connected to localhost (127.0.0.1) port 8081 (#0)
                * Server auth using Basic with user 'admin'
                > POST /service/siesta/rest/v1/script HTTP/1.1
                > Authorization: Basic YWRtaW46YWRtaW4xMjM=
                > User-Agent: curl/7.29.0
                > Host: localhost:8081
                > Accept: */*
                > Content-Type: application/json
                > Content-Length: 197
                >
                } [data not shown]
                * upload completely sent off: 197 out of 197 bytes
                < HTTP/1.1 204 No Content
                < Date: Thu, 01 Feb 2018 18:42:44 GMT
                < Server: Nexus/3.7.1-02 (OSS)
                < X-Frame-Options: SAMEORIGIN
                < X-Content-Type-Options: nosniff
                <
100   197    0     0  100   197      0  11789 --:--:-- --:--:-- --:--:-- 12312
                * Connection #0 to host localhost left intact
             - execute curl -v  -X POST -u admin:admin123 --header "Content-Type: application/json" 'http://localhost:8081/service/siesta/rest/v1/script' -d @admin_update_email.json
           * execute[run script admin_update_email] action run
             [execute]   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* About to connect() to localhost port 8081 (#0)
                *   Trying ::1...
                * Connection refused
                *   Trying 127.0.0.1...
                * Connected to localhost (127.0.0.1) port 8081 (#0)
                * Server auth using Basic with user 'admin'
                > POST /service/siesta/rest/v1/script/admin_update_email/run HTTP/1.1
                > Authorization: Basic YWRtaW46YWRtaW4xMjM=
                > User-Agent: curl/7.29.0
                > Host: localhost:8081
                > Accept: */*
                > Content-Type: text/plain
                >
                < HTTP/1.1 404 Not Found
                < Date: Thu, 01 Feb 2018 18:42:44 GMT
                < Server: Nexus/3.7.1-02 (OSS)
                < X-Frame-Options: SAMEORIGIN
                < X-Content-Type-Options: nosniff
                < X-Siesta-FaultId: d937922e-1085-4e99-b207-eb5198613498
                < Content-Length: 0
                <
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
                * Connection #0 to host localhost left intact
             - execute curl -v  -X POST -u admin:admin123 --header "Content-Type: text/plain" 'http://localhost:8081/service/siesta/rest/v1/script/admin_update_email/run'
@PaulusTM PaulusTM changed the title Can update admin email Can't update admin email Feb 1, 2018
@olive42
Copy link
Contributor

olive42 commented Feb 1, 2018

Can you check the Nexus logs to see if there are any errors related to uploading your script? (kitchen login, check in /opt/sonatype-work/nexus3/logs/nexus.log)

If you use the latest cookbook version, the nexus3_api resource does not take JSON content as input. I would also recommend using the nexus3_user resource,

@PaulusTM
Copy link
Author

PaulusTM commented Feb 5, 2018

I currently use the following without any luck yet.

nexus3_user 'admin' do
  username 'admin'
  email '[email protected]'
  password 'admin123'
  roles ['nx-admin']
  action :create
end

During the run I get a 404 exception from the API. Do you have any pointers?

             Error executing action `run` on resource 'nexus3_api[upsert_user admin]'
             ================================================================================

             Nexus3::ApiError
             ----------------
             HTTP_STATUS=404

             Cookbook Trace:
             ---------------
             /tmp/kitchen/cache/cookbooks/nexus3/libraries/api.rb:36:in `request'
             /tmp/kitchen/cache/cookbooks/nexus3/libraries/api.rb:41:in `run_script'
             /tmp/kitchen/cache/cookbooks/nexus3/resources/api.rb:40:in `block (2 levels) in class_from_file'
             /tmp/kitchen/cache/cookbooks/nexus3/resources/api.rb:39:in `block in class_from_file'

             Resource Declaration:
             ---------------------
             # In /tmp/kitchen/cache/cookbooks/nexus3/resources/user.rb

       42:     nexus3_api "upsert_user #{new_resource.username}" do
       43:       script_name 'upsert_user'
       44:       args username: new_resource.username,
       45:            password: new_resource.password,
       46:            first_name: new_resource.first_name,
       47:            last_name: new_resource.last_name,
       48:            email: new_resource.email,
       49:            roles: new_resource.roles
       50:
       51:       action %i(create run)
       52:       endpoint new_resource.api_endpoint
       53:       username new_resource.api_username
       54:       password new_resource.api_password
       55:
       56:       content ::Nexus3::Scripts.groovy_content('upsert_user', node)
       57:     end
       58:   end

             Compiled Resource:
             ------------------
             # Declared in /tmp/kitchen/cache/cookbooks/nexus3/resources/user.rb:42:in `block (2 levels) in class_from_file'

             nexus3_api("upsert_user admin") do
        action [:create, :run]
        updated true
        default_guard_interpreter :default
        declared_type :nexus3_api
        cookbook_name "company_nexus"
        script_name "upsert_user"
        endpoint "http://localhost:8081/service/siesta/rest/v1/script"
        username "admin"
        password "admin123"
        content "import org.sonatype.nexus.security.role.NoSuchRoleException;\nimport org.sonatype.nexus.security.role.RoleIdentifier;\nimport org.sonatype.nexus.security.user.User;\nimport org.sonatype.nexus.security.user.UserManager;\nimport org.sonatype.nexus.security.user.UserNotFoundException;\nimport org.sonatype.nexus.security.SecuritySystem;\n\nimport groovy.json.JsonSlurper;\n\ndef params = new JsonSlurper().parseText(args)\n\nauthManager = security.getSecuritySystem().getAuthorizationManager(UserManager.DEFAULT_SOURCE);\n// Create a list of available from the list of passed roles. May end up empty if no role exists.\nSet<RoleIdentifier> roleList = new HashSet<RoleIdentifier>();\nparams.roles.each { role ->\n    try {\n        def newRole = authManager.getRole(role);\n        roleList.add(newRole);\n    } catch (NoSuchRoleException e) {\n        log.warn(\"No such role: ${role}, trying to set for ${params.username} from Chef\");\n    }\n}\n\ntry {\n    // Update\n    User user = security.securitySystem.getUser(params.username, UserManager.DEFAULT_SOURCE);\n\n    user.setFirstName(params.first_name);\n    user.setLastName(params.last_name);\n    user.setEmailAddress(params.email);\n    user.setRoles(roleList);\n\n    security.securitySystem.updateUser(user);\n    security.securitySystem.changePassword(params.username, params.password);\n    log.info(\"Updated information for ${params.username} from Chef\");\n} catch (UserNotFoundException e) {\n    // Create\n    security.addUser(params.username, params.first_name, params.last_name, params.email, true, params.password, params.roles);\n    log.info(\"Created user ${params.username} from Chef\");\n}\n"
        args {:username=>"admin", :password=>"admin123", :first_name=>"", :last_name=>"", :email=>"[email protected]", :roles=>["nx-admin"]}
        apiclient #<Nexus3::Api:0x000000000316e678 @http_client=#<HTTPClient:0x000000000316c3a0 @proxy=nil, @no_proxy=nil, @no_proxy_regexps=[], @base_url="http://localhost:8081/service/siesta/rest/v1/script", @default_header={}, @www_auth=#<HTTPClient::WWWAuth:0x0000000003159138 @basic_auth=#<HTTPClient::BasicAuth:0x0000000003159110 @_mutex=#<Thread::Mutex:0x000000000313ff08>, @scheme="Basic", @challenge={}, @cred=nil, @auth={#<Addressable::URI:0x1d73e0c URI:http://localhost:8081/service/siesta/rest/v1/>=>"YWRtaW46YWRtaW4xMjM="}, @force_auth=true>, @digest_auth=#<HTTPClient::DigestAuth:0x000000000313fa08 @_mutex=#<Thread::Mutex:0x000000000313ec98>, @scheme="Digest", @challenge={}, @auth={#<Addressable::URI:0x1d7a478 URI:http://localhost:8081/service/siesta/rest/v1/>=>["admin", "admin123"]}, @nonce_count=0>, @negotiate_auth=#<HTTPClient::NegotiateAuth:0x000000000313e720 @_mutex=#<Thread::Mutex:0x000000000313c330>, @scheme="Negotiate", @challenge={}, @auth={#<Addressable::URI:0x1d7b620 URI:http://localhost:8081/service/siesta/rest/v1/>=>["admin", "admin123"]}, @auth_default=nil, @ntlm_opt={:ntlmv2=>true}>, @ntlm_auth=#<HTTPClient::NegotiateAuth:0x00000000031277a0 @_mutex=#<Thread::Mutex:0x00000000031257e8>, @scheme="NTLM", @challenge={}, @auth={#<Addressable::URI:0x1d7abe4 URI:http://localhost:8081/service/siesta/rest/v1/>=>["admin", "admin123"]}, @auth_default=nil, @ntlm_opt={:ntlmv2=>true}>, @sspi_negotiate_auth=#<HTTPClient::SSPINegotiateAuth:0x0000000003124be0 @_mutex=#<Thread::Mutex:0x0000000003117300>, @scheme="Negotiate", @challenge={}>, @oauth=#<HTTPClient::OAuth:0x00000000031164c8 @_mutex=#<Thread::Mutex:0x0000000003114970>, @scheme="OAuth", @challenge={}, @config=nil, @auth={}, @nonce_count=0, @signature_handler={"HMAC-SHA1"=>#<Method: HTTPClient::OAuth#sign_hmac_sha1>}>, @authenticator=[#<HTTPClient::OAuth:0x00000000031164c8 @_mutex=#<Thread::Mutex:0x0000000003114970>, @scheme="OAuth", @challenge={}, @config=nil, @auth={}, @nonce_count=0, @signature_handler={"HMAC-SHA1"=>#<Method: HTTPClient::OAuth#sign_hmac_sha1>}>, #<HTTPClient::NegotiateAuth:0x000000000313e720 @_mutex=#<Thread::Mutex:0x000000000313c330>, @scheme="Negotiate", @challenge={}, @auth={#<Addressable::URI:0x1d7b620 URI:http://localhost:8081/service/siesta/rest/v1/>=>["admin", "admin123"]}, @auth_default=nil, @ntlm_opt={:ntlmv2=>true}>, #<HTTPClient::NegotiateAuth:0x00000000031277a0 @_mutex=#<Thread::Mutex:0x00000000031257e8>, @scheme="NTLM", @challenge={}, @auth={#<Addressable::URI:0x1d7abe4 URI:http://localhost:8081/service/siesta/rest/v1/>=>["admin", "admin123"]}, @auth_default=nil, @ntlm_opt={:ntlmv2=>true}>, #<HTTPClient::SSPINegotiateAuth:0x0000000003124be0 @_mutex=#<Thread::Mutex:0x0000000003117300>, @scheme="Negotiate", @challenge={}>, #<HTTPClient::DigestAuth:0x000000000313fa08 @_mutex=#<Thread::Mutex:0x000000000313ec98>, @scheme="Digest", @challenge={}, @auth={#<Addressable::URI:0x1d7a478 URI:http://localhost:8081/service/siesta/rest/v1/>=>["admin", "admin123"]}, @nonce_count=0>, #<HTTPClient::BasicAuth:0x0000000003159110 @_mutex=#<Thread::Mutex:0x000000000313ff08>, @scheme="Basic", @challenge={}, @cred=nil, @auth={#<Addressable::URI:0x1d73e0c URI:http://localhost:8081/service/siesta/rest/v1/>=>"YWRtaW46YWRtaW4xMjM="}, @force_auth=true>]>, @proxy_auth=#<HTTPClient::ProxyAuth:0x00000000030fdfe0 @basic_auth=#<HTTPClient::ProxyBasicAuth:0x00000000030fde00 @_mutex=#<Thread::Mutex:0x00000000030fc730>, @scheme="Basic", @challenge={}, @cred=nil, @auth={}, @force_auth=true>, @negotiate_auth=#<HTTPClient::NegotiateAuth:0x00000000030e7308 @_mutex=#<Thread::Mutex:0x00000000030e5800>, @scheme="Negotiate", @challenge={}, @auth={}, @auth_default=nil, @ntlm_opt={:ntlmv2=>true}>, @ntlm_auth=#<HTTPClient::NegotiateAuth:0x00000000030e4748 @_mutex=#<Thread::Mutex:0x00000000030d7e08>, @scheme="NTLM", @challenge={}, @auth={}, @auth_default=nil, @ntlm_opt={:ntlmv2=>true}>, @sspi_negotiate_auth=#<HTTPClient::SSPINegotiateAuth:0x00000000030d6d28 @_mutex=#<Thread::Mutex:0x00000000030d61c0>, @scheme="Negotiate", @challenge={}>, @digest_auth=#<HTTPClient::ProxyDigestAuth:0x00000000030d5360 @_mutex=#<Thread::Mutex:0x00000000030bbe10>, @scheme="Digest", @challenge=nil, @auth={}, @nonce_count=0>, @authenticator=[#<HTTPClient::NegotiateAuth:0x00000000030e7308 @_mutex=#<Thread::Mutex:0x00000000030e5800>, @scheme="Negotiate", @challenge={}, @auth={}, @auth_default=nil, @ntlm_opt={:ntlmv2=>true}>, #<HTTPClient::NegotiateAuth:0x00000000030e4748 @_mutex=#<Thread::Mutex:0x00000000030d7e08>, @scheme="NTLM", @challenge={}, @auth={}, @auth_default=nil, @ntlm_opt={:ntlmv2=>true}>, #<HTTPClient::SSPINegotiateAuth:0x00000000030d6d28 @_mutex=#<Thread::Mutex:0x00000000030d61c0>, @scheme="Negotiate", @challenge={}>, #<HTTPClient::ProxyDigestAuth:0x00000000030d5360 @_mutex=#<Thread::Mutex:0x00000000030bbe10>, @scheme="Digest", @challenge=nil, @auth={}, @nonce_count=0>, #<HTTPClient::ProxyBasicAuth:0x00000000030fde00 @_mutex=#<Thread::Mutex:0x00000000030fc730>, @scheme="Basic", @challenge={}, @cred=nil, @auth={}, @force_auth=true>]>, @request_filter=[#<HTTPClient::ProxyAuth:0x00000000030fdfe0 @basic_auth=#<HTTPClient::ProxyBasicAuth:0x00000000030fde00 @_mutex=#<Thread::Mutex:0x00000000030fc730>, @scheme="Basic", @challenge={}, @cred=nil, @auth={}, @force_auth=true>, @negotiate_auth=#<HTTPClient::NegotiateAuth:0x00000000030e7308 @_mutex=#<Thread::Mutex:0x00000000030e5800>, @scheme="Negotiate", @challenge={}, @auth={}, @auth_default=nil, @ntlm_opt={:ntlmv2=>true}>, @ntlm_auth=#<HTTPClient::NegotiateAuth:0x00000000030e4748 @_mutex=#<Thread::Mutex:0x00000000030d7e08>, @scheme="NTLM", @challenge={}, @auth={}, @auth_default=nil, @ntlm_opt={:ntlmv2=>true}>, @sspi_negotiate_auth=#<HTTPClient::SSPINegotiateAuth:0x00000000030d6d28 @_mutex=#<Thread::Mutex:0x00000000030d61c0>, @scheme="Negotiate", @challenge={}>, @digest_auth=#<HTTPClient::ProxyDigestAuth:0x00000000030d5360 @_mutex=#<Thread::Mutex:0x00000000030bbe10>, @scheme="Digest", @challenge=nil, @auth={}, @nonce_count=0>, @authenticator=[#<HTTPClient::NegotiateAuth:0x00000000030e7308 @_mutex=#<Thread::Mutex:0x00000000030e5800>, @scheme="Negotiate", @challenge={}, @auth={}, @auth_default=nil, @ntlm_opt={:ntlmv2=>true}>, #<HTTPClient::NegotiateAuth:0x00000000030e4748 @_mutex=#<Thread::Mutex:0x00000000030d7e08>, @scheme="NTLM", @challenge={}, @auth={}, @auth_default=nil, @ntlm_opt={:ntlmv2=>true}>, #<HTTPClient::SSPINegotiateAuth:0x00000000030d6d28 @_mutex=#<Thread::Mutex:0x00000000030d61c0>, @scheme="Negotiate", @challenge={}>, #<HTTPClient::ProxyDigestAuth:0x00000000030d5360 @_mutex=#<Thread::Mutex:0x00000000030bbe10>, @scheme="Digest", @challenge=nil, @auth={}, @nonce_count=0>, #<HTTPClient::ProxyBasicAuth:0x00000000030fde00 @_mutex=#<Thread::Mutex:0x00000000030fc730>, @scheme="Basic", @challenge={}, @cred=nil, @auth={}, @force_auth=true>]>, #<HTTPClient::WWWAuth:0x0000000003159138 @basic_auth=#<HTTPClient::BasicAuth:0x0000000003159110 @_mutex=#<Thread::Mutex:0x000000000313ff08>, @scheme="Basic", @challenge={}, @cred=nil, @auth={#<Addressable::URI:0x1d73e0c URI:http://localhost:8081/service/siesta/rest/v1/>=>"YWRtaW46YWRtaW4xMjM="}, @force_auth=true>, @digest_auth=#<HTTPClient::DigestAuth:0x000000000313fa08 @_mutex=#<Thread::Mutex:0x000000000313ec98>, @scheme="Digest", @challenge={}, @auth={#<Addressable::URI:0x1d7a478 URI:http://localhost:8081/service/siesta/rest/v1/>=>["admin", "admin123"]}, @nonce_count=0>, @negotiate_auth=#<HTTPClient::NegotiateAuth:0x000000000313e720 @_mutex=#<Thread::Mutex:0x000000000313c330>, @scheme="Negotiate", @challenge={}, @auth={#<Addressable::URI:0x1d7b620 URI:http://localhost:8081/service/siesta/rest/v1/>=>["admin", "admin123"]}, @auth_default=nil, @ntlm_opt={:ntlmv2=>true}>, @ntlm_auth=#<HTTPClient::NegotiateAuth:0x00000000031277a0 @_mutex=#<Thread::Mutex:0x00000000031257e8>, @scheme="NTLM", @challenge={}, @auth={#<Addressable::URI:0x1d7abe4 URI:http://localhost:8081/service/siesta/rest/v1/>=>["admin", "admin123"]}, @auth_default=nil, @ntlm_opt={:ntlmv2=>true}>, @sspi_negotiate_auth=#<HTTPClient::SSPINegotiateAuth:0x0000000003124be0 @_mutex=#<Thread::Mutex:0x0000000003117300>, @scheme="Negotiate", @challenge={}>, @oauth=#<HTTPClient::OAuth:0x00000000031164c8 @_mutex=#<Thread::Mutex:0x0000000003114970>, @scheme="OAuth", @challenge={}, @config=nil, @auth={}, @nonce_count=0, @signature_handler={"HMAC-SHA1"=>#<Method: HTTPClient::OAuth#sign_hmac_sha1>}>, @authenticator=[#<HTTPClient::OAuth:0x00000000031164c8 @_mutex=#<Thread::Mutex:0x0000000003114970>, @scheme="OAuth", @challenge={}, @config=nil, @auth={}, @nonce_count=0, @signature_handler={"HMAC-SHA1"=>#<Method: HTTPClient::OAuth#sign_hmac_sha1>}>, #<HTTPClient::NegotiateAuth:0x000000000313e720 @_mutex=#<Thread::Mutex:0x000000000313c330>, @scheme="Negotiate", @challenge={}, @auth={#<Addressable::URI:0x1d7b620 URI:http://localhost:8081/service/siesta/rest/v1/>=>["admin", "admin123"]}, @auth_default=nil, @ntlm_opt={:ntlmv2=>true}>, #<HTTPClient::NegotiateAuth:0x00000000031277a0 @_mutex=#<Thread::Mutex:0x00000000031257e8>, @scheme="NTLM", @challenge={}, @auth={#<Addressable::URI:0x1d7abe4 URI:http://localhost:8081/service/siesta/rest/v1/>=>["admin", "admin123"]}, @auth_default=nil, @ntlm_opt={:ntlmv2=>true}>, #<HTTPClient::SSPINegotiateAuth:0x0000000003124be0 @_mutex=#<Thread::Mutex:0x0000000003117300>, @scheme="Negotiate", @challenge={}>, #<HTTPClient::DigestAuth:0x000000000313fa08 @_mutex=#<Thread::Mutex:0x000000000313ec98>, @scheme="Digest", @challenge={}, @auth={#<Addressable::URI:0x1d7a478 URI:http://localhost:8081/service/siesta/rest/v1/>=>["admin", "admin123"]}, @nonce_count=0>, #<HTTPClient::BasicAuth:0x0000000003159110 @_mutex=#<Thread::Mutex:0x000000000313ff08>, @scheme="Basic", @challenge={}, @cred=nil, @auth={#<Addressable::URI:0x1d73e0c URI:http://localhost:8081/service/siesta/rest/v1/>=>"YWRtaW46YWRtaW4xMjM="}, @force_auth=true>]>], @debug_dev=nil, @redirect_uri_callback=#<Method: HTTPClient#default_redirect_uri_callback>, @test_loopback_response=[], @session_manager=#<HTTPClient::SessionManager:0x00000000030b9250 @client=#<HTTPClient:0x000000000316c3a0 ...>, @proxy=nil, @agent_name="HTTPClient/1.0", @from=nil, @protocol_version=nil, @debug_dev=nil, @socket_sync=true, @tcp_keepalive=false, @chunk_size=16384, @connect_timeout=60, @connect_retry=1, @send_timeout=120, @receive_timeout=60, @keep_alive_timeout=15, @read_block_size=16384, @protocol_retry_count=5, @ssl_config=#<HTTPClient::SSLConfig:0x0000000003091a48 @client=#<HTTPClient:0x000000000316c3a0 ...>, @cert_store=#<OpenSSL::X509::Store:0x0000000003091a20 @verify_callback=nil, @error=nil, @error_string=nil, @chain=nil, @time=nil, @_httpclient_cert_store_items=[:default]>, @cert_store_crl_items=[], @client_ca=nil, @client_key_pass=nil, @client_key=nil, @client_cert=nil, @verify_mode=3, @verify_depth=nil, @verify_callback=nil, @dest=nil, @timeout=nil, @ssl_version=:auto, @options=2197947391, @ciphers="ALL:!aNULL:!eNULL:!SSLv2", @cacerts_loaded=false>, @test_loopback_http_response=[], @transparent_gzip_decompression=false, @strict_response_size_check=false, @socket_local=#<HTTPClient::Site:0x185c48c tcp://0.0.0.0:0>, @sess_pool={#<HTTPClient::Site:0x1d3e4f0 http://localhost:8081>=>[#<HTTPClient::Session:0x0000000003a7c5f8 @client=#<HTTPClient:0x000000000316c3a0 ...>, @dest=#<HTTPClient::Site:0x1d3e4f0 http://localhost:8081>, @proxy=nil, @socket_sync=true, @tcp_keepalive=false, @requested_version=nil, @debug_dev=nil, @connect_timeout=60, @connect_retry=1, @send_timeout=120, @receive_timeout=60, @read_block_size=16384, @protocol_retry_count=5, @ssl_config=#<HTTPClient::SSLConfig:0x0000000003091a48 @client=#<HTTPClient:0x000000000316c3a0 ...>, @cert_store=#<OpenSSL::X509::Store:0x0000000003091a20 @verify_callback=nil, @error=nil, @error_string=nil, @chain=nil, @time=nil, @_httpclient_cert_store_items=[:default]>, @cert_store_crl_items=[], @client_ca=nil, @client_key_pass=nil, @client_key=nil, @client_cert=nil, @verify_mode=3, @verify_depth=nil, @verify_callback=nil, @dest=nil, @timeout=nil, @ssl_version=:auto, @options=2197947391, @ciphers="ALL:!aNULL:!eNULL:!SSLv2", @cacerts_loaded=false>, @ssl_peer_cert=nil, @test_loopback_http_response=[], @strict_response_size_check=false, @socket_local=#<HTTPClient::Site:0x185c48c tcp://0.0.0.0:0>, @agent_name="HTTPClient/1.0", @from=nil, @state=:WAIT, @requests=[], @status=404, @reason="Not Found", @headers=[["Date", "Mon, 05 Feb 2018 15:06:46 GMT"], ["Server", "Nexus/3.2.1-01 (OSS)"], ["X-Frame-Options", "SAMEORIGIN"], ["X-Content-Type-Options", "nosniff"], ["X-Siesta-FaultId", "48e0fb03-3576-4c3a-b3e3-f62dc47ef041"], ["Content-Length", "0"]], @socket=#<TCPSocket:fd 21>, @readbuf=nil, @transparent_gzip_decompression=false, @last_used=2018-02-05 15:06:46 +0000, @next_connection=true, @content_length=0, @chunked=false, @content_encoding=nil, @chunk_length=0, @version="1.1">]}, @sess_pool_mutex=#<Thread::Mutex:0x0000000003092cb8>, @sess_pool_last_checked=2018-02-05 15:06:46 +0000>, @ssl_config=#<HTTPClient::SSLConfig:0x0000000003091a48 @client=#<HTTPClient:0x000000000316c3a0 ...>, @cert_store=#<OpenSSL::X509::Store:0x0000000003091a20 @verify_callback=nil, @error=nil, @error_string=nil, @chain=nil, @time=nil, @_httpclient_cert_store_items=[:default]>, @cert_store_crl_items=[], @client_ca=nil, @client_key_pass=nil, @client_key=nil, @client_cert=nil, @verify_mode=3, @verify_depth=nil, @verify_callback=nil, @dest=nil, @timeout=nil, @ssl_version=:auto, @options=2197947391, @ciphers="ALL:!aNULL:!eNULL:!SSLv2", @cacerts_loaded=false>, @cookie_manager=#<WebAgent::CookieManager:0x000000000308b3c8 @cookies=[], @cookies_file=nil, @is_saved=true, @reject_domains=[], @accept_domains=[], @netscape_rule=false>, @follow_redirect_count=10>>
             end

             System Info:
             ------------
             chef_version=13.7.16
             platform=centos
             platform_version=7.4.1708
             ruby=ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-linux]
             program_name=chef-client worker: ppid=3014;start=15:04:12;
             executable=/opt/chef/bin/chef-client


           ================================================================================
           Error executing action `create` on resource 'nexus3_user[admin]'
           ================================================================================

           Nexus3::ApiError
           ----------------
           nexus3_api[upsert_user admin] (/tmp/kitchen/cache/cookbooks/nexus3/resources/user.rb line 42) had an error: Nexus3::ApiError: HTTP_STATUS=404

           Cookbook Trace:
           ---------------
           /tmp/kitchen/cache/cookbooks/nexus3/libraries/api.rb:36:in `request'
           /tmp/kitchen/cache/cookbooks/nexus3/libraries/api.rb:41:in `run_script'
           /tmp/kitchen/cache/cookbooks/nexus3/resources/api.rb:40:in `block (2 levels) in class_from_file'
           /tmp/kitchen/cache/cookbooks/nexus3/resources/api.rb:39:in `block in class_from_file'

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/company_nexus/recipes/nexus.rb

            23: nexus3_user 'admin' do
            24:   username 'admin'
            25:   email '[email protected]'
            26:   password 'admin123'
            27:   roles ['nx-admin']
            28:   action :create
            29: end
            30:

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/company_nexus/recipes/nexus.rb:23:in `from_file'

           nexus3_user("admin") do
             action [:create]
             updated true
             updated_by_last_action true
             default_guard_interpreter :default
             declared_type :nexus3_user
             cookbook_name "company_nexus"
             recipe_name "nexus"
             username "admin"
             email "[email protected]"
             password "*sensitive value suppressed*"
             roles ["nx-admin"]
           end

           System Info:
           ------------
           chef_version=13.7.16
           platform=centos
           platform_version=7.4.1708
           ruby=ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-linux]
           program_name=chef-client worker: ppid=3014;start=15:04:12;
           executable=/opt/chef/bin/chef-client

nexus.log

2018-02-05 15:06:44,893+0000 WARN  [qtp983440579-37] admin org.sonatype.nexus.siesta.internal.WebappExceptionMapper - (ID a6cd2195-5241-4e05-8f3c-5c038aeee24b) Response: [404] (no entity/body); mapped from: javax.ws.rs.NotFoundException: RESTEASY003210: Could not find resource for full path: http://localhost:8081/service/siesta/rest/v1/get_user/run
2018-02-05 15:06:45,424+0000 WARN  [qtp983440579-43] admin org.sonatype.nexus.siesta.internal.WebappExceptionMapper - (ID 5b623a54-1e19-4def-84f0-4553d630b38a) Response: [404] (no entity/body); mapped from: javax.ws.rs.NotFoundException: RESTEASY003210: Could not find resource for full path: http://localhost:8081/service/siesta/rest/v1/get_user
2018-02-05 15:06:46,347+0000 WARN  [qtp983440579-44] admin org.sonatype.nexus.siesta.internal.WebappExceptionMapper - (ID 900852c8-2602-4a94-a8e5-3787054edab5) Response: [404] (no entity/body); mapped from: javax.ws.rs.NotFoundException: RESTEASY003210: Could not find resource for full path: http://localhost:8081/service/siesta/rest/v1/upsert_user
2018-02-05 15:06:46,475+0000 WARN  [qtp983440579-43] admin org.sonatype.nexus.siesta.internal.WebappExceptionMapper - (ID a211b0ae-d49c-489b-a795-f33440f5be2c) Response: [404] (no entity/body); mapped from: javax.ws.rs.NotFoundException: RESTEASY003210: Could not find resource for full path: http://localhost:8081/service/siesta/rest/v1/upsert_user
2018-02-05 15:06:46,533+0000 WARN  [qtp983440579-43] admin org.sonatype.nexus.siesta.internal.WebappExceptionMapper - (ID 48e0fb03-3576-4c3a-b3e3-f62dc47ef041) Response: [404] (no entity/body); mapped from: javax.ws.rs.NotFoundException: RESTEASY003210: Could not find resource for full path: http://localhost:8081/service/siesta/rest/v1/upsert_user/run

@olive42
Copy link
Contributor

olive42 commented Feb 6, 2018

The Chef run is trying to run the upsert_user script which does not seem to exist on the server; but it should have just been created. The warnings in the logs may just be due to Chef testing the existence of the scripts in load_current_value (from the api resource).

Does this work if you run chef-client again? (or kitchen converge)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants