How do i create a chef server user using knife user command?



  • Link to knife-user command: https://www.lightnetics.com/post/2011

    All the options to the knife user create command.

    knife user create --help
    knife user create USERNAME DISPLAY_NAME FIRST_NAME LAST_NAME EMAIL PASSWORD (options)
        -a, --admin                      DEPRECATED: Open Source Chef 11 only. Create the user as an admin.
        -s, --server-url URL             Chef Server URL
            --chef-zero-host HOST        Host to start chef-zero on
            --chef-zero-port PORT        Port (or port range) to start chef-zero on.  Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works.
            --key KEY                    API Client Key
            --[no-]color                 Use colored output, defaults to enabled
        -c, --config CONFIG              The configuration file to use
            --config-option OPTION=VALUE Override a single configuration option
            --defaults                   Accept default values for all questions
        -d, --disable-editing            Do not open EDITOR, just accept the data as is
        -e, --editor EDITOR              Set the editor to use for interactive commands
        -E, --environment ENVIRONMENT    Set the Chef environment (except for in searches, where this will be flagrantly ignored)
        -f, --file FILE                  Write the private key to a file if the server generated one.
            --[no-]fips                  Enable fips mode
        -F, --format FORMAT              Which format to use for output
            --[no-]listen                Whether a local mode (-z) server binds to a port
        -z, --local-mode                 Point knife commands at local repository instead of server
        -u, --user USER                  API Client Username
        -k, --prevent-keygen             API V1 (Chef Server 12.1+) only. Prevent server from generating a default key pair for you. Cannot be passed with --user-key.
            --print-after                Show the data after a destructive operation
            --profile PROFILE            The credentials profile to select
            --user-key FILENAME          Set the initial default key for the user from a file on disk (cannot pass with --prevent-keygen).
        -p, --password PASSWORD          DEPRECATED: Open Source Chef 11 only. Password for newly created user.
        -V, --verbose                    More verbose output. Use twice for max verbosity
        -v, --version                    Show chef version
        -y, --yes                        Say yes to all prompts for confirmation
        -h, --help                       Show this message
    

    Your user has to be part of the admin group to be able to run this command , it will display the private key to the screen, you can send it to a file with the -f option.
    Format is:
    knife user create USERNAME DISPLAY_NAME FIRST_NAME LAST_NAME EMAIL PASSWORD

    $ knife user create trainer Trainer One Trainer [email protected] 'trainer'
    

    Creating a use does not mean you get to work with chef immediately, an admin user has to invite you to the organisation, when you first log in you can accept the pending invitation. This is what you see:

    0_1522497115315_chef_invite.png


Log in to reply
 

© Lightnetics 2024