[PATCH conductor] BZ#806001 - Create default admin via database seeds

John Eckersberg jeckersb at redhat.com
Thu Jun 21 19:40:59 UTC 2012


On Wed, 20 Jun 2012 18:09:50 -0400, John Eckersberg <jeckersb at redhat.com> wrote:
> Previously, the default admin user was created by aeolus-configure,
> but this approach was confusing for users.  By creating the admin as
> part of the database seeds, we are guaranteed to always have a usable
> admin user at first login.  The expecation is for administrative users
> to be managed via the web UI (or API), not via configure.
> ---
>  src/db/seeds.rb |   14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/src/db/seeds.rb b/src/db/seeds.rb
> index 529ad76..ce3981d 100644
> --- a/src/db/seeds.rb
> +++ b/src/db/seeds.rb
> @@ -197,3 +197,17 @@ if CredentialDefinition.all.empty?
>    CredentialDefinition.create!(:name => 'x509private', :label => 'key', :input_type => 'file', :provider_type_id => ec2.id)
>    CredentialDefinition.create!(:name => 'x509public', :label => 'certificate', :input_type => 'file', :provider_type_id => ec2.id)
>  end
> +
> +# Default admin user
> +user = User.create!(:login => 'admin',
> +                    :email => 'root at localhost.localdomain',
> +                    :password => 'password',
> +                    :password_confirmation => 'password',
> +                    :first_name => 'Administrator',
> +                    :last_name  => '',
> +                    :quota => Quota.new)
> +registration = RegistrationService.new(user)
> +registration.save
> +permission = Permission.create!(:role => Role.find_by_name('base.admin'),
> +                                :permission_object => BasePermissionObject.general_permission_scope,
> +                                :entity => user.entity)
> -- 
> 1.7.10.2
> 

Mo pointed out that this breaks cukes, so I've reverted it.  I've got
yet another plan to do this that is isolated to configure, stay tuned.



More information about the aeolus-devel mailing list