This is how I do in SQL Server:
insert into users(name, password) values('admin', '1');
declare @id int;
set @id = @@identity;
insert into usersroles values(@id, 1);
insert into usersroles values(@id, 2);
@@identity
is in sql server the last inserted identity (serial)
How to do the same in Postgres?